Print api response in logs for 4xx errors (#2544)
## Description Print api response in logs for 4xx errors from GC. More info for things like 400 Bad Request could be useful. ## Does this PR need a docs update or release note? - [ ] ✅ Yes, it's included - [ ] 🕐 Yes, but in a later PR - [x] ⛔ No ## Type of change <!--- Please check the type of change your PR introduces: ---> - [ ] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Test - [ ] 💻 CI/Deployment - [x] 🧹 Tech Debt/Cleanup ## Issue(s) <!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. --> * #<issue> ## Test Plan <!-- How will this be tested prior to merging.--> - [x] 💪 Manual - [ ] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
2b8e1ad2d9
commit
8096025c55
@ -296,7 +296,7 @@ func (handler *LoggingMiddleware) Intercept(
|
||||
}
|
||||
|
||||
// Log errors according to api debugging configurations.
|
||||
// When debugging is toggled, every non-2xx is recorded with a respose dump.
|
||||
// When debugging is toggled, every non-2xx is recorded with a response dump.
|
||||
// Otherwise, throttling cases and other non-2xx responses are logged
|
||||
// with a slimmer reference for telemetry/supportability purposes.
|
||||
if logger.DebugAPI || os.Getenv(logGraphRequestsEnvKey) != "" {
|
||||
@ -316,9 +316,16 @@ func (handler *LoggingMiddleware) Intercept(
|
||||
// special case for supportability: log all throttling cases.
|
||||
if resp.StatusCode == http.StatusTooManyRequests {
|
||||
logger.Ctx(ctx).Infow("graph api throttling", "method", req.Method, "url", req.URL)
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusTooManyRequests && (resp.StatusCode/100) != 2 {
|
||||
} else if resp.StatusCode == http.StatusBadRequest {
|
||||
respDump, _ := httputil.DumpResponse(resp, true)
|
||||
logger.Ctx(ctx).Infow(
|
||||
"graph api error",
|
||||
"status", resp.Status,
|
||||
"method", req.Method,
|
||||
"url", req.URL,
|
||||
"response", string(respDump),
|
||||
)
|
||||
} else if resp.StatusCode/100 != 2 {
|
||||
logger.Ctx(ctx).Infow("graph api error", "status", resp.Status, "method", req.Method, "url", req.URL)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user