(attr Attribute, by []Attribute, lookups [][]Attribute, start, end, step uint64, instant bool, exemplars uint32)
| 449 | } |
| 450 | |
| 451 | func newAvgAggregator[F FastStatic, S StaticVals](attr Attribute, by []Attribute, lookups [][]Attribute, start, end, step uint64, instant bool, exemplars uint32) SpanAggregator { |
| 452 | var fn func(s Span) float64 |
| 453 | |
| 454 | switch attr { |
| 455 | case IntrinsicDurationAttribute: |
| 456 | fn = func(s Span) float64 { |
| 457 | return float64(s.DurationNanos()) / float64(time.Second) |
| 458 | } |
| 459 | default: |
| 460 | fn = func(s Span) float64 { |
| 461 | f, a := FloatizeAttribute(s, attr) |
| 462 | if a == TypeNil { |
| 463 | return math.Float64frombits(normalNaN) |
| 464 | } |
| 465 | return f |
| 466 | } |
| 467 | } |
| 468 | |
| 469 | return &avgOverTimeSpanAggregator[F, S]{ |
| 470 | series: map[F]avgOverTimeSeries[S]{}, |
| 471 | getSpanAttValue: fn, |
| 472 | by: by, |
| 473 | byLookups: lookups, |
| 474 | intervalMapper: NewIntervalMapper(start, end, step, instant), |
| 475 | start: start, |
| 476 | end: end, |
| 477 | step: step, |
| 478 | instant: instant, |
| 479 | exemplars: exemplars, |
| 480 | } |
| 481 | } |
| 482 | |
| 483 | func (g *avgOverTimeSpanAggregator[F, S]) Observe(span Span) { |
| 484 | interval := g.intervalMapper.Interval(span.StartTimeUnixNanos()) |
no test coverage detected