Skip to content

Commit 69cc685

Browse files
authored
exporter/prometheus: Expose scope name, version, schema URL and attributes as labels (#40004)
#### Description This PR is a PoC for the spec change described at open-telemetry/opentelemetry-specification#4223 In the specification change, it's being proposed that Prometheus exporters stop generating the metric `otel_scope_info` with all the scope attributes and instead add all scope information as labels, turning Scope information "identifying". Turns out our exporter never exposed `otel_scope_info`, so this PR just introduces the addition of the new labels. --------- Signed-off-by: Arthur Silva Sens <[email protected]>
1 parent e6f6dcf commit 69cc685

File tree

7 files changed

+197
-104
lines changed

7 files changed

+197
-104
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: bug_fix
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: prometheusexporter
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Expose Scope Name, Version, Schema URL, and Attributes as labels.
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [40004]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext: This work is done to comply with https://github.com/open-telemetry/opentelemetry-specification/issues/4223.
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: [api]

exporter/prometheusexporter/accumulator.go

Lines changed: 51 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ type accumulatedValue struct {
2626
// updated indicates when metric was last changed.
2727
updated time.Time
2828

29-
scope pcommon.InstrumentationScope
29+
scopeName string
30+
scopeVersion string
31+
scopeSchemaURL string
32+
scopeAttributes pcommon.Map
3033
}
3134

3235
// accumulator stores aggregated values of incoming metrics
@@ -35,7 +38,7 @@ type accumulator interface {
3538
Accumulate(resourceMetrics pmetric.ResourceMetrics) (processed int)
3639
// Collect returns a slice with relevant aggregated metrics and their resource attributes.
3740
// The number or metrics and attributes returned will be the same.
38-
Collect() (metrics []pmetric.Metric, resourceAttrs []pcommon.Map)
41+
Collect() (metrics []pmetric.Metric, resourceAttrs []pcommon.Map, scopeNames []string, scopeVersions []string, scopeSchemaURLs []string, scopeAttributes []pcommon.Map)
3942
}
4043

4144
// LastValueAccumulator keeps last value for accumulated metrics
@@ -68,25 +71,25 @@ func (a *lastValueAccumulator) Accumulate(rm pmetric.ResourceMetrics) (n int) {
6871

6972
metrics := ilm.Metrics()
7073
for j := 0; j < metrics.Len(); j++ {
71-
n += a.addMetric(metrics.At(j), ilm.Scope(), resourceAttrs, now)
74+
n += a.addMetric(metrics.At(j), ilm.Scope().Name(), ilm.Scope().Version(), ilm.SchemaUrl(), ilm.Scope().Attributes(), resourceAttrs, now)
7275
}
7376
}
7477

7578
return
7679
}
7780

78-
func (a *lastValueAccumulator) addMetric(metric pmetric.Metric, il pcommon.InstrumentationScope, resourceAttrs pcommon.Map, now time.Time) int {
81+
func (a *lastValueAccumulator) addMetric(metric pmetric.Metric, scopeName string, scopeVersion string, scopeSchemaURL string, scopeAttributes pcommon.Map, resourceAttrs pcommon.Map, now time.Time) int {
7982
a.logger.Debug(fmt.Sprintf("accumulating metric: %s", metric.Name()))
8083

8184
switch metric.Type() {
8285
case pmetric.MetricTypeGauge:
83-
return a.accumulateGauge(metric, il, resourceAttrs, now)
86+
return a.accumulateGauge(metric, scopeName, scopeVersion, scopeSchemaURL, scopeAttributes, resourceAttrs, now)
8487
case pmetric.MetricTypeSum:
85-
return a.accumulateSum(metric, il, resourceAttrs, now)
88+
return a.accumulateSum(metric, scopeName, scopeVersion, scopeSchemaURL, scopeAttributes, resourceAttrs, now)
8689
case pmetric.MetricTypeHistogram:
87-
return a.accumulateHistogram(metric, il, resourceAttrs, now)
90+
return a.accumulateHistogram(metric, scopeName, scopeVersion, scopeSchemaURL, scopeAttributes, resourceAttrs, now)
8891
case pmetric.MetricTypeSummary:
89-
return a.accumulateSummary(metric, il, resourceAttrs, now)
92+
return a.accumulateSummary(metric, scopeName, scopeVersion, scopeSchemaURL, scopeAttributes, resourceAttrs, now)
9093
default:
9194
a.logger.With(
9295
zap.String("data_type", string(metric.Type())),
@@ -97,12 +100,12 @@ func (a *lastValueAccumulator) addMetric(metric pmetric.Metric, il pcommon.Instr
97100
return 0
98101
}
99102

100-
func (a *lastValueAccumulator) accumulateSummary(metric pmetric.Metric, il pcommon.InstrumentationScope, resourceAttrs pcommon.Map, now time.Time) (n int) {
103+
func (a *lastValueAccumulator) accumulateSummary(metric pmetric.Metric, scopeName string, scopeVersion string, scopeSchemaURL string, scopeAttributes pcommon.Map, resourceAttrs pcommon.Map, now time.Time) (n int) {
101104
dps := metric.Summary().DataPoints()
102105
for i := 0; i < dps.Len(); i++ {
103106
ip := dps.At(i)
104107

105-
signature := timeseriesSignature(il.Name(), metric, ip.Attributes(), resourceAttrs)
108+
signature := timeseriesSignature(scopeName, scopeVersion, scopeSchemaURL, scopeAttributes, metric, ip.Attributes(), resourceAttrs)
106109
if ip.Flags().NoRecordedValue() {
107110
a.registeredMetrics.Delete(signature)
108111
return 0
@@ -119,19 +122,19 @@ func (a *lastValueAccumulator) accumulateSummary(metric pmetric.Metric, il pcomm
119122

120123
m := copyMetricMetadata(metric)
121124
ip.CopyTo(m.SetEmptySummary().DataPoints().AppendEmpty())
122-
a.registeredMetrics.Store(signature, &accumulatedValue{value: m, resourceAttrs: resourceAttrs, scope: il, updated: now})
125+
a.registeredMetrics.Store(signature, &accumulatedValue{value: m, resourceAttrs: resourceAttrs, scopeName: scopeName, scopeVersion: scopeVersion, scopeSchemaURL: scopeSchemaURL, scopeAttributes: scopeAttributes, updated: now})
123126
n++
124127
}
125128

126129
return n
127130
}
128131

129-
func (a *lastValueAccumulator) accumulateGauge(metric pmetric.Metric, il pcommon.InstrumentationScope, resourceAttrs pcommon.Map, now time.Time) (n int) {
132+
func (a *lastValueAccumulator) accumulateGauge(metric pmetric.Metric, scopeName string, scopeVersion string, scopeSchemaURL string, scopeAttributes pcommon.Map, resourceAttrs pcommon.Map, now time.Time) (n int) {
130133
dps := metric.Gauge().DataPoints()
131134
for i := 0; i < dps.Len(); i++ {
132135
ip := dps.At(i)
133136

134-
signature := timeseriesSignature(il.Name(), metric, ip.Attributes(), resourceAttrs)
137+
signature := timeseriesSignature(scopeName, scopeVersion, scopeSchemaURL, scopeAttributes, metric, ip.Attributes(), resourceAttrs)
135138
if ip.Flags().NoRecordedValue() {
136139
a.registeredMetrics.Delete(signature)
137140
return 0
@@ -141,7 +144,7 @@ func (a *lastValueAccumulator) accumulateGauge(metric pmetric.Metric, il pcommon
141144
if !ok {
142145
m := copyMetricMetadata(metric)
143146
ip.CopyTo(m.SetEmptyGauge().DataPoints().AppendEmpty())
144-
a.registeredMetrics.Store(signature, &accumulatedValue{value: m, resourceAttrs: resourceAttrs, scope: il, updated: now})
147+
a.registeredMetrics.Store(signature, &accumulatedValue{value: m, resourceAttrs: resourceAttrs, scopeName: scopeName, scopeVersion: scopeVersion, scopeSchemaURL: scopeSchemaURL, scopeAttributes: scopeAttributes, updated: now})
145148
n++
146149
continue
147150
}
@@ -154,13 +157,13 @@ func (a *lastValueAccumulator) accumulateGauge(metric pmetric.Metric, il pcommon
154157

155158
m := copyMetricMetadata(metric)
156159
ip.CopyTo(m.SetEmptyGauge().DataPoints().AppendEmpty())
157-
a.registeredMetrics.Store(signature, &accumulatedValue{value: m, resourceAttrs: resourceAttrs, scope: il, updated: now})
160+
a.registeredMetrics.Store(signature, &accumulatedValue{value: m, resourceAttrs: resourceAttrs, scopeName: scopeName, scopeVersion: scopeVersion, scopeSchemaURL: scopeSchemaURL, scopeAttributes: scopeAttributes, updated: now})
158161
n++
159162
}
160163
return
161164
}
162165

163-
func (a *lastValueAccumulator) accumulateSum(metric pmetric.Metric, il pcommon.InstrumentationScope, resourceAttrs pcommon.Map, now time.Time) (n int) {
166+
func (a *lastValueAccumulator) accumulateSum(metric pmetric.Metric, scopeName string, scopeVersion string, scopeSchemaURL string, scopeAttributes pcommon.Map, resourceAttrs pcommon.Map, now time.Time) (n int) {
164167
doubleSum := metric.Sum()
165168

166169
// Drop metrics with unspecified aggregations
@@ -177,7 +180,7 @@ func (a *lastValueAccumulator) accumulateSum(metric pmetric.Metric, il pcommon.I
177180
for i := 0; i < dps.Len(); i++ {
178181
ip := dps.At(i)
179182

180-
signature := timeseriesSignature(il.Name(), metric, ip.Attributes(), resourceAttrs)
183+
signature := timeseriesSignature(scopeName, scopeVersion, scopeSchemaURL, scopeAttributes, metric, ip.Attributes(), resourceAttrs)
181184
if ip.Flags().NoRecordedValue() {
182185
a.registeredMetrics.Delete(signature)
183186
return 0
@@ -189,7 +192,7 @@ func (a *lastValueAccumulator) accumulateSum(metric pmetric.Metric, il pcommon.I
189192
m.SetEmptySum().SetIsMonotonic(metric.Sum().IsMonotonic())
190193
m.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative)
191194
ip.CopyTo(m.Sum().DataPoints().AppendEmpty())
192-
a.registeredMetrics.Store(signature, &accumulatedValue{value: m, resourceAttrs: resourceAttrs, scope: il, updated: now})
195+
a.registeredMetrics.Store(signature, &accumulatedValue{value: m, resourceAttrs: resourceAttrs, scopeName: scopeName, scopeVersion: scopeVersion, scopeSchemaURL: scopeSchemaURL, scopeAttributes: scopeAttributes, updated: now})
193196
n++
194197
continue
195198
}
@@ -215,21 +218,21 @@ func (a *lastValueAccumulator) accumulateSum(metric pmetric.Metric, il pcommon.I
215218
m.SetEmptySum().SetIsMonotonic(metric.Sum().IsMonotonic())
216219
m.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative)
217220
ip.CopyTo(m.Sum().DataPoints().AppendEmpty())
218-
a.registeredMetrics.Store(signature, &accumulatedValue{value: m, resourceAttrs: resourceAttrs, scope: il, updated: now})
221+
a.registeredMetrics.Store(signature, &accumulatedValue{value: m, resourceAttrs: resourceAttrs, scopeName: scopeName, scopeVersion: scopeVersion, scopeSchemaURL: scopeSchemaURL, scopeAttributes: scopeAttributes, updated: now})
219222
n++
220223
}
221224
return
222225
}
223226

224-
func (a *lastValueAccumulator) accumulateHistogram(metric pmetric.Metric, il pcommon.InstrumentationScope, resourceAttrs pcommon.Map, now time.Time) (n int) {
227+
func (a *lastValueAccumulator) accumulateHistogram(metric pmetric.Metric, scopeName string, scopeVersion string, scopeSchemaURL string, scopeAttributes pcommon.Map, resourceAttrs pcommon.Map, now time.Time) (n int) {
225228
histogram := metric.Histogram()
226229
a.logger.Debug("Accumulate histogram.....")
227230
dps := histogram.DataPoints()
228231

229232
for i := 0; i < dps.Len(); i++ {
230233
ip := dps.At(i)
231234

232-
signature := timeseriesSignature(il.Name(), metric, ip.Attributes(), resourceAttrs) // uniquely identify this time series you are accumulating for
235+
signature := timeseriesSignature(scopeName, scopeVersion, scopeSchemaURL, scopeAttributes, metric, ip.Attributes(), resourceAttrs) // uniquely identify this time series you are accumulating for
233236
if ip.Flags().NoRecordedValue() {
234237
a.registeredMetrics.Delete(signature)
235238
return 0
@@ -241,7 +244,7 @@ func (a *lastValueAccumulator) accumulateHistogram(metric pmetric.Metric, il pco
241244
m := copyMetricMetadata(metric)
242245
ip.CopyTo(m.SetEmptyHistogram().DataPoints().AppendEmpty())
243246
m.Histogram().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative)
244-
a.registeredMetrics.Store(signature, &accumulatedValue{value: m, resourceAttrs: resourceAttrs, scope: il, updated: now})
247+
a.registeredMetrics.Store(signature, &accumulatedValue{value: m, resourceAttrs: resourceAttrs, scopeName: scopeName, scopeVersion: scopeVersion, scopeSchemaURL: scopeSchemaURL, scopeAttributes: scopeAttributes, updated: now})
245248
n++
246249
continue
247250
}
@@ -284,18 +287,22 @@ func (a *lastValueAccumulator) accumulateHistogram(metric pmetric.Metric, il pco
284287
// unsupported temporality
285288
continue
286289
}
287-
a.registeredMetrics.Store(signature, &accumulatedValue{value: m, resourceAttrs: resourceAttrs, scope: il, updated: now})
290+
a.registeredMetrics.Store(signature, &accumulatedValue{value: m, resourceAttrs: resourceAttrs, scopeName: scopeName, scopeVersion: scopeVersion, scopeSchemaURL: scopeSchemaURL, scopeAttributes: scopeAttributes, updated: now})
288291
n++
289292
}
290293
return
291294
}
292295

293296
// Collect returns a slice with relevant aggregated metrics and their resource attributes.
294-
func (a *lastValueAccumulator) Collect() ([]pmetric.Metric, []pcommon.Map) {
297+
func (a *lastValueAccumulator) Collect() ([]pmetric.Metric, []pcommon.Map, []string, []string, []string, []pcommon.Map) {
295298
a.logger.Debug("Accumulator collect called")
296299

297300
var metrics []pmetric.Metric
298301
var resourceAttrs []pcommon.Map
302+
var scopeNames []string
303+
var scopeVersions []string
304+
var scopeSchemaURLs []string
305+
var scopeAttributes []pcommon.Map
299306
expirationTime := time.Now().Add(-a.metricExpiration)
300307

301308
a.registeredMetrics.Range(func(key, value any) bool {
@@ -308,23 +315,38 @@ func (a *lastValueAccumulator) Collect() ([]pmetric.Metric, []pcommon.Map) {
308315

309316
metrics = append(metrics, v.value)
310317
resourceAttrs = append(resourceAttrs, v.resourceAttrs)
318+
scopeNames = append(scopeNames, v.scopeName)
319+
scopeVersions = append(scopeVersions, v.scopeVersion)
320+
scopeSchemaURLs = append(scopeSchemaURLs, v.scopeSchemaURL)
321+
scopeAttributes = append(scopeAttributes, v.scopeAttributes)
311322
return true
312323
})
313324

314-
return metrics, resourceAttrs
325+
return metrics, resourceAttrs, scopeNames, scopeVersions, scopeSchemaURLs, scopeAttributes
315326
}
316327

317-
func timeseriesSignature(ilmName string, metric pmetric.Metric, attributes pcommon.Map, resourceAttrs pcommon.Map) string {
328+
func timeseriesSignature(scopeName string, scopeVersion string, scopeSchemaURL string, scopeAttributes pcommon.Map, metric pmetric.Metric, attributes pcommon.Map, resourceAttrs pcommon.Map) string {
318329
var b strings.Builder
319-
b.WriteString(metric.Type().String())
320-
b.WriteString("*" + ilmName)
321330
b.WriteString("*" + metric.Name())
322-
attrs := make([]string, 0, attributes.Len())
331+
b.WriteString(metric.Type().String())
332+
b.WriteString("*" + scopeName)
333+
b.WriteString("*" + scopeVersion)
334+
b.WriteString("*" + scopeSchemaURL)
335+
336+
attrs := make([]string, 0, scopeAttributes.Len())
337+
for k, v := range scopeAttributes.All() {
338+
attrs = append(attrs, k+"*"+v.AsString())
339+
}
340+
sort.Strings(attrs)
341+
b.WriteString("*" + strings.Join(attrs, "*"))
342+
343+
attrs = make([]string, 0, attributes.Len())
323344
for k, v := range attributes.All() {
324345
attrs = append(attrs, k+"*"+v.AsString())
325346
}
326347
sort.Strings(attrs)
327348
b.WriteString("*" + strings.Join(attrs, "*"))
349+
328350
if job, ok := extractJob(resourceAttrs); ok {
329351
b.WriteString("*" + model.JobLabel + "*" + job)
330352
}

exporter/prometheusexporter/accumulator_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -240,14 +240,14 @@ func TestAccumulateMetrics(t *testing.T) {
240240

241241
m2Labels, _, m2Value, m2Temporality, m2IsMonotonic := getMetricProperties(ilm2.Metrics().At(0))
242242

243-
signature := timeseriesSignature(ilm2.Scope().Name(), ilm2.Metrics().At(0), m2Labels, pcommon.NewMap())
243+
signature := timeseriesSignature(ilm2.Scope().Name(), ilm2.Scope().Version(), ilm2.SchemaUrl(), ilm2.Scope().Attributes(), ilm2.Metrics().At(0), m2Labels, pcommon.NewMap())
244244
m, ok := a.registeredMetrics.Load(signature)
245245
require.True(t, ok)
246246

247247
v := m.(*accumulatedValue)
248248
vLabels, vTS, vValue, vTemporality, vIsMonotonic := getMetricProperties(ilm2.Metrics().At(0))
249249

250-
require.Equal(t, "test", v.scope.Name())
250+
require.Equal(t, "test", v.scopeName)
251251
require.Equal(t, v.value.Type(), ilm2.Metrics().At(0).Type())
252252
for k, v := range vLabels.All() {
253253
r, _ := m2Labels.Get(k)
@@ -350,14 +350,14 @@ func TestAccumulateDeltaToCumulative(t *testing.T) {
350350
require.Equal(t, 2, n)
351351

352352
mLabels, _, mValue, _, _ := getMetricProperties(ilm.Metrics().At(1))
353-
signature := timeseriesSignature(ilm.Scope().Name(), ilm.Metrics().At(0), mLabels, pcommon.NewMap())
353+
signature := timeseriesSignature(ilm.Scope().Name(), ilm.Scope().Version(), ilm.SchemaUrl(), ilm.Scope().Attributes(), ilm.Metrics().At(0), mLabels, pcommon.NewMap())
354354
m, ok := a.registeredMetrics.Load(signature)
355355
require.True(t, ok)
356356

357357
v := m.(*accumulatedValue)
358358
vLabels, vTS, vValue, vTemporality, vIsMonotonic := getMetricProperties(v.value)
359359

360-
require.Equal(t, "test", v.scope.Name())
360+
require.Equal(t, "test", v.scopeName)
361361
require.Equal(t, v.value.Type(), ilm.Metrics().At(0).Type())
362362
require.Equal(t, v.value.Type(), ilm.Metrics().At(1).Type())
363363

@@ -405,7 +405,7 @@ func TestAccumulateDeltaToCumulativeHistogram(t *testing.T) {
405405

406406
m1 := ilm.Metrics().At(0).Histogram().DataPoints().At(0)
407407
m2 := ilm.Metrics().At(1).Histogram().DataPoints().At(0)
408-
signature := timeseriesSignature(ilm.Scope().Name(), ilm.Metrics().At(0), m2.Attributes(), pcommon.NewMap())
408+
signature := timeseriesSignature(ilm.Scope().Name(), ilm.Scope().Version(), ilm.SchemaUrl(), ilm.Scope().Attributes(), ilm.Metrics().At(0), m2.Attributes(), pcommon.NewMap())
409409

410410
a := newAccumulator(zap.NewNop(), 1*time.Hour).(*lastValueAccumulator)
411411
n := a.Accumulate(resourceMetrics)
@@ -438,7 +438,7 @@ func TestAccumulateDeltaToCumulativeHistogram(t *testing.T) {
438438

439439
m1 := ilm.Metrics().At(0).Histogram().DataPoints().At(0)
440440
m2 := ilm.Metrics().At(1).Histogram().DataPoints().At(0)
441-
signature := timeseriesSignature(ilm.Scope().Name(), ilm.Metrics().At(0), m2.Attributes(), pcommon.NewMap())
441+
signature := timeseriesSignature(ilm.Scope().Name(), ilm.Scope().Version(), ilm.SchemaUrl(), ilm.Scope().Attributes(), ilm.Metrics().At(0), m2.Attributes(), pcommon.NewMap())
442442

443443
// should ignore metric with different buckets from the past
444444
a := newAccumulator(zap.NewNop(), 1*time.Hour).(*lastValueAccumulator)
@@ -472,7 +472,7 @@ func TestAccumulateDeltaToCumulativeHistogram(t *testing.T) {
472472
appendDeltaHistogram(ts1, ts2, 7, 5, []uint64{3, 1, 1, 0, 0}, []float64{0.1, 0.2, 1, 10}, ilm.Metrics())
473473

474474
m2 := ilm.Metrics().At(1).Histogram().DataPoints().At(0)
475-
signature := timeseriesSignature(ilm.Scope().Name(), ilm.Metrics().At(0), m2.Attributes(), pcommon.NewMap())
475+
signature := timeseriesSignature(ilm.Scope().Name(), ilm.Scope().Version(), ilm.SchemaUrl(), ilm.Scope().Attributes(), ilm.Metrics().At(0), m2.Attributes(), pcommon.NewMap())
476476

477477
// should ignore metric with different buckets from the past
478478
a := newAccumulator(zap.NewNop(), 1*time.Hour).(*lastValueAccumulator)
@@ -507,7 +507,7 @@ func TestAccumulateDeltaToCumulativeHistogram(t *testing.T) {
507507
appendDeltaHistogram(startTs2, ts2, 7, 5, []uint64{3, 1, 1, 0, 0}, []float64{0.1, 0.2, 1, 10}, ilm.Metrics())
508508

509509
m1 := ilm.Metrics().At(0).Histogram().DataPoints().At(0)
510-
signature := timeseriesSignature(ilm.Scope().Name(), ilm.Metrics().At(0), m1.Attributes(), pcommon.NewMap())
510+
signature := timeseriesSignature(ilm.Scope().Name(), ilm.Scope().Version(), ilm.SchemaUrl(), ilm.Scope().Attributes(), ilm.Metrics().At(0), m1.Attributes(), pcommon.NewMap())
511511

512512
a := newAccumulator(zap.NewNop(), 1*time.Hour).(*lastValueAccumulator)
513513
n := a.Accumulate(resourceMetrics)
@@ -541,7 +541,7 @@ func TestAccumulateDeltaToCumulativeHistogram(t *testing.T) {
541541
appendDeltaHistogram(startTs2, ts2, 7, 5, []uint64{3, 1, 1, 0, 0}, []float64{0.1, 0.2, 1, 10}, ilm.Metrics())
542542

543543
m2 := ilm.Metrics().At(1).Histogram().DataPoints().At(0)
544-
signature := timeseriesSignature(ilm.Scope().Name(), ilm.Metrics().At(0), m2.Attributes(), pcommon.NewMap())
544+
signature := timeseriesSignature(ilm.Scope().Name(), ilm.Scope().Version(), ilm.SchemaUrl(), ilm.Scope().Attributes(), ilm.Metrics().At(0), m2.Attributes(), pcommon.NewMap())
545545

546546
a := newAccumulator(zap.NewNop(), 1*time.Hour).(*lastValueAccumulator)
547547
n := a.Accumulate(resourceMetrics)
@@ -632,7 +632,7 @@ func TestAccumulateDroppedMetrics(t *testing.T) {
632632
n := a.Accumulate(resourceMetrics)
633633
require.Equal(t, 0, n)
634634

635-
signature := timeseriesSignature(ilm.Scope().Name(), ilm.Metrics().At(0), pcommon.NewMap(), pcommon.NewMap())
635+
signature := timeseriesSignature(ilm.Scope().Name(), ilm.Scope().Version(), ilm.SchemaUrl(), ilm.Scope().Attributes(), ilm.Metrics().At(0), pcommon.NewMap(), pcommon.NewMap())
636636
v, ok := a.registeredMetrics.Load(signature)
637637
require.False(t, ok)
638638
require.Nil(t, v)
@@ -646,7 +646,7 @@ func TestTimeseriesSignatureNotMutating(t *testing.T) {
646646
attrs.PutStr("label_1", "1")
647647
origAttrs := pcommon.NewMap()
648648
attrs.CopyTo(origAttrs)
649-
timeseriesSignature("test_il", pmetric.NewMetric(), attrs, attrs)
649+
timeseriesSignature("test_il", "1.0.0", "http://test.com", attrs, pmetric.NewMetric(), attrs, pcommon.NewMap())
650650
require.Equal(t, origAttrs, attrs) // make sure attrs are not mutated
651651
}
652652

0 commit comments

Comments
 (0)