From ed0de41b737e24eeebf2276ce9aae6cea7ed17aa Mon Sep 17 00:00:00 2001 From: Arthur Silva Sens Date: Wed, 4 Jun 2025 17:52:39 -0300 Subject: [PATCH] bugfix: Default OTLP config not respected when `otlp:` block is unset (#16693) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jan-Otto Kröpke --- CHANGELOG.md | 4 ++++ config/config.go | 1 + config/config_default_test.go | 1 + config/config_test.go | 20 ++++++++++++++++++++ config/testdata/otlp_empty.yml | 1 + 5 files changed, 27 insertions(+) create mode 100644 config/testdata/otlp_empty.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index 3411245417..f51a485e61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 3.4.2 / 2025-06-04 + +* [BUGFIX] OTLP receiver: Fix default configuration not being respected if the `otlp:` block is unset in the config file. #16693 + ## 3.4.1 / 2025-05-31 * [BUGFIX] Parser: Add reproducer for a dangling-reference issue in parsers. #16633 diff --git a/config/config.go b/config/config.go index f140044baa..7c591cfa8f 100644 --- a/config/config.go +++ b/config/config.go @@ -157,6 +157,7 @@ var ( DefaultConfig = Config{ GlobalConfig: DefaultGlobalConfig, Runtime: DefaultRuntimeConfig, + OTLPConfig: DefaultOTLPConfig, } // DefaultGlobalConfig is the default global configuration. diff --git a/config/config_default_test.go b/config/config_default_test.go index 2faaf98cf9..e5f43e1f50 100644 --- a/config/config_default_test.go +++ b/config/config_default_test.go @@ -22,6 +22,7 @@ var ruleFilesExpectedConf = &Config{ GlobalConfig: DefaultGlobalConfig, Runtime: DefaultRuntimeConfig, + OTLPConfig: DefaultOTLPConfig, RuleFiles: []string{ "testdata/first.rules", "testdata/rules/second.rules", diff --git a/config/config_test.go b/config/config_test.go index 236b062898..415905e46f 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -1775,6 +1775,26 @@ func TestOTLPAllowUTF8(t *testing.T) { verify(t, err) }) }) + + t.Run("good config - missing otlp config uses default", func(t *testing.T) { + fpath := filepath.Join("testdata", "otlp_empty.yml") + verify := func(t *testing.T, conf *Config, err error) { + t.Helper() + require.NoError(t, err) + require.Equal(t, UnderscoreEscapingWithSuffixes, conf.OTLPConfig.TranslationStrategy) + } + + t.Run("LoadFile", func(t *testing.T) { + conf, err := LoadFile(fpath, false, promslog.NewNopLogger()) + verify(t, conf, err) + }) + t.Run("Load", func(t *testing.T) { + content, err := os.ReadFile(fpath) + require.NoError(t, err) + conf, err := Load(string(content), promslog.NewNopLogger()) + verify(t, conf, err) + }) + }) } func TestLoadConfig(t *testing.T) { diff --git a/config/testdata/otlp_empty.yml b/config/testdata/otlp_empty.yml new file mode 100644 index 0000000000..7085e9246b --- /dev/null +++ b/config/testdata/otlp_empty.yml @@ -0,0 +1 @@ +global: