Dont log req
This commit is contained in:
parent
93079b0812
commit
eaf252a26c
@ -45,8 +45,7 @@ func logResp(ctx context.Context, resp *http.Response) {
|
|||||||
// Dump both request and response for graph 400 errors. This is a temporary
|
// Dump both request and response for graph 400 errors. This is a temporary
|
||||||
// measure to help us understand why graph is returning transient 400s.
|
// measure to help us understand why graph is returning transient 400s.
|
||||||
if resp.StatusCode == http.StatusBadRequest {
|
if resp.StatusCode == http.StatusBadRequest {
|
||||||
log.With("request", getRequestDump(ctx, resp.Request, true)).
|
log.With("response", getRespDump(ctx, resp, logBody)).
|
||||||
With("response", getRespDump(ctx, resp, logBody)).
|
|
||||||
Info("graph api bad request")
|
Info("graph api bad request")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,14 +68,14 @@ func logResp(ctx context.Context, resp *http.Response) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func logReq(ctx context.Context, req *http.Request) {
|
// func logReq(ctx context.Context, req *http.Request) {
|
||||||
var (
|
// var (
|
||||||
log = logger.Ctx(ctx)
|
// log = logger.Ctx(ctx)
|
||||||
)
|
// )
|
||||||
|
|
||||||
log.With("request", getRequestDump(ctx, req, true)).
|
// log.With("request", getRequestDump(ctx, req, true)).
|
||||||
Info("graph api req")
|
// Info("graph api req")
|
||||||
}
|
// }
|
||||||
|
|
||||||
func getRespDump(ctx context.Context, resp *http.Response, getBody bool) string {
|
func getRespDump(ctx context.Context, resp *http.Response, getBody bool) string {
|
||||||
respDump, err := httputil.DumpResponse(resp, getBody)
|
respDump, err := httputil.DumpResponse(resp, getBody)
|
||||||
@ -87,11 +86,11 @@ func getRespDump(ctx context.Context, resp *http.Response, getBody bool) string
|
|||||||
return string(respDump)
|
return string(respDump)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getRequestDump(ctx context.Context, req *http.Request, getBody bool) string {
|
// func getRequestDump(ctx context.Context, req *http.Request, getBody bool) string {
|
||||||
reqDump, err := httputil.DumpRequest(req, getBody)
|
// reqDump, err := httputil.DumpRequest(req, getBody)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
logger.CtxErr(ctx, err).Error("dumping http request")
|
// logger.CtxErr(ctx, err).Error("dumping http request")
|
||||||
}
|
// }
|
||||||
|
|
||||||
return string(reqDump)
|
// return string(reqDump)
|
||||||
}
|
// }
|
||||||
|
|||||||
@ -118,7 +118,7 @@ func (mw *LoggingMiddleware) Intercept(
|
|||||||
middlewareIndex int,
|
middlewareIndex int,
|
||||||
req *http.Request,
|
req *http.Request,
|
||||||
) (*http.Response, error) {
|
) (*http.Response, error) {
|
||||||
logReq(req.Context(), req)
|
// logReq(req.Context(), req)
|
||||||
|
|
||||||
// call the next middleware
|
// call the next middleware
|
||||||
resp, err := pipeline.Next(req, middlewareIndex)
|
resp, err := pipeline.Next(req, middlewareIndex)
|
||||||
|
|||||||
@ -291,16 +291,16 @@ func kiotaMiddlewares(
|
|||||||
chaosOpt := &khttp.ChaosHandlerOptions{
|
chaosOpt := &khttp.ChaosHandlerOptions{
|
||||||
ChaosStrategy: khttp.Random,
|
ChaosStrategy: khttp.Random,
|
||||||
ChaosPercentage: 50,
|
ChaosPercentage: 50,
|
||||||
StatusCode: 502,
|
StatusCode: 503,
|
||||||
ResponseBody: &http.Response{
|
ResponseBody: &http.Response{
|
||||||
Status: "Bad Gateway",
|
Status: "Service Unavailable",
|
||||||
StatusCode: 502,
|
StatusCode: 503,
|
||||||
// Retry-After header
|
// Retry-After header
|
||||||
// Header: http.Header{
|
// Header: http.Header{
|
||||||
// "Retry-After": []string{"1"},
|
// "Retry-After": []string{"1"},
|
||||||
// },
|
// },
|
||||||
// Dummy body
|
// Dummy body
|
||||||
Body: io.NopCloser(strings.NewReader("bad gateway, deal with it")),
|
Body: io.NopCloser(strings.NewReader("service is down. deal with it")),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user