| 97 | } |
| 98 | |
| 99 | func (c *Client) logRequest(req *http.Request, span opentracing.Span) { |
| 100 | if req.Body == nil || c.requestLogThreshold <= 0 { |
| 101 | return |
| 102 | } |
| 103 | body, err := req.GetBody() |
| 104 | if err != nil { |
| 105 | ext.LogError(span, errors.Wrap(err, "cannot get request body")) |
| 106 | return |
| 107 | } |
| 108 | defer body.Close() |
| 109 | |
| 110 | byt, err := ioutil.ReadAll(io.LimitReader(body, int64(c.responseLogThreshold))) |
| 111 | if err != nil { |
| 112 | ext.LogError(span, errors.Wrap(err, "cannot read request body")) |
| 113 | return |
| 114 | } |
| 115 | if span != nil { |
| 116 | span.LogKV("request", string(byt)) |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | func (c *Client) logResponse(response *http.Response, span opentracing.Span) { |
| 121 | if response.Body == nil || c.responseLogThreshold <= 0 { |