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

Method postProcessIngesterSearchResults

modules/querier/querier.go:864–899  ·  view source on GitHub ↗
(req *tempopb.SearchRequest, results []any)

Source from the content-addressed store, hash-verified

862}
863
864func (q *Querier) postProcessIngesterSearchResults(req *tempopb.SearchRequest, results []any) *tempopb.SearchResponse {
865 response := &tempopb.SearchResponse{
866 Metrics: &tempopb.SearchMetrics{},
867 }
868
869 traces := map[string]*tempopb.TraceSearchMetadata{}
870
871 for _, result := range results {
872 sr := result.(*tempopb.SearchResponse)
873
874 for _, t := range sr.Traces {
875 // Just simply take first result for each trace
876 if _, ok := traces[t.TraceID]; !ok {
877 traces[t.TraceID] = t
878 }
879 }
880 if sr.Metrics != nil {
881 response.Metrics.InspectedBytes += sr.Metrics.InspectedBytes
882 response.Metrics.InspectedTraces += sr.Metrics.InspectedTraces
883 }
884 }
885
886 for _, t := range traces {
887 response.Traces = append(response.Traces, t)
888 }
889
890 // Sort and limit results
891 sort.Slice(response.Traces, func(i, j int) bool {
892 return response.Traces[i].StartTimeUnixNano > response.Traces[j].StartTimeUnixNano
893 })
894 if req.Limit != 0 && int(req.Limit) < len(response.Traces) {
895 response.Traces = response.Traces[:req.Limit]
896 }
897
898 return response
899}
900
901func countSpans(trace *tempopb.Trace) int {
902 count := 0

Callers 1

SearchRecentMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected