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

Method Combine

pkg/traceql/engine_metrics.go:1628–1664  ·  view source on GitHub ↗
(in []*tempopb.TimeSeries)

Source from the content-addressed store, hash-verified

1626}
1627
1628func (b *SimpleAggregator) Combine(in []*tempopb.TimeSeries) {
1629 nan := math.Float64frombits(normalNaN)
1630
1631 for _, ts := range in {
1632 // Convert proto labels to traceql labels
1633 labels, _ := convertProtoLabelsToTraceQL(ts.Labels, false)
1634 key := labels.MapKey()
1635
1636 existing, ok := b.ss[key]
1637 if !ok {
1638
1639 existing = TimeSeries{
1640 Labels: labels,
1641 Values: make([]float64, b.intervalMapper.IntervalCount()),
1642 Exemplars: make([]Exemplar, 0, len(ts.Exemplars)),
1643 }
1644 if b.initWithNaN {
1645 for i := range existing.Values {
1646 existing.Values[i] = nan
1647 }
1648 }
1649
1650 b.ss[key] = existing
1651 }
1652
1653 for _, sample := range ts.Samples {
1654 j := b.intervalMapper.IntervalMs(sample.TimestampMs)
1655 if j >= 0 && j < len(existing.Values) {
1656 existing.Values[j] = b.aggregationFunc(existing.Values[j], sample.Value)
1657 }
1658 }
1659
1660 b.aggregateExemplars(ts, &existing)
1661
1662 b.ss[key] = existing
1663 }
1664}
1665
1666func (b *SimpleAggregator) aggregateExemplars(ts *tempopb.TimeSeries, existing *TimeSeries) {
1667 for _, exemplar := range ts.Exemplars {

Callers

nothing calls this directly

Calls 5

aggregateExemplarsMethod · 0.95
IntervalCountMethod · 0.65
IntervalMsMethod · 0.65
MapKeyMethod · 0.45

Tested by

no test coverage detected