From 8b736e4bca1edbcb4a24de431bf70c94fae26302 Mon Sep 17 00:00:00 2001 From: Mackenzie <63265430+mackjmr@users.noreply.github.com> Date: Tue, 12 Dec 2023 14:25:11 +0100 Subject: [PATCH] Remove ResourceAttributesAsTags (#219) * remove unused ResourceAttributesAsTags * changelog * make fmt --- .../mackjmr_remove-unused-rattr-as-tags.yaml | 16 ++++++++++++++ pkg/otlp/metrics/config.go | 22 +++++-------------- pkg/otlp/metrics/histograms_test.go | 15 +++++-------- pkg/otlp/metrics/metrics_translator.go | 1 - pkg/otlp/metrics/mixed_metrics_test.go | 15 +++++-------- 5 files changed, 31 insertions(+), 38 deletions(-) create mode 100755 .chloggen/mackjmr_remove-unused-rattr-as-tags.yaml diff --git a/.chloggen/mackjmr_remove-unused-rattr-as-tags.yaml b/.chloggen/mackjmr_remove-unused-rattr-as-tags.yaml new file mode 100755 index 00000000..e9aa8317 --- /dev/null +++ b/.chloggen/mackjmr_remove-unused-rattr-as-tags.yaml @@ -0,0 +1,16 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: breaking + +# The name of the component (e.g. pkg/quantile) +component: pkg/metrics + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Remove `WithResourceAttributesAsTags()` and `translatorConfig.ResourceAttributesAsTags` + +# The PR related to this change +issues: [219] + +# (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: diff --git a/pkg/otlp/metrics/config.go b/pkg/otlp/metrics/config.go index 94f99913..f5c9dd1b 100644 --- a/pkg/otlp/metrics/config.go +++ b/pkg/otlp/metrics/config.go @@ -22,15 +22,11 @@ import ( type translatorConfig struct { // metrics export behavior - HistMode HistogramMode - SendHistogramAggregations bool - Quantiles bool - NumberMode NumberMode - InitialCumulMonoValueMode InitialCumulMonoValueMode - ResourceAttributesAsTags bool - // Deprecated: use InstrumentationScopeMetadataAsTags instead in favor of - // https://github.com/open-telemetry/opentelemetry-proto/releases/tag/v0.15.0 - // Both must not be enabled at the same time. + HistMode HistogramMode + SendHistogramAggregations bool + Quantiles bool + NumberMode NumberMode + InitialCumulMonoValueMode InitialCumulMonoValueMode InstrumentationLibraryMetadataAsTags bool InstrumentationScopeMetadataAsTags bool @@ -95,14 +91,6 @@ func WithQuantiles() TranslatorOption { } } -// WithResourceAttributesAsTags sets resource attributes as tags. -func WithResourceAttributesAsTags() TranslatorOption { - return func(t *translatorConfig) error { - t.ResourceAttributesAsTags = true - return nil - } -} - // WithInstrumentationLibraryMetadataAsTags sets instrumentation library metadata as tags. func WithInstrumentationLibraryMetadataAsTags() TranslatorOption { return func(t *translatorConfig) error { diff --git a/pkg/otlp/metrics/histograms_test.go b/pkg/otlp/metrics/histograms_test.go index 9d3135d9..5e17fd65 100644 --- a/pkg/otlp/metrics/histograms_test.go +++ b/pkg/otlp/metrics/histograms_test.go @@ -188,13 +188,11 @@ func TestExponentialHistogramTranslatorOptions(t *testing.T) { expectedUnsupportedAggregationTemporality: 1, }, { - name: "resource-attributes-as-tags", - otlpfile: "testdata/otlpdata/histogram/simple-exponential.json", - ddogfile: "testdata/datadogdata/histogram/simple-exponential_res-tags.json", - options: []TranslatorOption{ - WithResourceAttributesAsTags(), - }, - expectedUnknownMetricType: 1, + name: "resource-attributes-as-tags", + otlpfile: "testdata/otlpdata/histogram/simple-exponential.json", + ddogfile: "testdata/datadogdata/histogram/simple-exponential_res-tags.json", + options: []TranslatorOption{}, + expectedUnknownMetricType: 1, expectedUnsupportedAggregationTemporality: 1, }, { @@ -243,7 +241,6 @@ func TestExponentialHistogramTranslatorOptions(t *testing.T) { otlpfile: "testdata/otlpdata/histogram/simple-exponential.json", ddogfile: "testdata/datadogdata/histogram/simple-exponential_res-ilmd-tags.json", options: []TranslatorOption{ - WithResourceAttributesAsTags(), WithInstrumentationLibraryMetadataAsTags(), }, expectedUnknownMetricType: 1, @@ -255,7 +252,6 @@ func TestExponentialHistogramTranslatorOptions(t *testing.T) { ddogfile: "testdata/datadogdata/histogram/simple-exponential_cs-both-tags.json", options: []TranslatorOption{ WithHistogramAggregations(), - WithResourceAttributesAsTags(), WithInstrumentationLibraryMetadataAsTags(), }, expectedUnknownMetricType: 1, @@ -267,7 +263,6 @@ func TestExponentialHistogramTranslatorOptions(t *testing.T) { ddogfile: "testdata/datadogdata/histogram/simple-exponential_all.json", options: []TranslatorOption{ WithHistogramAggregations(), - WithResourceAttributesAsTags(), WithInstrumentationLibraryMetadataAsTags(), WithInstrumentationScopeMetadataAsTags(), }, diff --git a/pkg/otlp/metrics/metrics_translator.go b/pkg/otlp/metrics/metrics_translator.go index adccf345..0e702762 100644 --- a/pkg/otlp/metrics/metrics_translator.go +++ b/pkg/otlp/metrics/metrics_translator.go @@ -70,7 +70,6 @@ func NewTranslator(set component.TelemetrySettings, options ...TranslatorOption) Quantiles: false, NumberMode: NumberModeCumulativeToDelta, InitialCumulMonoValueMode: InitialCumulMonoValueModeAuto, - ResourceAttributesAsTags: false, InstrumentationLibraryMetadataAsTags: false, sweepInterval: 1800, deltaTTL: 3600, diff --git a/pkg/otlp/metrics/mixed_metrics_test.go b/pkg/otlp/metrics/mixed_metrics_test.go index 48c4f960..669b6ad1 100644 --- a/pkg/otlp/metrics/mixed_metrics_test.go +++ b/pkg/otlp/metrics/mixed_metrics_test.go @@ -33,13 +33,11 @@ func TestMapMetrics(t *testing.T) { expectedUnsupportedAggregationTemporality: 2, }, { - name: "resource-attributes-as-tags", - otlpfile: "testdata/otlpdata/mixed/simple.json", - ddogfile: "testdata/datadogdata/mixed/simple_res-tags.json", - options: []TranslatorOption{ - WithResourceAttributesAsTags(), - }, - expectedUnknownMetricType: 1, + name: "resource-attributes-as-tags", + otlpfile: "testdata/otlpdata/mixed/simple.json", + ddogfile: "testdata/datadogdata/mixed/simple_res-tags.json", + options: []TranslatorOption{}, + expectedUnknownMetricType: 1, expectedUnsupportedAggregationTemporality: 2, }, { @@ -88,7 +86,6 @@ func TestMapMetrics(t *testing.T) { otlpfile: "testdata/otlpdata/mixed/simple.json", ddogfile: "testdata/datadogdata/mixed/simple_res-ilmd-tags.json", options: []TranslatorOption{ - WithResourceAttributesAsTags(), WithInstrumentationLibraryMetadataAsTags(), }, expectedUnknownMetricType: 1, @@ -100,7 +97,6 @@ func TestMapMetrics(t *testing.T) { ddogfile: "testdata/datadogdata/mixed/simple_cs-both-tags.json", options: []TranslatorOption{ WithHistogramAggregations(), - WithResourceAttributesAsTags(), WithInstrumentationLibraryMetadataAsTags(), }, expectedUnknownMetricType: 1, @@ -112,7 +108,6 @@ func TestMapMetrics(t *testing.T) { ddogfile: "testdata/datadogdata/mixed/simple_all.json", options: []TranslatorOption{ WithHistogramAggregations(), - WithResourceAttributesAsTags(), WithInstrumentationLibraryMetadataAsTags(), WithInstrumentationScopeMetadataAsTags(), },