fix(config): Fix extrafields / attribute on logger / tracing
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Matthieu 'JP' DERASSE
2023-01-10 21:26:51 +00:00
parent 582a9e6192
commit 5a0beb9e2c
2 changed files with 10 additions and 2 deletions

View File

@ -114,9 +114,13 @@ func (c *ConfigStruct) applyEnv() error {
// Extra Fields
if v := os.Getenv(fmt.Sprintf("%s%s", envPrefix, "EXTRA_FIELDS")); v != "" {
if c.ExtrasFields == nil {
c.ExtrasFields = make(map[string]interface{})
}
extraFieldsPart := strings.Split(v, ",")
for _, efp := range extraFieldsPart {
extraFieldKV := strings.SplitN(efp, ":", 1)
extraFieldKV := strings.SplitN(efp, ":", 2)
if len(extraFieldKV) != 2 {
return errors.NotValidf(fmt.Sprintf("Invalid extra_field %s in environment variable. Should be a key1:value1,key2:value2 format", efp))
}