diff --git a/log/config.go b/log/config.go index 1759f21..253eb1e 100644 --- a/log/config.go +++ b/log/config.go @@ -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)) } diff --git a/tracing/config.go b/tracing/config.go index 19de364..03df409 100644 --- a/tracing/config.go +++ b/tracing/config.go @@ -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)) }