MCPcopy Index your code
hub / github.com/DoNewsCode/core / logRequest

Method logRequest

clihttp/client.go:99–118  ·  view source on GitHub ↗
(req *http.Request, span opentracing.Span)

Source from the content-addressed store, hash-verified

97}
98
99func (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
120func (c *Client) logResponse(response *http.Response, span opentracing.Span) {
121 if response.Body == nil || c.responseLogThreshold <= 0 {

Callers 1

DoMethod · 0.95

Calls 2

CloseMethod · 0.80
LogKVMethod · 0.65

Tested by

no test coverage detected