You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[chore](prometheusreceiver): use type and unit as identifier in tests (open-telemetry#38645)
I'd like to fix a technical dept from open-telemetry#28663 where the Prometheus
receiver didn't allow receiving both classic and native histogram for
the same metric name. To test the implementation, the assertions must
not assume that the metric name alone is identifying in OpenTelemetry.
No new tests added, I just refactored to make name+type+unit the
identifier.
Also I made it implicit that `doCompare` fails on metrics that were not
expected - excluding the 5 scrape metrics. This means that
`assertMetricAbsent` is not needed anymore.
Signed-off-by: György Krajcsovits <[email protected]>
require.Equal(t, -1, pos, "metric %s is not unique", id)
545
+
pos=k
546
+
547
+
fori, de:=rangeme.dataPointExpectations {
453
548
switchm.Type() {
454
549
casepmetric.MetricTypeGauge:
455
550
for_, npc:=rangede.numberPointComparator {
456
-
require.Len(t, dataPointExpectations, m.Gauge().DataPoints().Len(), "Expected number of data-points in Gauge metric '%s' does not match to testdata", name)
551
+
require.Len(t, me.dataPointExpectations, m.Gauge().DataPoints().Len(), "Expected number of data-points in Gauge metric '%s' does not match to testdata", id)
457
552
npc(t, m.Gauge().DataPoints().At(i))
458
553
}
459
554
casepmetric.MetricTypeSum:
460
555
for_, npc:=rangede.numberPointComparator {
461
-
require.Len(t, dataPointExpectations, m.Sum().DataPoints().Len(), "Expected number of data-points in Sum metric '%s' does not match to testdata", name)
556
+
require.Len(t, me.dataPointExpectations, m.Sum().DataPoints().Len(), "Expected number of data-points in Sum metric '%s' does not match to testdata", id)
462
557
npc(t, m.Sum().DataPoints().At(i))
463
558
}
464
559
casepmetric.MetricTypeHistogram:
465
560
for_, hpc:=rangede.histogramPointComparator {
466
-
require.Len(t, dataPointExpectations, m.Histogram().DataPoints().Len(), "Expected number of data-points in Histogram metric '%s' does not match to testdata", name)
561
+
require.Len(t, me.dataPointExpectations, m.Histogram().DataPoints().Len(), "Expected number of data-points in Histogram metric '%s' does not match to testdata", id)
467
562
hpc(t, m.Histogram().DataPoints().At(i))
468
563
}
469
564
casepmetric.MetricTypeSummary:
470
565
for_, spc:=rangede.summaryPointComparator {
471
-
require.Len(t, dataPointExpectations, m.Summary().DataPoints().Len(), "Expected number of data-points in Summary metric '%s' does not match to testdata", name)
566
+
require.Len(t, me.dataPointExpectations, m.Summary().DataPoints().Len(), "Expected number of data-points in Summary metric '%s' does not match to testdata", id)
require.Len(t, dataPointExpectations, m.ExponentialHistogram().DataPoints().Len(), "Expected number of data-points in Exponential Histogram metric '%s' does not match to testdata", name)
571
+
require.Len(t, me.dataPointExpectations, m.ExponentialHistogram().DataPoints().Len(), "Expected number of data-points in Exponential Histogram metric '%s' does not match to testdata", id)
0 commit comments