fix(config): Fix extrafields / attribute on logger / tracing
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
582a9e6192
commit
5a0beb9e2c
@ -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))
|
||||
}
|
||||
|
@ -116,9 +116,13 @@ func (c *ConfigStruct) applyEnv() error {
|
||||
|
||||
// Attributes
|
||||
if v := os.Getenv(fmt.Sprintf("%s%s", envPrefix, "ATTRIBUTES")); v != "" {
|
||||
if c.Attributes == nil {
|
||||
c.Attributes = make(map[string]string)
|
||||
}
|
||||
|
||||
attributeParts := strings.Split(v, ",")
|
||||
for _, ap := range attributeParts {
|
||||
attributeKV := strings.SplitN(ap, ":", 1)
|
||||
attributeKV := strings.SplitN(ap, ":", 2)
|
||||
if len(attributeKV) != 2 {
|
||||
return errors.NotValidf(fmt.Sprintf("Invalid attribute %s in environment variable. Should be a key1:value1,key2:value2 format", ap))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user