From 2b1b3998bb740c75b2c410581abef997079b0ff5 Mon Sep 17 00:00:00 2001 From: David Ashpole Date: Fri, 18 Aug 2023 13:06:02 +0000 Subject: [PATCH] translate prometheus units from words to UCUM --- .chloggen/prometheus_translate_ucum.yaml | 27 ++++++ pkg/translator/prometheus/unit_to_ucum.go | 90 +++++++++++++++++++ .../prometheus/unit_to_ucum_test.go | 61 +++++++++++++ .../internal/metricfamily.go | 2 +- .../metrics_receiver_helper_test.go | 9 +- .../metrics_receiver_honor_timestamp_test.go | 20 +++++ .../metrics_receiver_labels_test.go | 18 ++++ ...ics_receiver_metric_name_normalize_test.go | 4 + .../metrics_receiver_non_numerical_test.go | 15 ++++ .../metrics_receiver_open_metrics_test.go | 2 + ...ceiver_report_extra_scrape_metrics_test.go | 2 + .../metrics_receiver_test.go | 44 +++++++++ .../metrics_reciever_metric_rename_test.go | 11 +++ 13 files changed, 303 insertions(+), 2 deletions(-) create mode 100644 .chloggen/prometheus_translate_ucum.yaml create mode 100644 pkg/translator/prometheus/unit_to_ucum.go create mode 100644 pkg/translator/prometheus/unit_to_ucum_test.go diff --git a/.chloggen/prometheus_translate_ucum.yaml b/.chloggen/prometheus_translate_ucum.yaml new file mode 100644 index 000000000000..f730be37c202 --- /dev/null +++ b/.chloggen/prometheus_translate_ucum.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: receiver/prometheus + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: translate units from prometheus to UCUM + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [23208] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [user, api] diff --git a/pkg/translator/prometheus/unit_to_ucum.go b/pkg/translator/prometheus/unit_to_ucum.go new file mode 100644 index 000000000000..b2f2c4f3aa2f --- /dev/null +++ b/pkg/translator/prometheus/unit_to_ucum.go @@ -0,0 +1,90 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package prometheus // import "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheus" + +import "strings" + +var wordToUCUM = map[string]string{ + + // Time + "days": "d", + "hours": "h", + "minutes": "min", + "seconds": "s", + "milliseconds": "ms", + "microseconds": "us", + "nanoseconds": "ns", + + // Bytes + "bytes": "By", + "kibibytes": "KiBy", + "mebibytes": "MiBy", + "gibibytes": "GiBy", + "tibibytes": "TiBy", + "kilobytes": "KBy", + "megabytes": "MBy", + "gigabytes": "GBy", + "terabytes": "TBy", + + // SI + "meters": "m", + "volts": "V", + "amperes": "A", + "joules": "J", + "watts": "W", + "grams": "g", + + // Misc + "celsius": "Cel", + "hertz": "Hz", + "ratio": "1", + "percent": "%", +} + +// The map that translates the "per" unit +// Example: per_second (singular) => /s +var perWordToUCUM = map[string]string{ + "second": "s", + "minute": "m", + "hour": "h", + "day": "d", + "week": "w", + "month": "mo", + "year": "y", +} + +// UnitWordToUCUM converts english unit words to UCUM units: +// https://ucum.org/ucum#section-Alphabetic-Index-By-Symbol +// It also handles rates, such as meters_per_second, by translating the first +// word to UCUM, and the "per" word to UCUM. It joins them with a "/" between. +func UnitWordToUCUM(unit string) string { + unitTokens := strings.SplitN(unit, "_per_", 2) + if len(unitTokens) == 0 { + return "" + } + ucumUnit := wordToUCUMOrDefault(unitTokens[0]) + if len(unitTokens) > 1 && unitTokens[1] != "" { + ucumUnit += "/" + perWordToUCUMOrDefault(unitTokens[1]) + } + return ucumUnit +} + +// wordToUCUMOrDefault retrieves the Prometheus "basic" unit corresponding to +// the specified "basic" unit. Returns the specified unit if not found in +// wordToUCUM. +func wordToUCUMOrDefault(unit string) string { + if promUnit, ok := wordToUCUM[unit]; ok { + return promUnit + } + return unit +} + +// perWordToUCUMOrDefault retrieve the Prometheus "per" unit corresponding to +// the specified "per" unit. Returns the specified unit if not found in perWordToUCUM. +func perWordToUCUMOrDefault(perUnit string) string { + if promPerUnit, ok := perWordToUCUM[perUnit]; ok { + return promPerUnit + } + return perUnit +} diff --git a/pkg/translator/prometheus/unit_to_ucum_test.go b/pkg/translator/prometheus/unit_to_ucum_test.go new file mode 100644 index 000000000000..518a2983a2fa --- /dev/null +++ b/pkg/translator/prometheus/unit_to_ucum_test.go @@ -0,0 +1,61 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package prometheus // import "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheus" + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestUnitWordToUCUM(t *testing.T) { + for _, tc := range []struct { + input string + expected string + }{ + { + input: "", + expected: "", + }, + { + input: "days", + expected: "d", + }, + { + input: "seconds", + expected: "s", + }, + { + input: "kibibytes", + expected: "KiBy", + }, + { + input: "volts", + expected: "V", + }, + { + input: "bananas_per_day", + expected: "bananas/d", + }, + { + input: "meters_per_hour", + expected: "m/h", + }, + { + input: "ratio", + expected: "1", + }, + { + input: "percent", + expected: "%", + }, + } { + t.Run(fmt.Sprintf("input: \"%v\"", tc.input), func(t *testing.T) { + got := UnitWordToUCUM(tc.input) + assert.Equal(t, tc.expected, got) + }) + } + +} diff --git a/receiver/prometheusreceiver/internal/metricfamily.go b/receiver/prometheusreceiver/internal/metricfamily.go index 85c764cb4413..18fa97f7618e 100644 --- a/receiver/prometheusreceiver/internal/metricfamily.go +++ b/receiver/prometheusreceiver/internal/metricfamily.go @@ -320,7 +320,7 @@ func (mf *metricFamily) appendMetric(metrics pmetric.MetricSlice, trimSuffixes b } metric.SetName(name) metric.SetDescription(mf.metadata.Help) - metric.SetUnit(mf.metadata.Unit) + metric.SetUnit(prometheus.UnitWordToUCUM(mf.metadata.Unit)) pointCount := 0 diff --git a/receiver/prometheusreceiver/metrics_receiver_helper_test.go b/receiver/prometheusreceiver/metrics_receiver_helper_test.go index 4cd6fa5a81e2..30646cedd4ac 100644 --- a/receiver/prometheusreceiver/metrics_receiver_helper_test.go +++ b/receiver/prometheusreceiver/metrics_receiver_helper_test.go @@ -378,7 +378,7 @@ func doCompareNormalized(t *testing.T, name string, want pcommon.Map, got pmetri }) } -func assertMetricPresent(name string, metricTypeExpectations metricTypeComparator, dataPointExpectations []dataPointExpectation) testExpectation { +func assertMetricPresent(name string, metricTypeExpectations metricTypeComparator, metricUnitExpectations metricTypeComparator, dataPointExpectations []dataPointExpectation) testExpectation { return func(t *testing.T, rm pmetric.ResourceMetrics) { allMetrics := getMetrics(rm) var present bool @@ -389,6 +389,7 @@ func assertMetricPresent(name string, metricTypeExpectations metricTypeComparato present = true metricTypeExpectations(t, m) + metricUnitExpectations(t, m) for i, de := range dataPointExpectations { switch m.Type() { case pmetric.MetricTypeGauge: @@ -434,6 +435,12 @@ func compareMetricType(typ pmetric.MetricType) metricTypeComparator { } } +func compareMetricUnit(unit string) metricTypeComparator { + return func(t *testing.T, metric pmetric.Metric) { + assert.Equal(t, unit, metric.Unit(), "Metric unit does not match") + } +} + func compareMetricIsMonotonic(isMonotonic bool) metricTypeComparator { return func(t *testing.T, metric pmetric.Metric) { assert.Equal(t, pmetric.MetricTypeSum.String(), metric.Type().String(), "IsMonotonic only exists for sums") diff --git a/receiver/prometheusreceiver/metrics_receiver_honor_timestamp_test.go b/receiver/prometheusreceiver/metrics_receiver_honor_timestamp_test.go index 951934d646dd..3ce6b001b28e 100644 --- a/receiver/prometheusreceiver/metrics_receiver_honor_timestamp_test.go +++ b/receiver/prometheusreceiver/metrics_receiver_honor_timestamp_test.go @@ -208,6 +208,7 @@ func verifyHonorTimeStampsTrue(t *testing.T, td *testData, resourceMetrics []pme e1 := []testExpectation{ assertMetricPresent("go_threads", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -218,6 +219,7 @@ func verifyHonorTimeStampsTrue(t *testing.T, td *testData, resourceMetrics []pme }), assertMetricPresent("http_requests_total", compareMetricType(pmetric.MetricTypeSum), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -238,6 +240,7 @@ func verifyHonorTimeStampsTrue(t *testing.T, td *testData, resourceMetrics []pme }), assertMetricPresent("http_request_duration_seconds", compareMetricType(pmetric.MetricTypeHistogram), + compareMetricUnit(""), []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ @@ -249,6 +252,7 @@ func verifyHonorTimeStampsTrue(t *testing.T, td *testData, resourceMetrics []pme }), assertMetricPresent("rpc_duration_seconds", compareMetricType(pmetric.MetricTypeSummary), + compareMetricUnit(""), []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ @@ -268,6 +272,7 @@ func verifyHonorTimeStampsTrue(t *testing.T, td *testData, resourceMetrics []pme e2 := []testExpectation{ assertMetricPresent("go_threads", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -278,6 +283,7 @@ func verifyHonorTimeStampsTrue(t *testing.T, td *testData, resourceMetrics []pme }), assertMetricPresent("http_requests_total", compareMetricType(pmetric.MetricTypeSum), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -298,6 +304,7 @@ func verifyHonorTimeStampsTrue(t *testing.T, td *testData, resourceMetrics []pme }), assertMetricPresent("http_request_duration_seconds", compareMetricType(pmetric.MetricTypeHistogram), + compareMetricUnit(""), []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ @@ -309,6 +316,7 @@ func verifyHonorTimeStampsTrue(t *testing.T, td *testData, resourceMetrics []pme }), assertMetricPresent("rpc_duration_seconds", compareMetricType(pmetric.MetricTypeSummary), + compareMetricUnit(""), []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ @@ -328,6 +336,7 @@ func verifyHonorTimeStampsTrue(t *testing.T, td *testData, resourceMetrics []pme e3 := []testExpectation{ assertMetricPresent("go_threads", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -338,6 +347,7 @@ func verifyHonorTimeStampsTrue(t *testing.T, td *testData, resourceMetrics []pme }), assertMetricPresent("http_requests_total", compareMetricType(pmetric.MetricTypeSum), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -358,6 +368,7 @@ func verifyHonorTimeStampsTrue(t *testing.T, td *testData, resourceMetrics []pme }), assertMetricPresent("http_request_duration_seconds", compareMetricType(pmetric.MetricTypeHistogram), + compareMetricUnit(""), []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ @@ -369,6 +380,7 @@ func verifyHonorTimeStampsTrue(t *testing.T, td *testData, resourceMetrics []pme }), assertMetricPresent("rpc_duration_seconds", compareMetricType(pmetric.MetricTypeSummary), + compareMetricUnit(""), []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ @@ -396,6 +408,7 @@ func verifyHonorTimeStampsFalse(t *testing.T, td *testData, resourceMetrics []pm e1 := []testExpectation{ assertMetricPresent("go_threads", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -406,6 +419,7 @@ func verifyHonorTimeStampsFalse(t *testing.T, td *testData, resourceMetrics []pm }), assertMetricPresent("http_requests_total", compareMetricType(pmetric.MetricTypeSum), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -426,6 +440,7 @@ func verifyHonorTimeStampsFalse(t *testing.T, td *testData, resourceMetrics []pm }), assertMetricPresent("http_request_duration_seconds", compareMetricType(pmetric.MetricTypeHistogram), + compareMetricUnit(""), []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ @@ -437,6 +452,7 @@ func verifyHonorTimeStampsFalse(t *testing.T, td *testData, resourceMetrics []pm }), assertMetricPresent("rpc_duration_seconds", compareMetricType(pmetric.MetricTypeSummary), + compareMetricUnit(""), []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ @@ -458,6 +474,7 @@ func verifyHonorTimeStampsFalse(t *testing.T, td *testData, resourceMetrics []pm e2 := []testExpectation{ assertMetricPresent("go_threads", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -468,6 +485,7 @@ func verifyHonorTimeStampsFalse(t *testing.T, td *testData, resourceMetrics []pm }), assertMetricPresent("http_requests_total", compareMetricType(pmetric.MetricTypeSum), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -488,6 +506,7 @@ func verifyHonorTimeStampsFalse(t *testing.T, td *testData, resourceMetrics []pm }), assertMetricPresent("http_request_duration_seconds", compareMetricType(pmetric.MetricTypeHistogram), + compareMetricUnit(""), []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ @@ -499,6 +518,7 @@ func verifyHonorTimeStampsFalse(t *testing.T, td *testData, resourceMetrics []pm }), assertMetricPresent("rpc_duration_seconds", compareMetricType(pmetric.MetricTypeSummary), + compareMetricUnit(""), []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ diff --git a/receiver/prometheusreceiver/metrics_receiver_labels_test.go b/receiver/prometheusreceiver/metrics_receiver_labels_test.go index 73ee1ae69628..6adfef5c1a4a 100644 --- a/receiver/prometheusreceiver/metrics_receiver_labels_test.go +++ b/receiver/prometheusreceiver/metrics_receiver_labels_test.go @@ -44,6 +44,7 @@ func verifyExternalLabels(t *testing.T, td *testData, rms []pmetric.ResourceMetr doCompare(t, "scrape-externalLabels", wantAttributes, rms[0], []testExpectation{ assertMetricPresent("go_threads", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -74,6 +75,7 @@ func verifyLabelLimitTarget1(t *testing.T, td *testData, rms []pmetric.ResourceM doCompare(t, "scrape-labelLimit", want, rms[0], []testExpectation{ assertMetricPresent("test_gauge0", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -165,6 +167,7 @@ func verifyLabelConfigTarget1(t *testing.T, td *testData, rms []pmetric.Resource e1 := []testExpectation{ assertMetricPresent("test_counter0", compareMetricType(pmetric.MetricTypeSum), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -177,6 +180,7 @@ func verifyLabelConfigTarget1(t *testing.T, td *testData, rms []pmetric.Resource }), assertMetricPresent("test_gauge0", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -188,6 +192,7 @@ func verifyLabelConfigTarget1(t *testing.T, td *testData, rms []pmetric.Resource }), assertMetricPresent("test_histogram0", compareMetricType(pmetric.MetricTypeHistogram), + compareMetricUnit(""), []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ @@ -200,6 +205,7 @@ func verifyLabelConfigTarget1(t *testing.T, td *testData, rms []pmetric.Resource }), assertMetricPresent("test_summary0", compareMetricType(pmetric.MetricTypeSummary), + compareMetricUnit(""), []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ @@ -324,6 +330,7 @@ func verifyEmptyLabelValuesTarget1(t *testing.T, td *testData, rms []pmetric.Res e1 := []testExpectation{ assertMetricPresent("test_gauge0", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -335,6 +342,7 @@ func verifyEmptyLabelValuesTarget1(t *testing.T, td *testData, rms []pmetric.Res }), assertMetricPresent("test_counter0", compareMetricType(pmetric.MetricTypeSum), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -346,6 +354,7 @@ func verifyEmptyLabelValuesTarget1(t *testing.T, td *testData, rms []pmetric.Res }), assertMetricPresent("test_histogram0", compareMetricType(pmetric.MetricTypeHistogram), + compareMetricUnit(""), []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ @@ -358,6 +367,7 @@ func verifyEmptyLabelValuesTarget1(t *testing.T, td *testData, rms []pmetric.Res }), assertMetricPresent("test_summary0", compareMetricType(pmetric.MetricTypeSummary), + compareMetricUnit(""), []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ @@ -395,6 +405,7 @@ func verifyEmptyLabelValuesTarget2(t *testing.T, td *testData, rms []pmetric.Res e1 := []testExpectation{ assertMetricPresent("test_gauge0", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -413,6 +424,7 @@ func verifyEmptyLabelValuesTarget2(t *testing.T, td *testData, rms []pmetric.Res }), assertMetricPresent("test_counter0", compareMetricType(pmetric.MetricTypeSum), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -469,6 +481,7 @@ func verifyHonorLabelsFalse(t *testing.T, td *testData, rms []pmetric.ResourceMe doCompare(t, "honor_labels_false", want, rms[0], []testExpectation{ assertMetricPresent("test_gauge0", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -504,6 +517,7 @@ func verifyEmptyLabelsTarget1(t *testing.T, td *testData, rms []pmetric.Resource assertMetricPresent( "test_gauge0", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -517,6 +531,7 @@ func verifyEmptyLabelsTarget1(t *testing.T, td *testData, rms []pmetric.Resource assertMetricPresent( "test_counter0", compareMetricType(pmetric.MetricTypeSum), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -574,6 +589,7 @@ func verifyHonorLabelsTrue(t *testing.T, td *testData, rms []pmetric.ResourceMet doCompare(t, "honor_labels_true", expectedAttributes, rms[0], []testExpectation{ assertMetricPresent("test_gauge0", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -660,6 +676,7 @@ func verifyRelabelJobInstance(t *testing.T, td *testData, rms []pmetric.Resource doCompare(t, "relabel-job-instance", wantAttributes, rms[0], []testExpectation{ assertMetricPresent("jvm_memory_bytes_used", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -708,6 +725,7 @@ func verifyTargetInfoResourceAttributes(t *testing.T, td *testData, rms []pmetri doCompare(t, "relabel-job-instance", wantAttributes, rms[0], []testExpectation{ assertMetricPresent("jvm_memory_bytes_used", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ diff --git a/receiver/prometheusreceiver/metrics_receiver_metric_name_normalize_test.go b/receiver/prometheusreceiver/metrics_receiver_metric_name_normalize_test.go index 9cb4274d7650..5ac7682f1b7a 100644 --- a/receiver/prometheusreceiver/metrics_receiver_metric_name_normalize_test.go +++ b/receiver/prometheusreceiver/metrics_receiver_metric_name_normalize_test.go @@ -61,6 +61,7 @@ func verifyNormalizeMetric(t *testing.T, td *testData, resourceMetrics []pmetric e1 := []testExpectation{ assertMetricPresent("http_connected", compareMetricType(pmetric.MetricTypeSum), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -79,6 +80,7 @@ func verifyNormalizeMetric(t *testing.T, td *testData, resourceMetrics []pmetric }), assertMetricPresent("foo_gauge_total", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -97,6 +99,7 @@ func verifyNormalizeMetric(t *testing.T, td *testData, resourceMetrics []pmetric }), assertMetricPresent("http_connection_duration", compareMetricType(pmetric.MetricTypeSum), + compareMetricUnit("s"), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -115,6 +118,7 @@ func verifyNormalizeMetric(t *testing.T, td *testData, resourceMetrics []pmetric }), assertMetricPresent("foo_gauge", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit("s"), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ diff --git a/receiver/prometheusreceiver/metrics_receiver_non_numerical_test.go b/receiver/prometheusreceiver/metrics_receiver_non_numerical_test.go index 926760237f78..05107737acb9 100644 --- a/receiver/prometheusreceiver/metrics_receiver_non_numerical_test.go +++ b/receiver/prometheusreceiver/metrics_receiver_non_numerical_test.go @@ -95,6 +95,7 @@ func verifyStaleNaNsSuccessfulScrape(t *testing.T, td *testData, resourceMetric e1 := []testExpectation{ assertMetricPresent("go_threads", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -105,6 +106,7 @@ func verifyStaleNaNsSuccessfulScrape(t *testing.T, td *testData, resourceMetric }), assertMetricPresent("http_requests_total", compareMetricType(pmetric.MetricTypeSum), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -125,6 +127,7 @@ func verifyStaleNaNsSuccessfulScrape(t *testing.T, td *testData, resourceMetric }), assertMetricPresent("http_request_duration_seconds", compareMetricType(pmetric.MetricTypeHistogram), + compareMetricUnit(""), []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ @@ -136,6 +139,7 @@ func verifyStaleNaNsSuccessfulScrape(t *testing.T, td *testData, resourceMetric }), assertMetricPresent("rpc_duration_seconds", compareMetricType(pmetric.MetricTypeSummary), + compareMetricUnit(""), []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ @@ -161,6 +165,7 @@ func verifyStaleNaNsFailedScrape(t *testing.T, td *testData, resourceMetric pmet e1 := []testExpectation{ assertMetricPresent("go_threads", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -171,6 +176,7 @@ func verifyStaleNaNsFailedScrape(t *testing.T, td *testData, resourceMetric pmet }), assertMetricPresent("http_requests_total", compareMetricType(pmetric.MetricTypeSum), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -189,6 +195,7 @@ func verifyStaleNaNsFailedScrape(t *testing.T, td *testData, resourceMetric pmet }), assertMetricPresent("http_request_duration_seconds", compareMetricType(pmetric.MetricTypeHistogram), + compareMetricUnit(""), []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ @@ -200,6 +207,7 @@ func verifyStaleNaNsFailedScrape(t *testing.T, td *testData, resourceMetric pmet }), assertMetricPresent("rpc_duration_seconds", compareMetricType(pmetric.MetricTypeSummary), + compareMetricUnit(""), []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ @@ -261,6 +269,7 @@ func verifyNormalNaNs(t *testing.T, td *testData, resourceMetrics []pmetric.Reso e1 := []testExpectation{ assertMetricPresent("go_threads", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -271,6 +280,7 @@ func verifyNormalNaNs(t *testing.T, td *testData, resourceMetrics []pmetric.Reso }), assertMetricPresent("redis_connected_clients", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -282,6 +292,7 @@ func verifyNormalNaNs(t *testing.T, td *testData, resourceMetrics []pmetric.Reso }), assertMetricPresent("rpc_duration_seconds", compareMetricType(pmetric.MetricTypeSummary), + compareMetricUnit(""), []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ @@ -345,6 +356,7 @@ func verifyInfValues(t *testing.T, td *testData, resourceMetrics []pmetric.Resou e1 := []testExpectation{ assertMetricPresent("go_threads", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -355,6 +367,7 @@ func verifyInfValues(t *testing.T, td *testData, resourceMetrics []pmetric.Resou }), assertMetricPresent("redis_connected_clients", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -366,6 +379,7 @@ func verifyInfValues(t *testing.T, td *testData, resourceMetrics []pmetric.Resou }), assertMetricPresent("http_requests_total", compareMetricType(pmetric.MetricTypeSum), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -378,6 +392,7 @@ func verifyInfValues(t *testing.T, td *testData, resourceMetrics []pmetric.Resou }), assertMetricPresent("rpc_duration_seconds", compareMetricType(pmetric.MetricTypeSummary), + compareMetricUnit(""), []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ diff --git a/receiver/prometheusreceiver/metrics_receiver_open_metrics_test.go b/receiver/prometheusreceiver/metrics_receiver_open_metrics_test.go index 71c738fed4de..3ab80d737ed7 100644 --- a/receiver/prometheusreceiver/metrics_receiver_open_metrics_test.go +++ b/receiver/prometheusreceiver/metrics_receiver_open_metrics_test.go @@ -246,6 +246,7 @@ func verifyInfoStatesetMetrics(t *testing.T, td *testData, resourceMetrics []pme e1 := []testExpectation{ assertMetricPresent("foo", compareMetricIsMonotonic(false), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -264,6 +265,7 @@ func verifyInfoStatesetMetrics(t *testing.T, td *testData, resourceMetrics []pme }), assertMetricPresent("bar", compareMetricIsMonotonic(false), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ diff --git a/receiver/prometheusreceiver/metrics_receiver_report_extra_scrape_metrics_test.go b/receiver/prometheusreceiver/metrics_receiver_report_extra_scrape_metrics_test.go index 67b85b823936..84121f130184 100644 --- a/receiver/prometheusreceiver/metrics_receiver_report_extra_scrape_metrics_test.go +++ b/receiver/prometheusreceiver/metrics_receiver_report_extra_scrape_metrics_test.go @@ -119,6 +119,7 @@ func verifyMetrics(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc e1 := []testExpectation{ assertMetricPresent("http_connected_total", compareMetricType(pmetric.MetricTypeSum), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -137,6 +138,7 @@ func verifyMetrics(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }), assertMetricPresent("foo_gauge_total", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ diff --git a/receiver/prometheusreceiver/metrics_receiver_test.go b/receiver/prometheusreceiver/metrics_receiver_test.go index ff000eef3249..acfc6f8a4f83 100644 --- a/receiver/prometheusreceiver/metrics_receiver_test.go +++ b/receiver/prometheusreceiver/metrics_receiver_test.go @@ -129,6 +129,7 @@ func verifyTarget1(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc e1 := []testExpectation{ assertMetricPresent("go_threads", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -139,6 +140,7 @@ func verifyTarget1(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }), assertMetricPresent("http_requests_total", compareMetricType(pmetric.MetricTypeSum), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -159,6 +161,7 @@ func verifyTarget1(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }), assertMetricPresent("http_request_duration_seconds", compareMetricType(pmetric.MetricTypeHistogram), + compareMetricUnit(""), []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ @@ -170,6 +173,7 @@ func verifyTarget1(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }), assertMetricPresent("rpc_duration_seconds", compareMetricType(pmetric.MetricTypeSummary), + compareMetricUnit(""), []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ @@ -191,6 +195,7 @@ func verifyTarget1(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc e2 := []testExpectation{ assertMetricPresent("go_threads", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -201,6 +206,7 @@ func verifyTarget1(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }), assertMetricPresent("http_requests_total", compareMetricType(pmetric.MetricTypeSum), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -221,6 +227,7 @@ func verifyTarget1(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }), assertMetricPresent("http_request_duration_seconds", compareMetricType(pmetric.MetricTypeHistogram), + compareMetricUnit(""), []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ @@ -233,6 +240,7 @@ func verifyTarget1(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }), assertMetricPresent("rpc_duration_seconds", compareMetricType(pmetric.MetricTypeSummary), + compareMetricUnit(""), []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ @@ -254,6 +262,7 @@ func verifyTarget1(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc e3 := []testExpectation{ assertMetricPresent("go_threads", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -264,6 +273,7 @@ func verifyTarget1(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }), assertMetricPresent("http_requests_total", compareMetricType(pmetric.MetricTypeSum), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -286,6 +296,7 @@ func verifyTarget1(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }), assertMetricPresent("http_request_duration_seconds", compareMetricType(pmetric.MetricTypeHistogram), + compareMetricUnit(""), []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ @@ -298,6 +309,7 @@ func verifyTarget1(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }), assertMetricPresent("rpc_duration_seconds", compareMetricType(pmetric.MetricTypeSummary), + compareMetricUnit(""), []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ @@ -515,6 +527,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc e1 := []testExpectation{ assertMetricPresent("go_threads", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -525,6 +538,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }), assertMetricPresent("http_request_duration_seconds", compareMetricType(pmetric.MetricTypeHistogram), + compareMetricUnit(""), []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ @@ -545,6 +559,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }), assertMetricPresent("http_requests_total", compareMetricType(pmetric.MetricTypeSum), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -565,6 +580,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }), assertMetricPresent("rpc_duration_seconds", compareMetricType(pmetric.MetricTypeSummary), + compareMetricUnit(""), []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ @@ -595,6 +611,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc e2 := []testExpectation{ assertMetricPresent("go_threads", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -605,6 +622,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }), assertMetricPresent("http_request_duration_seconds", compareMetricType(pmetric.MetricTypeHistogram), + compareMetricUnit(""), []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ @@ -633,6 +651,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }), assertMetricPresent("http_requests_total", compareMetricType(pmetric.MetricTypeSum), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -661,6 +680,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }), assertMetricPresent("rpc_duration_seconds", compareMetricType(pmetric.MetricTypeSummary), + compareMetricUnit(""), []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ @@ -699,6 +719,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc e3 := []testExpectation{ assertMetricPresent("go_threads", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -709,6 +730,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }), assertMetricPresent("http_request_duration_seconds", compareMetricType(pmetric.MetricTypeHistogram), + compareMetricUnit(""), []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ @@ -737,6 +759,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }), assertMetricPresent("http_requests_total", compareMetricType(pmetric.MetricTypeSum), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -765,6 +788,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }), assertMetricPresent("rpc_duration_seconds", compareMetricType(pmetric.MetricTypeSummary), + compareMetricUnit(""), []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ @@ -803,6 +827,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc e4 := []testExpectation{ assertMetricPresent("go_threads", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -813,6 +838,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }), assertMetricPresent("http_request_duration_seconds", compareMetricType(pmetric.MetricTypeHistogram), + compareMetricUnit(""), []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ @@ -841,6 +867,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }), assertMetricPresent("http_requests_total", compareMetricType(pmetric.MetricTypeSum), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -869,6 +896,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }), assertMetricPresent("rpc_duration_seconds", compareMetricType(pmetric.MetricTypeSummary), + compareMetricUnit(""), []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ @@ -907,6 +935,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc e5 := []testExpectation{ assertMetricPresent("go_threads", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -917,6 +946,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }), assertMetricPresent("http_request_duration_seconds", compareMetricType(pmetric.MetricTypeHistogram), + compareMetricUnit(""), []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ @@ -945,6 +975,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }), assertMetricPresent("http_requests_total", compareMetricType(pmetric.MetricTypeSum), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -973,6 +1004,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }), assertMetricPresent("rpc_duration_seconds", compareMetricType(pmetric.MetricTypeSummary), + compareMetricUnit(""), []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ @@ -1097,6 +1129,7 @@ func verifyTarget3(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc e1 := []testExpectation{ assertMetricPresent("go_threads", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -1107,6 +1140,7 @@ func verifyTarget3(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }), assertMetricPresent("http_request_duration_seconds", compareMetricType(pmetric.MetricTypeHistogram), + compareMetricUnit(""), []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ @@ -1118,6 +1152,7 @@ func verifyTarget3(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }), assertMetricPresent("corrupted_hist", compareMetricType(pmetric.MetricTypeHistogram), + compareMetricUnit(""), []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ @@ -1129,6 +1164,7 @@ func verifyTarget3(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }), assertMetricPresent("rpc_duration_seconds", compareMetricType(pmetric.MetricTypeSummary), + compareMetricUnit(""), []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ @@ -1159,6 +1195,7 @@ func verifyTarget3(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc e2 := []testExpectation{ assertMetricPresent("go_threads", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -1169,6 +1206,7 @@ func verifyTarget3(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }), assertMetricPresent("http_request_duration_seconds", compareMetricType(pmetric.MetricTypeHistogram), + compareMetricUnit(""), []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ @@ -1180,6 +1218,7 @@ func verifyTarget3(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }), assertMetricPresent("corrupted_hist", compareMetricType(pmetric.MetricTypeHistogram), + compareMetricUnit(""), []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ @@ -1191,6 +1230,7 @@ func verifyTarget3(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }), assertMetricPresent("rpc_duration_seconds", compareMetricType(pmetric.MetricTypeSummary), + compareMetricUnit(""), []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ @@ -1227,6 +1267,7 @@ func verifyTarget4(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc e1 := []testExpectation{ assertMetricPresent("foo", compareMetricIsMonotonic(true), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -1237,6 +1278,7 @@ func verifyTarget4(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }), assertMetricPresent("foo_total", compareMetricIsMonotonic(true), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -1476,6 +1518,7 @@ func verifyUntypedMetrics(t *testing.T, td *testData, resourceMetrics []pmetric. e1 := []testExpectation{ assertMetricPresent("http_requests_total", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -1494,6 +1537,7 @@ func verifyUntypedMetrics(t *testing.T, td *testData, resourceMetrics []pmetric. }), assertMetricPresent("redis_connected_clients", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ diff --git a/receiver/prometheusreceiver/metrics_reciever_metric_rename_test.go b/receiver/prometheusreceiver/metrics_reciever_metric_rename_test.go index 70c945cba4ab..70abdd2eba09 100644 --- a/receiver/prometheusreceiver/metrics_reciever_metric_rename_test.go +++ b/receiver/prometheusreceiver/metrics_reciever_metric_rename_test.go @@ -120,6 +120,7 @@ func verifyRenameMetric(t *testing.T, td *testData, resourceMetrics []pmetric.Re e1 := []testExpectation{ assertMetricPresent("foo", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -139,6 +140,7 @@ func verifyRenameMetric(t *testing.T, td *testData, resourceMetrics []pmetric.Re // renaming config converts any metric type to untyped metric, which then gets converted to gauge double type by metric builder assertMetricPresent("http_requests_total", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -174,6 +176,7 @@ func verifyRenameMetricKeepAction(t *testing.T, td *testData, resourceMetrics [] e1 := []testExpectation{ assertMetricPresent("rpc_duration_total", compareMetricType(pmetric.MetricTypeSum), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -281,6 +284,7 @@ func verifyRenameLabel(t *testing.T, td *testData, resourceMetrics []pmetric.Res e1 := []testExpectation{ assertMetricPresent("http_go_threads", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -292,6 +296,7 @@ func verifyRenameLabel(t *testing.T, td *testData, resourceMetrics []pmetric.Res }), assertMetricPresent("http_connected_total", compareMetricType(pmetric.MetricTypeSum), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -303,6 +308,7 @@ func verifyRenameLabel(t *testing.T, td *testData, resourceMetrics []pmetric.Res }), assertMetricPresent("redis_http_requests_total", compareMetricType(pmetric.MetricTypeSum), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -323,6 +329,7 @@ func verifyRenameLabel(t *testing.T, td *testData, resourceMetrics []pmetric.Res }), assertMetricPresent("rpc_duration_total", compareMetricType(pmetric.MetricTypeSum), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -384,6 +391,7 @@ func verifyRenameLabelKeepAction(t *testing.T, td *testData, resourceMetrics []p e1 := []testExpectation{ assertMetricPresent("http_go_threads", compareMetricType(pmetric.MetricTypeGauge), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -395,6 +403,7 @@ func verifyRenameLabelKeepAction(t *testing.T, td *testData, resourceMetrics []p }), assertMetricPresent("http_connected_total", compareMetricType(pmetric.MetricTypeSum), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -406,6 +415,7 @@ func verifyRenameLabelKeepAction(t *testing.T, td *testData, resourceMetrics []p }), assertMetricPresent("redis_http_requests_total", compareMetricType(pmetric.MetricTypeSum), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ @@ -424,6 +434,7 @@ func verifyRenameLabelKeepAction(t *testing.T, td *testData, resourceMetrics []p }), assertMetricPresent("rpc_duration_total", compareMetricType(pmetric.MetricTypeSum), + compareMetricUnit(""), []dataPointExpectation{ { numberPointComparator: []numberPointComparator{