Repository navigation
Log client error responses at warning level. - #12
Merged
Merged
Conversation
A 4xx response is a client mistake, such as a wrong password, a failed validation or an unknown resource, not a failure of the service. Logging it at error level flooded the alerts that watch that level. Responses in the 5xx range stay at error, and failure-only paths still log both 4xx and 5xx responses.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The middleware logged every response in the 4xx/5xx range at
errorlevel. A consumer therefore wrote every client mistake (a wrong password answered with 401, a validation failure answered with 422, an unknown resource answered with 404) as an error, which flooded the alerting and the error tracking that watch that level.The level of the
responseentry now follows the status code:error(as before)warning(waserror)info(as before)requestentry stays atinfo.Code::isErrorCode, 400 to 511), so paths set throughwithFailureOnlyPathsstill log both 4xx and 5xx responses. A 4xx response on such a path is now written atwarning, the same level any other path gets.Internal/LogResponse. The public API is untouched.LogMiddlewareBuilderandLogMiddlewaredocblocks speak of responses that are an error, never of a level, so they still hold and are unchanged.Release
Recommended release:
1.6.0(minor). The public API does not change, but the documented level of 4xx responses does, and a consumer whose alerting relied on 4xx entries aterrorstops receiving them. That is a visible change in behavior, not a bug fix, so it is not a patch.Related issue
None. The need came from consumers whose error alerting was flooded by client mistakes.
Checklist
info), 400 and 499 (warning), 500 (error), plus 200, 302, 401, 404, 422, 503 and 511. The 422 test now expectswarningand noerror. Failure-only paths are covered at 399 (nothing logged) and at 400, 404, 422, 499 (warning) and 500, 503 (error), and an unlisted path next to configured filters logs 422 atwarning.make reviewpasses.make testspasses: 84 tests, 148 assertions, 117 mutants, all killed, MSI 100%.