From 76e7bbc26dbc014d1102f8f410019b53dd87ada0 Mon Sep 17 00:00:00 2001 From: Kavashen Pather Date: Tue, 3 Mar 2020 07:24:05 +1100 Subject: [PATCH] feat: allow custom attributes to be transformed (#110) --- internal/processor/create.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/internal/processor/create.go b/internal/processor/create.go index 0ec3795b..f0fb2e5c 100644 --- a/internal/processor/create.go +++ b/internal/processor/create.go @@ -32,6 +32,16 @@ func CreateMetricSets(samples []interface{}, config *load.Config, i int, mergeMe eventType := "UnknownSample" // set an UnknownSample event name SetEventType(¤tSample, &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{}{} @@ -110,15 +120,6 @@ func CreateMetricSets(samples []interface{}, config *load.Config, i int, mergeMe RunMathCalculations(&api.Math, ¤tSample) - // 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