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

Method RoundTrip

modules/frontend/pipeline/collector_http.go:33–65  ·  view source on GitHub ↗

RoundTrip implements the http.RoundTripper interface

(req *http.Request)

Source from the content-addressed store, hash-verified

31
32// RoundTrip implements the http.RoundTripper interface
33func (r httpCollector) RoundTrip(req *http.Request) (*http.Response, error) {
34 ctx, cancel := context.WithCancel(req.Context())
35 defer cancel()
36 ctx, span := tracer.Start(ctx, "httpCollector.RoundTrip")
37 defer span.End()
38
39 req = req.WithContext(ctx)
40
41 resps, err := r.next.RoundTrip(NewHTTPRequest(req))
42 if err != nil {
43 return nil, err
44 }
45 span.AddEvent("next.RoundTrip done")
46
47 err = consumeAndCombineResponses(ctx, r.consumers, resps, r.combiner, nil)
48 if err != nil {
49 return nil, err
50 }
51 span.AddEvent("consumeAndCombineResponses done")
52
53 resp, err := r.combiner.HTTPFinal()
54 if err != nil {
55 return nil, err
56 }
57 span.AddEvent("combiner.HTTPFinal done")
58
59 // we don't get context cancellation errors from the HTTPFinal,
60 // so we need to check, and return to downstream callers
61 if req.Context().Err() != nil {
62 return nil, req.Context().Err()
63 }
64 return resp, err
65}
66
67func consumeAndCombineResponses(ctx context.Context, consumers int, resps Responses[combiner.PipelineResponse], c combiner.Combiner, callback func() error) error {
68 respChan := make(chan combiner.PipelineResponse)

Callers

nothing calls this directly

Calls 6

NewHTTPRequestFunction · 0.85
ContextMethod · 0.65
StartMethod · 0.65
RoundTripMethod · 0.65
HTTPFinalMethod · 0.65

Tested by

no test coverage detected