RoundTrip implements http.RoundTripper
(pipelineRequest pipeline.Request)
| 48 | |
| 49 | // RoundTrip implements http.RoundTripper |
| 50 | func (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 |
nothing calls this directly
no test coverage detected