bugfix: Default OTLP config not respected when otlp: block is unset (#16693)

Co-authored-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
Arthur Silva Sens 2025-06-04 17:52:39 -03:00 committed by GitHub
parent aea6503d9b
commit ed0de41b73
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 27 additions and 0 deletions

View File

@ -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

View File

@ -157,6 +157,7 @@ var (
DefaultConfig = Config{
GlobalConfig: DefaultGlobalConfig,
Runtime: DefaultRuntimeConfig,
OTLPConfig: DefaultOTLPConfig,
}
// DefaultGlobalConfig is the default global configuration.

View File

@ -22,6 +22,7 @@ var ruleFilesExpectedConf = &Config{
GlobalConfig: DefaultGlobalConfig,
Runtime: DefaultRuntimeConfig,
OTLPConfig: DefaultOTLPConfig,
RuleFiles: []string{
"testdata/first.rules",
"testdata/rules/second.rules",

View File

@ -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) {

1
config/testdata/otlp_empty.yml vendored Normal file
View File

@ -0,0 +1 @@
global: