move logging to metrics middleware
This commit is contained in:
parent
8dbda8ebda
commit
79d7ffa18c
@ -476,7 +476,7 @@ func (oc *Collection) streamItems(ctx context.Context, errs *fault.Bus) {
|
||||
int64(len(oc.driveItems)))
|
||||
defer close(folderProgress)
|
||||
|
||||
semaphoreCh := make(chan struct{}, graph.Parallelism(path.OneDriveService).Item())
|
||||
semaphoreCh := make(chan struct{}, 1)
|
||||
defer close(semaphoreCh)
|
||||
|
||||
ctx = clues.Add(ctx,
|
||||
|
||||
@ -93,5 +93,10 @@ func getRequestDump(ctx context.Context, req *http.Request, getBody bool) string
|
||||
logger.CtxErr(ctx, err).Error("dumping http request")
|
||||
}
|
||||
|
||||
// Dump all headers
|
||||
for k, v := range req.Header {
|
||||
logger.Ctx(ctx).Debugf("Header field %q, Value %q\n", k, v)
|
||||
}
|
||||
|
||||
return string(reqDump)
|
||||
}
|
||||
|
||||
@ -118,7 +118,6 @@ func (mw *LoggingMiddleware) Intercept(
|
||||
middlewareIndex int,
|
||||
req *http.Request,
|
||||
) (*http.Response, error) {
|
||||
logReq(req.Context(), req)
|
||||
|
||||
// call the next middleware
|
||||
resp, err := pipeline.Next(req, middlewareIndex)
|
||||
@ -126,16 +125,16 @@ func (mw *LoggingMiddleware) Intercept(
|
||||
return resp, err
|
||||
}
|
||||
|
||||
ctx := clues.Add(
|
||||
req.Context(),
|
||||
"method", req.Method,
|
||||
"url", LoggableURL(req.URL.String()),
|
||||
"request_content_len", req.ContentLength,
|
||||
"resp_status", resp.Status,
|
||||
"resp_status_code", resp.StatusCode,
|
||||
"resp_content_len", resp.ContentLength)
|
||||
// ctx := clues.Add(
|
||||
// req.Context(),
|
||||
// "method", req.Method,
|
||||
// "url", LoggableURL(req.URL.String()),
|
||||
// "request_content_len", req.ContentLength,
|
||||
// "resp_status", resp.Status,
|
||||
// "resp_status_code", resp.StatusCode,
|
||||
// "resp_content_len", resp.ContentLength)
|
||||
|
||||
logResp(ctx, resp)
|
||||
//logResp(ctx, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
@ -336,6 +335,8 @@ func (mw *MetricsMiddleware) Intercept(
|
||||
middlewareIndex int,
|
||||
req *http.Request,
|
||||
) (*http.Response, error) {
|
||||
logReq(req.Context(), req)
|
||||
|
||||
var (
|
||||
start = time.Now()
|
||||
resp, err = pipeline.Next(req, middlewareIndex)
|
||||
@ -370,5 +371,16 @@ func (mw *MetricsMiddleware) Intercept(
|
||||
|
||||
events.IncN(xmrui, events.APICall, xmruHeader)
|
||||
|
||||
ctx := clues.Add(
|
||||
req.Context(),
|
||||
"method", req.Method,
|
||||
"url", LoggableURL(req.URL.String()),
|
||||
"request_content_len", req.ContentLength,
|
||||
"resp_status", resp.Status,
|
||||
"resp_status_code", resp.StatusCode,
|
||||
"resp_content_len", resp.ContentLength)
|
||||
|
||||
logResp(ctx, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user