Skip to content

Commit

Permalink
feat: allow custom attributes to be transformed (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kav91 authored Mar 2, 2020
1 parent 2e97ee5 commit 76e7bbc
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions internal/processor/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ func CreateMetricSets(samples []interface{}, config *load.Config, i int, mergeMe
eventType := "UnknownSample" // set an UnknownSample event name
SetEventType(&currentSample, &eventType, api.EventType, api.Merge, api.Name)

// add custom attribute(s)
// global
for k, v := range config.CustomAttributes {
currentSample[k] = v
}
// nested
for k, v := range api.CustomAttributes {
currentSample[k] = v
}

// init lookup store
if (&config.LookupStore) == nil {
config.LookupStore = map[string]map[string]struct{}{}
Expand Down Expand Up @@ -110,15 +120,6 @@ func CreateMetricSets(samples []interface{}, config *load.Config, i int, mergeMe

RunMathCalculations(&api.Math, &currentSample)

// add custom attribute(s)
// global
for k, v := range config.CustomAttributes {
currentSample[k] = v
}
// nested
for k, v := range api.CustomAttributes {
currentSample[k] = v
}
// inject some additional attributes if set
if config.Global.BaseURL != "" {
currentSample["baseUrl"] = config.Global.BaseURL
Expand Down

0 comments on commit 76e7bbc

Please sign in to comment.