MCPcopy Create free account
hub / github.com/cortexproject/cortex / addAttributesToMetric

Function addAttributesToMetric

pkg/util/push/otlp.go:277–290  ·  view source on GitHub ↗

addAttributesToMetric adds additional labels to the given metric

(metric pmetric.Metric, labelMap pcommon.Map)

Source from the content-addressed store, hash-verified

275
276// addAttributesToMetric adds additional labels to the given metric
277func addAttributesToMetric(metric pmetric.Metric, labelMap pcommon.Map) {
278 switch metric.Type() {
279 case pmetric.MetricTypeGauge:
280 addAttributesToNumberDataPoints(metric.Gauge().DataPoints(), labelMap)
281 case pmetric.MetricTypeSum:
282 addAttributesToNumberDataPoints(metric.Sum().DataPoints(), labelMap)
283 case pmetric.MetricTypeHistogram:
284 addAttributesToHistogramDataPoints(metric.Histogram().DataPoints(), labelMap)
285 case pmetric.MetricTypeSummary:
286 addAttributesToSummaryDataPoints(metric.Summary().DataPoints(), labelMap)
287 case pmetric.MetricTypeExponentialHistogram:
288 addAttributesToExponentialHistogramDataPoints(metric.ExponentialHistogram().DataPoints(), labelMap)
289 }
290}
291
292func addAttributesToNumberDataPoints(ps pmetric.NumberDataPointSlice, newAttributeMap pcommon.Map) {
293 for i := 0; i < ps.Len(); i++ {

Callers 1

Tested by

no test coverage detected