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

Method RoundTrip

modules/frontend/traceid_sharder.go:50–79  ·  view source on GitHub ↗

RoundTrip implements http.RoundTripper

(pipelineRequest pipeline.Request)

Source from the content-addressed store, hash-verified

48
49// RoundTrip implements http.RoundTripper
50func (s asyncTraceSharder) RoundTrip(pipelineRequest pipeline.Request) (pipeline.Responses[combiner.PipelineResponse], error) {
51 ctx, span := tracer.Start(pipelineRequest.Context(), "frontend.ShardQuery")
52 defer span.End()
53 pipelineRequest.SetContext(ctx)
54
55 reqs, err := s.buildShardedRequests(pipelineRequest)
56 if err != nil {
57 return nil, err
58 }
59 s.jobsPerQuery.WithLabelValues(traceByIDOp).Observe(float64(len(reqs)))
60
61 // execute requests
62 concurrentShards := uint(s.cfg.QueryShards)
63 // if concurrent shards is set, respect that value
64 if s.cfg.ConcurrentShards > 0 {
65 concurrentShards = uint(s.cfg.ConcurrentShards)
66 }
67
68 // concurrent_shards grater then query_shards should not be allowed because it would create
69 // more goroutines then the jobs to send these jobs to queriers.
70 if concurrentShards > uint(s.cfg.QueryShards) {
71 // set the concurrent shards to the total shards
72 concurrentShards = uint(s.cfg.QueryShards)
73 }
74
75 return pipeline.NewAsyncSharderFunc(ctx, int(concurrentShards), len(reqs), func(i int) pipeline.Request {
76 pipelineReq := reqs[i]
77 return pipelineReq
78 }, s.next), nil
79}
80
81// buildShardedRequests returns a slice of requests sharded on the precalculated
82// block boundaries

Callers

nothing calls this directly

Calls 6

buildShardedRequestsMethod · 0.95
NewAsyncSharderFuncFunction · 0.92
StartMethod · 0.65
ContextMethod · 0.65
SetContextMethod · 0.65
ObserveMethod · 0.65

Tested by

no test coverage detected