From f5804e7cf2542486747db98c51155f554aec5bd9 Mon Sep 17 00:00:00 2001 From: Arve Knudsen Date: Thu, 16 Oct 2025 16:26:41 +0200 Subject: [PATCH] Remove configuration parameters Signed-off-by: Arve Knudsen --- config/config.go | 12 +---- config/config_test.go | 46 +------------------ ..._underscore_sanitization_defaults.good.yml | 2 - ..._underscore_sanitization_disabled.good.yml | 3 -- ...l_underscore_sanitization_enabled.good.yml | 3 -- docs/configuration/configuration.md | 9 ---- storage/remote/write_handler.go | 6 ++- 7 files changed, 6 insertions(+), 75 deletions(-) delete mode 100644 config/testdata/otlp_label_underscore_sanitization_defaults.good.yml delete mode 100644 config/testdata/otlp_label_underscore_sanitization_disabled.good.yml delete mode 100644 config/testdata/otlp_label_underscore_sanitization_enabled.good.yml diff --git a/config/config.go b/config/config.go index 91b91d25fc..8e7afc1f2f 100644 --- a/config/config.go +++ b/config/config.go @@ -258,9 +258,7 @@ var ( // DefaultOTLPConfig is the default OTLP configuration. DefaultOTLPConfig = OTLPConfig{ - TranslationStrategy: otlptranslator.UnderscoreEscapingWithSuffixes, - LabelNameUnderscoreSanitization: true, - LabelNamePreserveMultipleUnderscores: true, + TranslationStrategy: otlptranslator.UnderscoreEscapingWithSuffixes, } ) @@ -1611,14 +1609,6 @@ type OTLPConfig struct { // PromoteScopeMetadata controls whether to promote OTel scope metadata (i.e. name, version, schema URL, and attributes) to metric labels. // As per OTel spec, the aforementioned scope metadata should be identifying, i.e. made into metric labels. PromoteScopeMetadata bool `yaml:"promote_scope_metadata,omitempty"` - // LabelNameUnderscoreSanitization controls whether to enable prepending of 'key_' to labels - // starting with '_'. Reserved labels starting with `__` are not modified. - // This is only relevant when AllowUTF8 is false (i.e., when using underscore escaping). - LabelNameUnderscoreSanitization bool `yaml:"label_name_underscore_sanitization,omitempty"` - // LabelNamePreserveMultipleUnderscores enables preserving of multiple consecutive underscores - // in label names when AllowUTF8 is false. When false, multiple consecutive underscores are - // collapsed to a single underscore during label name sanitization. - LabelNamePreserveMultipleUnderscores bool `yaml:"label_name_preserve_multiple_underscores,omitempty"` } // UnmarshalYAML implements the yaml.Unmarshaler interface. diff --git a/config/config_test.go b/config/config_test.go index d729d2a6aa..1f093c7959 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -175,9 +175,7 @@ var expectedConf = &Config{ PromoteResourceAttributes: []string{ "k8s.cluster.name", "k8s.job.name", "k8s.namespace.name", }, - TranslationStrategy: otlptranslator.UnderscoreEscapingWithSuffixes, - LabelNameUnderscoreSanitization: true, - LabelNamePreserveMultipleUnderscores: true, + TranslationStrategy: otlptranslator.UnderscoreEscapingWithSuffixes, }, RemoteReadConfigs: []*RemoteReadConfig{ @@ -1844,48 +1842,6 @@ func TestOTLPPromoteScopeMetadata(t *testing.T) { }) } -func TestOTLPLabelUnderscoreSanitization(t *testing.T) { - t.Run("defaults to true", func(t *testing.T) { - conf, err := LoadFile(filepath.Join("testdata", "otlp_label_underscore_sanitization_defaults.good.yml"), false, promslog.NewNopLogger()) - require.NoError(t, err) - - // Test that default values are true - require.True(t, conf.OTLPConfig.LabelNameUnderscoreSanitization) - require.True(t, conf.OTLPConfig.LabelNamePreserveMultipleUnderscores) - }) - - t.Run("explicit enabled", func(t *testing.T) { - conf, err := LoadFile(filepath.Join("testdata", "otlp_label_underscore_sanitization_enabled.good.yml"), false, promslog.NewNopLogger()) - require.NoError(t, err) - - out, err := yaml.Marshal(conf) - require.NoError(t, err) - var got Config - require.NoError(t, yaml.UnmarshalStrict(out, &got)) - - require.True(t, got.OTLPConfig.LabelNameUnderscoreSanitization) - require.True(t, got.OTLPConfig.LabelNamePreserveMultipleUnderscores) - }) - - t.Run("explicit disabled", func(t *testing.T) { - conf, err := LoadFile(filepath.Join("testdata", "otlp_label_underscore_sanitization_disabled.good.yml"), false, promslog.NewNopLogger()) - require.NoError(t, err) - - // When explicitly set to false, they should be false - require.False(t, conf.OTLPConfig.LabelNameUnderscoreSanitization) - require.False(t, conf.OTLPConfig.LabelNamePreserveMultipleUnderscores) - }) - - t.Run("empty config uses defaults", func(t *testing.T) { - conf, err := LoadFile(filepath.Join("testdata", "otlp_empty.yml"), false, promslog.NewNopLogger()) - require.NoError(t, err) - - // Empty config should use default values (true) - require.True(t, conf.OTLPConfig.LabelNameUnderscoreSanitization) - require.True(t, conf.OTLPConfig.LabelNamePreserveMultipleUnderscores) - }) -} - func TestOTLPAllowUTF8(t *testing.T) { t.Run("good config - NoUTF8EscapingWithSuffixes", func(t *testing.T) { fpath := filepath.Join("testdata", "otlp_allow_utf8.good.yml") diff --git a/config/testdata/otlp_label_underscore_sanitization_defaults.good.yml b/config/testdata/otlp_label_underscore_sanitization_defaults.good.yml deleted file mode 100644 index 3b1e9796d3..0000000000 --- a/config/testdata/otlp_label_underscore_sanitization_defaults.good.yml +++ /dev/null @@ -1,2 +0,0 @@ -otlp: - promote_resource_attributes: ["service.name"] diff --git a/config/testdata/otlp_label_underscore_sanitization_disabled.good.yml b/config/testdata/otlp_label_underscore_sanitization_disabled.good.yml deleted file mode 100644 index f8fe4ea669..0000000000 --- a/config/testdata/otlp_label_underscore_sanitization_disabled.good.yml +++ /dev/null @@ -1,3 +0,0 @@ -otlp: - label_name_underscore_sanitization: false - label_name_preserve_multiple_underscores: false diff --git a/config/testdata/otlp_label_underscore_sanitization_enabled.good.yml b/config/testdata/otlp_label_underscore_sanitization_enabled.good.yml deleted file mode 100644 index 8ce347495e..0000000000 --- a/config/testdata/otlp_label_underscore_sanitization_enabled.good.yml +++ /dev/null @@ -1,3 +0,0 @@ -otlp: - label_name_underscore_sanitization: true - label_name_preserve_multiple_underscores: true diff --git a/docs/configuration/configuration.md b/docs/configuration/configuration.md index 451af231c5..b3ea571b80 100644 --- a/docs/configuration/configuration.md +++ b/docs/configuration/configuration.md @@ -222,15 +222,6 @@ otlp: # Enables promotion of OTel scope metadata (i.e. name, version, schema URL, and attributes) to metric labels. # This is disabled by default for backwards compatibility, but according to OTel spec, scope metadata _should_ be identifying, i.e. translated to metric labels. [ promote_scope_metadata: | default = false ] - # Controls whether to enable prepending of 'key_' to labels starting with '_'. - # Reserved labels starting with '__' are not modified. - # This is only relevant when translation_strategy uses underscore escaping - # (e.g., "UnderscoreEscapingWithSuffixes" or "UnderscoreEscapingWithoutSuffixes"). - [ label_name_underscore_sanitization: | default = true ] - # Enables preserving of multiple consecutive underscores in label names when - # translation_strategy uses underscore escaping. When true (default), multiple - # consecutive underscores are preserved during label name sanitization. - [ label_name_preserve_multiple_underscores: | default = true ] # Settings related to the remote read feature. remote_read: diff --git a/storage/remote/write_handler.go b/storage/remote/write_handler.go index 6bb63635b5..8c8f71941f 100644 --- a/storage/remote/write_handler.go +++ b/storage/remote/write_handler.go @@ -658,8 +658,10 @@ func (rw *rwExporter) ConsumeMetrics(ctx context.Context, md pmetric.Metrics) er AllowDeltaTemporality: rw.allowDeltaTemporality, LookbackDelta: rw.lookbackDelta, EnableTypeAndUnitLabels: rw.enableTypeAndUnitLabels, - LabelNameUnderscoreSanitization: otlpCfg.LabelNameUnderscoreSanitization, - LabelNamePreserveMultipleUnderscores: otlpCfg.LabelNamePreserveMultipleUnderscores, + // For backwards compatibility. + LabelNameUnderscoreSanitization: true, + // For backwards compatibility. + LabelNamePreserveMultipleUnderscores: true, }) defer func() {