Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
atoulme committed Jun 16, 2023
1 parent 8ca8e51 commit abafee3
Showing 1 changed file with 13 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,20 @@ func GetMetrics(set receiver.CreateSettings, rq *corev1.ResourceQuota) pmetric.M
mb := imetadata.NewMetricsBuilder(imetadata.DefaultMetricsBuilderConfig(), set)
ts := pcommon.NewTimestampFromTime(time.Now())

for _, t := range []struct {
recordFn func(ts pcommon.Timestamp, val int64, resource string)
rl corev1.ResourceList
}{
{
mb.RecordK8sResourceQuotaHardLimitDataPoint,
rq.Status.Hard,
},
{
mb.RecordK8sResourceQuotaUsedDataPoint,
rq.Status.Used,
},
} {
for k, v := range t.rl {

val := v.Value()
if strings.HasSuffix(string(k), ".cpu") {
val = v.MilliValue()
}
mb.RecordK8sResourceQuotaUsedDataPoint(ts, val, string(k))
mb.RecordK8sResourceQuotaHardLimitDataPoint(ts, val, string(k))
for k, v := range rq.Status.Hard {
val := v.Value()
if strings.HasSuffix(string(k), ".cpu") {
val = v.MilliValue()
}
mb.RecordK8sResourceQuotaHardLimitDataPoint(ts, val, string(k))
}

for k, v := range rq.Status.Used {
val := v.Value()
if strings.HasSuffix(string(k), ".cpu") {
val = v.MilliValue()
}
mb.RecordK8sResourceQuotaUsedDataPoint(ts, val, string(k))
}

return mb.Emit(imetadata.WithK8sResourcequotaUID(string(rq.UID)), imetadata.WithK8sResourcequotaName(rq.Name), imetadata.WithK8sNamespaceName(rq.Namespace), imetadata.WithOpencensusResourcetype("k8s"))
Expand Down

0 comments on commit abafee3

Please sign in to comment.