MCPcopy Create free account
hub / github.com/cortexproject/cortex / AddExtraFields

Method AddExtraFields

pkg/querier/stats/stats.go:104–125  ·  view source on GitHub ↗
(fieldsVals ...any)

Source from the content-addressed store, hash-verified

102}
103
104func (s *QueryStats) AddExtraFields(fieldsVals ...any) {
105 if s == nil {
106 return
107 }
108
109 s.m.Lock()
110 defer s.m.Unlock()
111
112 if s.ExtraFields == nil {
113 s.ExtraFields = map[string]string{}
114 }
115
116 if len(fieldsVals)%2 == 1 {
117 fieldsVals = append(fieldsVals, "")
118 }
119
120 for i := 0; i < len(fieldsVals); i += 2 {
121 if v, ok := fieldsVals[i].(string); ok {
122 s.ExtraFields[v] = fmt.Sprintf("%v", fieldsVals[i+1])
123 }
124 }
125}
126
127func (s *QueryStats) LoadExtraFields() []any {
128 if s == nil {

Callers 4

TestStats_MergeFunction · 0.95
MergeMethod · 0.95
DoMethod · 0.80

Calls

no outgoing calls

Tested by 2

TestStats_MergeFunction · 0.76