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
I'd like to fix a technical dept from #28663 where the Promtheus reveiver
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)
547
+
pos=k
548
+
549
+
fori, de:=rangeme.dataPointExpectations {
453
550
switchm.Type() {
454
551
casepmetric.MetricTypeGauge:
455
552
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)
553
+
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
554
npc(t, m.Gauge().DataPoints().At(i))
458
555
}
459
556
casepmetric.MetricTypeSum:
460
557
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)
558
+
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
559
npc(t, m.Sum().DataPoints().At(i))
463
560
}
464
561
casepmetric.MetricTypeHistogram:
465
562
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)
563
+
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
564
hpc(t, m.Histogram().DataPoints().At(i))
468
565
}
469
566
casepmetric.MetricTypeSummary:
470
567
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)
568
+
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)
573
+
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