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

Method String

pkg/traceql/engine_metrics.go:283–309  ·  view source on GitHub ↗

String returns the prometheus-formatted version of the labels. Which is downcasting the typed TraceQL values to strings, with some special casing.

()

Source from the content-addressed store, hash-verified

281// String returns the prometheus-formatted version of the labels. Which is downcasting
282// the typed TraceQL values to strings, with some special casing.
283func (ls Labels) String() string {
284 promLabels := labels.NewBuilder(labels.EmptyLabels())
285 for _, l := range ls {
286 var promValue string
287 switch l.Value.Type {
288 case TypeNil:
289 promValue = "<nil>"
290 case TypeString:
291 s := l.Value.EncodeToString(false)
292 switch s {
293 case "nil":
294 promValue = "<nil>"
295 case "":
296 promValue = "<empty>"
297 default:
298 promValue = s
299 }
300 case TypeInt:
301 promValue = "int(" + l.Value.EncodeToString(false) + ")"
302 default:
303 promValue = l.Value.EncodeToString(false)
304 }
305 promLabels.Set(l.Name, promValue)
306 }
307
308 return promLabels.Labels().String()
309}
310
311func (ls Labels) MapKey() SeriesMapKey {
312 key := SeriesMapKey{}

Callers 4

ObserveExemplarMethod · 0.45
labelsForMethod · 0.45
ObserveExemplarMethod · 0.45
CombineMethod · 0.45

Calls 2

EncodeToStringMethod · 0.80
SetMethod · 0.65

Tested by

no test coverage detected