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

Method AsAnyValue

pkg/traceql/engine.go:377–479  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

375}
376
377func (s Static) AsAnyValue() *common_v1.AnyValue {
378 switch s.Type {
379 case TypeInt:
380 n, _ := s.Int()
381 return &common_v1.AnyValue{
382 Value: &common_v1.AnyValue_IntValue{
383 IntValue: int64(n),
384 },
385 }
386 case TypeFloat:
387 return &common_v1.AnyValue{
388 Value: &common_v1.AnyValue_DoubleValue{
389 DoubleValue: s.Float(),
390 },
391 }
392 case TypeBoolean:
393 b, _ := s.Bool()
394 return &common_v1.AnyValue{
395 Value: &common_v1.AnyValue_BoolValue{
396 BoolValue: b,
397 },
398 }
399 case TypeDuration:
400 d, _ := s.Duration()
401 return &common_v1.AnyValue{
402 Value: &common_v1.AnyValue_StringValue{
403 StringValue: d.String(),
404 },
405 }
406 case TypeString, TypeStatus, TypeNil, TypeKind:
407 return &common_v1.AnyValue{
408 Value: &common_v1.AnyValue_StringValue{
409 StringValue: s.EncodeToString(false),
410 },
411 }
412 case TypeIntArray:
413 ints, _ := s.IntArray()
414
415 anyInts := make([]common_v1.AnyValue_IntValue, len(ints))
416 anyVals := make([]common_v1.AnyValue, len(ints))
417 anyArray := common_v1.ArrayValue{
418 Values: make([]*common_v1.AnyValue, len(ints)),
419 }
420 for i, n := range ints {
421 anyInts[i].IntValue = int64(n)
422 anyVals[i].Value = &anyInts[i]
423 anyArray.Values[i] = &anyVals[i]
424 }
425
426 return &common_v1.AnyValue{Value: &common_v1.AnyValue_ArrayValue{ArrayValue: &anyArray}}
427 case TypeFloatArray:
428 floats, _ := s.FloatArray()
429
430 anyDouble := make([]common_v1.AnyValue_DoubleValue, len(floats))
431 anyVals := make([]common_v1.AnyValue, len(floats))
432 anyArray := common_v1.ArrayValue{
433 Values: make([]*common_v1.AnyValue, len(floats)),
434 }

Callers 3

asTraceSearchMetadataFunction · 0.80
ToProtoMethod · 0.80
TestStatic_AsAnyValueFunction · 0.80

Calls 10

IntMethod · 0.95
FloatMethod · 0.95
BoolMethod · 0.95
DurationMethod · 0.95
EncodeToStringMethod · 0.95
IntArrayMethod · 0.95
FloatArrayMethod · 0.95
StringArrayMethod · 0.95
BooleanArrayMethod · 0.95
StringMethod · 0.45

Tested by 1

TestStatic_AsAnyValueFunction · 0.64