String returns the prometheus-formatted version of the labels. Which is downcasting the typed TraceQL values to strings, with some special casing.
()
| 281 | // String returns the prometheus-formatted version of the labels. Which is downcasting |
| 282 | // the typed TraceQL values to strings, with some special casing. |
| 283 | func (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 | |
| 311 | func (ls Labels) MapKey() SeriesMapKey { |
| 312 | key := SeriesMapKey{} |
no test coverage detected