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

Function NewOverTimeAggregator

pkg/traceql/engine_metrics.go:489–522  ·  view source on GitHub ↗
(attr Attribute, op SimpleAggregationOp)

Source from the content-addressed store, hash-verified

487var _ VectorAggregator = (*OverTimeAggregator)(nil)
488
489func NewOverTimeAggregator(attr Attribute, op SimpleAggregationOp) *OverTimeAggregator {
490 var fn func(s Span) float64
491 var agg func(current, n float64) float64
492
493 switch op {
494 case maxOverTimeAggregation:
495 agg = maxOverTime()
496 case minOverTimeAggregation:
497 agg = minOverTime()
498 case sumOverTimeAggregation:
499 agg = sumOverTime()
500 }
501
502 switch attr {
503 case IntrinsicDurationAttribute:
504 fn = func(s Span) float64 {
505 return float64(s.DurationNanos()) / float64(time.Second)
506 }
507 default:
508 fn = func(s Span) float64 {
509 f, a := FloatizeAttribute(s, attr)
510 if a == TypeNil {
511 return math.Float64frombits(normalNaN)
512 }
513 return f
514 }
515 }
516
517 return &OverTimeAggregator{
518 getSpanAttValue: fn,
519 agg: agg,
520 val: math.Float64frombits(normalNaN),
521 }
522}
523
524func (c *OverTimeAggregator) Observe(s Span) {
525 c.val = c.agg(c.val, c.getSpanAttValue(s))

Callers 1

initMethod · 0.85

Calls 5

maxOverTimeFunction · 0.85
minOverTimeFunction · 0.85
sumOverTimeFunction · 0.85
FloatizeAttributeFunction · 0.85
DurationNanosMethod · 0.65

Tested by

no test coverage detected