github.com/msales/pkg/v3@v3.24.0/stats/tags.go (about) 1 package stats 2 3 // Tags is a map of strings that adds some convenience functionality over the vanilla go map. 4 // Deprecated. 5 // Warning! There is a known bug where Tags passed to any stats func (like Inc, Gauge, etc.) will 6 // not be merge correctly into the global tags. This might result in the stats loss! Do not pass 7 // Tags object to those functions, use the variadic list instead.. 8 type Tags map[string]string 9 10 // With adds the value to the key. 11 func (t Tags) With(key, value string) Tags { 12 t[key] = value 13 14 return t 15 } 16 17 // Merge adds the values from t2 to t, overriding the conflicting keys. 18 func (t Tags) Merge(t2 Tags) Tags { 19 for k, v := range t2 { 20 t[k] = v 21 } 22 23 return t 24 } 25 26 func (t Tags) toArray() []interface{} { 27 arr := make([]interface{}, len(t)*2) 28 29 i := 0 30 for k, v := range t { 31 arr[i] = k 32 arr[i+1] = v 33 i += 2 34 } 35 36 return arr 37 }