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

Record an exception as an error only when Plug.Exception.status/1 returns 500..599. #165

Merged
merged 2 commits into from
Jul 6, 2023

Conversation

derekkraan
Copy link
Contributor

It is encouraged in the Phoenix docs to use Plug.Exception with custom exceptions to generate for example 404 responses at certain places. These 404s should not be marked as error, since simple "route not found" 404s are also not marked as error.

@tsloughter
Copy link
Member

I'm good with this, it fits the spec. A little cautious about backwards compatibility, not that we can't change the default, just don't like changing things on people like this.

@bryannaegele are you good with this being merged as is?

@bryannaegele
Copy link
Collaborator

The spec part is right as far as the error goes but I think we'd still want to record the exception no matter what.

@derekkraan
Copy link
Contributor Author

So just not setting "error"? I could live with that.

@bryannaegele
Copy link
Collaborator

Right. And you don't need to do the status check. Endpoint stop will already take care of marking it errored when it's 500+. Just remove the set error line

returns 500..599.

It is encouraged in the Phoenix docs to use `Plug.Exception` with
custom exceptions to generate for example 404 responses at certain
places. These 404s should not be marked as error, since simple "route
not found" 404s are also not marked as error.
@derekkraan
Copy link
Contributor Author

Thanks for the feedback. This PR has become very small indeed. Should be good to go now.

@tsloughter tsloughter merged commit 7119c4b into open-telemetry:main Jul 6, 2023
@seantanly
Copy link

seantanly commented Jul 31, 2023

@derekkraan Thanks for the fix!
@tsloughter Any chance this improvement will be released soon?
The 4xx errors are not playing well with API SLO calculations.

Related: open-telemetry/opentelemetry-specification#1998

@yordis yordis mentioned this pull request Dec 12, 2023
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants