MCPcopy
hub / github.com/grafana/tempo / LabelsFromArgs

Function LabelsFromArgs

pkg/traceql/engine_metrics.go:244–270  ·  view source on GitHub ↗
(args ...any)

Source from the content-addressed store, hash-verified

242}
243
244func LabelsFromArgs(args ...any) Labels {
245 if len(args)%2 != 0 {
246 panic("LabelsFromArgs must be called with an even number of arguments")
247 }
248
249 out := make(Labels, 0, len(args)/2)
250
251 for i := 0; i < len(args); i += 2 {
252 name := args[i].(string)
253 var val Static
254 switch arg := args[i+1].(type) {
255 case string:
256 val = NewStaticString(arg)
257 case int:
258 val = NewStaticInt(arg)
259 case float64:
260 val = NewStaticFloat(arg)
261 default:
262 panic(fmt.Sprintf("LabelsFromArgs type not yet supported: %T", arg))
263
264 }
265
266 out = append(out, Label{Name: name, Value: val})
267 }
268
269 return out
270}
271
272func (ls Labels) Has(name string) bool {
273 for _, l := range ls {

Calls 3

NewStaticStringFunction · 0.85
NewStaticIntFunction · 0.85
NewStaticFloatFunction · 0.85