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
refactor(receiver/prometheusreceiver): use type and unit as identifier in test
I'd like to fix a technical dept from open-telemetry#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
not expected - excluding the 5 scrape metrics.
Signed-off-by: György Krajcsovits <[email protected]>
require.Equal(t, -1, pos, "metric %s is not unique", id)
502
+
pos=k
503
+
504
+
fori, de:=rangeme.dataPointExpectations {
453
505
switchm.Type() {
454
506
casepmetric.MetricTypeGauge:
455
507
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)
508
+
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
509
npc(t, m.Gauge().DataPoints().At(i))
458
510
}
459
511
casepmetric.MetricTypeSum:
460
512
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)
513
+
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
514
npc(t, m.Sum().DataPoints().At(i))
463
515
}
464
516
casepmetric.MetricTypeHistogram:
465
517
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)
518
+
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
519
hpc(t, m.Histogram().DataPoints().At(i))
468
520
}
469
521
casepmetric.MetricTypeSummary:
470
522
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)
523
+
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)
528
+
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)
assert.Equal(t, unit, metric.Unit(), "Metric unit does not match")
562
+
present=true
563
+
fori, de:=rangedataPointExpectations {
564
+
switchm.Type() {
565
+
casepmetric.MetricTypeGauge:
566
+
for_, npc:=rangede.numberPointComparator {
567
+
require.Len(t, dataPointExpectations, m.Gauge().DataPoints().Len(), "Expected number of data-points in Gauge metric '%s' does not match to testdata", id)
568
+
npc(t, m.Gauge().DataPoints().At(i))
569
+
}
570
+
casepmetric.MetricTypeSum:
571
+
for_, npc:=rangede.numberPointComparator {
572
+
require.Len(t, dataPointExpectations, m.Sum().DataPoints().Len(), "Expected number of data-points in Sum metric '%s' does not match to testdata", id)
573
+
npc(t, m.Sum().DataPoints().At(i))
574
+
}
575
+
casepmetric.MetricTypeHistogram:
576
+
for_, hpc:=rangede.histogramPointComparator {
577
+
require.Len(t, dataPointExpectations, m.Histogram().DataPoints().Len(), "Expected number of data-points in Histogram metric '%s' does not match to testdata", id)
578
+
hpc(t, m.Histogram().DataPoints().At(i))
579
+
}
580
+
casepmetric.MetricTypeSummary:
581
+
for_, spc:=rangede.summaryPointComparator {
582
+
require.Len(t, 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", id)
0 commit comments