-
Notifications
You must be signed in to change notification settings - Fork 510
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
Enable configuration of reported status codes for FastAPI/Starlette HTTPExceptions #2825
Comments
Hey @PeterBaker0 thanks for writing in. The Http status codes in the 4xx range are client side errors, this is why we do not sent them to Sentry. They should be captured and sent by the client of the FastAPI api. |
I'm interested in 4xx client-side errors being reported in sentry (in my case in Django) and I've seen this response a few times, but yet I also see the exact set of options I desire in the Sentry docs for ASP.Net Core: https://docs.sentry.io/platforms/dotnet/guides/aspnetcore/configuration/http-client-errors/ Can you help me understand why there is a difference? |
Good catch @syserr0r I kind of get the logic @antonpirker - that's why defaults are provided - but not everything fits into a neat box. I'm sure there are use cases where the client application isn't wanting to setup/use sentry reporting e.g. programmatic/headless clients? I think it's good to have the options - especially considering there is precedent in other clients as @syserr0r mentioned. For example, what if you wanted to log all 401 errors in your API for security auditing purposes? A malicious client wouldn't nicely call the sentry API for you to report the error. |
Hey @PeterBaker0 and @syserr0r, thanks for bringing up the good points. It looks like this is a feature we should be supporting per our Develop documentation, so we will place this issue on our backlog. Thanks for reporting! |
Thanks @sentrivana !! |
Does this need to be raised for every integration (i.e. do I need to raise an issue for the Django implementation of this fix)? |
Problem Statement
When instrumenting a FastAPI application with Sentry, I want to be able to configure the status codes for which a HTTPException is reported to Sentry, so that I can control what kinds of errors are reported in sentry in a way which makes sense in my application.
Solution Brainstorm
The code which informs the status code filtering appears to be here
sentry-python/sentry_sdk/integrations/starlette.py
Line 216 in 16d25e2
I don't know enough about the sentry SDK/integration architecture to understand where/how/if integration specific config can be injected to this context.
I'd assume that if this is possible, it would be an easy addition.
A (rough) interface like so might be helpful:
The text was updated successfully, but these errors were encountered: