Do sends the request.
(req *http.Request)
| 72 | |
| 73 | // Do sends the request. |
| 74 | func (c *Client) Do(req *http.Request) (*http.Response, error) { |
| 75 | clientSpan, ctx := opentracing.StartSpanFromContextWithTracer(req.Context(), c.tracer, "HTTP Client") |
| 76 | defer clientSpan.Finish() |
| 77 | |
| 78 | req = req.WithContext(ctx) |
| 79 | |
| 80 | ext.SpanKindRPCClient.Set(clientSpan) |
| 81 | ext.HTTPUrl.Set(clientSpan, req.RequestURI) |
| 82 | ext.HTTPMethod.Set(clientSpan, req.Method) |
| 83 | |
| 84 | // Inject the client span context into the headers |
| 85 | c.logRequest(req, clientSpan) |
| 86 | |
| 87 | c.tracer.Inject(clientSpan.Context(), opentracing.HTTPHeaders, opentracing.HTTPHeadersCarrier(req.Header)) |
| 88 | response, err := c.underlying.Do(req) |
| 89 | if err != nil { |
| 90 | ext.LogError(clientSpan, err) |
| 91 | return response, err |
| 92 | } |
| 93 | |
| 94 | c.logResponse(response, clientSpan) |
| 95 | |
| 96 | return response, err |
| 97 | } |
| 98 | |
| 99 | func (c *Client) logRequest(req *http.Request, span opentracing.Span) { |
| 100 | if req.Body == nil || c.requestLogThreshold <= 0 { |