Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

middleware: add a way to stop errors being logged #293

Closed
wants to merge 3 commits into from

Conversation

bboreham
Copy link
Collaborator

E.g. if the error is caused by overload, then we don't want to log it because that uses more resource.

E.g. if the error is caused by overload, then we don't want to log it
because that uses more resource.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
@bboreham bboreham marked this pull request as draft July 20, 2023 08:04
@bboreham
Copy link
Collaborator Author

Moved to draft because I would like to get more agreement how this should be implemented.
grafana/mimir#5494 (review)

@@ -83,6 +91,9 @@ func (l Log) Wrap(next http.Handler) http.Handler {
statusCode, writeErr := wrapped.getStatusCode(), wrapped.getWriteError()

if writeErr != nil {
if errors.Is(writeErr, DoNotLogError{}) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't right: the writeError is an error from Write(), not the underlying operation error.

Patterned after the one for http logging.
@bboreham
Copy link
Collaborator Author

bboreham commented Aug 1, 2023

Replaced by #299

@bboreham bboreham closed this Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant