Skip to content

Commit

Permalink
chore(telemetry): store extra attributes in the reserved field
Browse files Browse the repository at this point in the history
Signed-off-by: Alexey Igrychev <alexey.igrychev@flant.com>
  • Loading branch information
alexey-igrychev committed Aug 15, 2022
1 parent c95a872 commit 6f798de
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions pkg/telemetry/telemetrywerfio.go
Expand Up @@ -174,27 +174,20 @@ func (t *TelemetryWerfIO) getAttributes() map[string]interface{} {

// add extra attributes
{
extraAttributes := map[string]interface{}{}
env := os.Environ()
sort.Strings(env)
for _, keyValue := range env {
parts := strings.SplitN(keyValue, "=", 2)
if strings.HasPrefix(parts[0], "WERF_TELEMETRY_EXTRA_ATTRIBUTE_") {
valueParts := strings.SplitN(parts[1], "=", 2)

attrKey := valueParts[0]
attrVal := valueParts[1]

// ignore reserved name
{
_, ok := attributes[attrKey]
if ok {
continue
}
}

attributes[attrKey] = attrVal
extraAttributes[attrKey] = attrVal
}
}

attributes["extra"] = extraAttributes
}

return attributes
Expand Down

0 comments on commit 6f798de

Please sign in to comment.