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

Function naiveQueryRangeCombine

integration/api/query_range_test.go:819–853  ·  view source on GitHub ↗

naiveQueryRangeCombine makes assumptions about the data being sent from Tempo. it assumes that labels orders are always the same and that samples and exemplars do not need to be deduped.

(rNew, rInto *tempopb.QueryRangeResponse)

Source from the content-addressed store, hash-verified

817// naiveQueryRangeCombine makes assumptions about the data being sent from Tempo. it assumes that labels orders are always
818// the same and that samples and exemplars do not need to be deduped.
819func naiveQueryRangeCombine(rNew, rInto *tempopb.QueryRangeResponse) {
820 rIntoSeries := map[string]*tempopb.TimeSeries{}
821 for _, series := range rInto.GetSeries() {
822 rIntoSeries[keyFromLabels(series.GetLabels())] = series
823 }
824
825 for _, newSeries := range rNew.GetSeries() {
826 key := keyFromLabels(newSeries.GetLabels())
827 if intoSeries, ok := rIntoSeries[key]; ok {
828 intoSeries.Exemplars = append(intoSeries.Exemplars, newSeries.Exemplars...)
829 intoSeries.Samples = append(intoSeries.Samples, newSeries.Samples...)
830 } else {
831 rIntoSeries[key] = newSeries
832 }
833 }
834
835 // Rebuild the series slice from the map
836 rInto.Series = make([]*tempopb.TimeSeries, 0, len(rIntoSeries))
837 for _, series := range rIntoSeries {
838 rInto.Series = append(rInto.Series, series)
839 }
840
841 if rInto.Message == "" {
842 rInto.Message = rNew.Message
843 }
844 if rInto.Status == 0 {
845 rInto.Status = rNew.Status
846 }
847
848 // metrics?
849 rInto.Metrics.CompletedJobs += rNew.Metrics.CompletedJobs
850 rInto.Metrics.InspectedBytes += rNew.Metrics.InspectedBytes
851 rInto.Metrics.InspectedTraces += rNew.Metrics.InspectedTraces
852 rInto.Metrics.InspectedSpans += rNew.Metrics.InspectedSpans
853}
854
855func keyFromLabels(labels []v1.KeyValue) string {
856 key := ""

Callers 2

callQueryRangeFunction · 0.85

Calls 3

keyFromLabelsFunction · 0.85
GetSeriesMethod · 0.45
GetLabelsMethod · 0.45

Tested by

no test coverage detected