You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The common case in Pyramid is to handle exception with tweens that seat atop of main Pyramid handling function. With a current integration approach each exception occurring in main function goes to sentry. Is there a way to track just those errors that were not handled in tweens?
As far as I can tell tweens are just like errorhandlers in Flask. In Flask, we have the following behavior:
If you register an errorhandler for the exception (@app.errorhandler(Exception)), it will swallow the exception and it will not report to Sentry
If you register an errorhandler for a status code (@app.errorhandler(500)), we consider the errorhandler to be just a "pretty error page" and still report the error to sentry.
I wonder if we can figure out a rule like that for Pyramid too. I only had a look at exception views and was not sure if there is a way to distinguish those two cases, so I opted for what I felt was "safer", which is reporting to sentry
I wonder if we can figure out a rule like that for Pyramid too. I only had a look at exception views and was not sure if there is a way to distinguish those two cases, so I opted for what I felt was "safer", which is reporting to sentry
We're seeing a similar issue where exception views for 4xx exceptions are now being sent to Sentry, e.g.:
Or maybe making the Router.handle_request portion of the Pyramid integration optional, so we can explicitly log to Sentry in our exception handling views. 😕
@rouge8 current Pyramid integration lives inside a main handler but I think it should be placed above pyramid.tweens.excview_tween_factory. In that case you don't need to record exceptions in exception views explicitly.
@drnextgis I don't want to make the user explicitly wire up the pyramid integration. I don't understand your suggestion in the sense that I don't know how it would affect behavior. We still have the problem that we don't know which exceptions are "handled" and which are "suppressed".
To be clear, I am worried about a catch-all exception view:
@view_config(context=Exception)deffoo(...):
...
Is the intention to make a default 500 error page or to really suppress all exceptions? As far as i can tell pyramid_exclog behaves the exact same way as the Sentry integration:
Ignores HTTP exceptions
Logs everything, even if a matching exception view exists
Has separate config to ignore exception types (see link I posted at beginning of this thread)
(this is just what I read from the docs you linked)
The intent of catch-all exceptions views are to have a custom 500 error page that doesn't mismatch the design of the site and/or conforms to API error schemas.
When a pyramid user has defined any exception-based view, I think it's reasonable to expect them to do all error handling themselves, including error reporting.
This seems to be the only reasonable alternative at the moment. I'd rather not be carpet bombed with every single 4xx and 5xx error we raise as an exception and manually add them to Sentry filter lists. When we upgraded to the latest SDK our issues dashboard exploded with a lot of non-errors and is now even noisier than before.
It seems to me that sentry should only log unhandled exceptions that propagate out of the app. If people register exception views to deal with exceptions then it feels reasonable that they will sentry_sdk.capture_exception themselves if they wish. The simplest way to do this is monkeypatching just the router.__call__ if that's possible.
One quick question @goodspark, you don't see subtypes of HTTPException being reported to Sentry by any chance? That would be a hard bug as we intend to explicitly ignore those.
Activity
untitaker commentedon Mar 25, 2019
As a quick fix you can ignore errors by class with https://docs.sentry.io/error-reporting/configuration/filtering/?platform=python#before-send
As far as I can tell tweens are just like errorhandlers in Flask. In Flask, we have the following behavior:
@app.errorhandler(Exception)), it will swallow the exception and it will not report to Sentry@app.errorhandler(500)), we consider the errorhandler to be just a "pretty error page" and still report the error to sentry.I wonder if we can figure out a rule like that for Pyramid too. I only had a look at exception views and was not sure if there is a way to distinguish those two cases, so I opted for what I felt was "safer", which is reporting to sentry
rouge8 commentedon Mar 26, 2019
We're seeing a similar issue where exception views for 4xx exceptions are now being sent to Sentry, e.g.:
It looks like the current Pyramid integration is recording the exception before the handler is even called. 😞
drnextgis commentedon Mar 27, 2019
@untitaker what do you think about implementing Pyramid integration as a tween in a same way it is done for pyramid_exclog?
rouge8 commentedon Mar 27, 2019
Or maybe making the
Router.handle_requestportion of the Pyramid integration optional, so we can explicitly log to Sentry in our exception handling views. 😕drnextgis commentedon Mar 27, 2019
@rouge8 current Pyramid integration lives inside a main handler but I think it should be placed above
pyramid.tweens.excview_tween_factory. In that case you don't need to record exceptions in exception views explicitly.untitaker commentedon Mar 27, 2019
@drnextgis I don't want to make the user explicitly wire up the pyramid integration. I don't understand your suggestion in the sense that I don't know how it would affect behavior. We still have the problem that we don't know which exceptions are "handled" and which are "suppressed".
To be clear, I am worried about a catch-all exception view:
Is the intention to make a default 500 error page or to really suppress all exceptions? As far as i can tell
pyramid_exclogbehaves the exact same way as the Sentry integration:(this is just what I read from the docs you linked)
goodspark commentedon Apr 1, 2019
The intent of catch-all exceptions views are to have a custom 500 error page that doesn't mismatch the design of the site and/or conforms to API error schemas.
When a pyramid user has defined any exception-based view, I think it's reasonable to expect them to do all error handling themselves, including error reporting.
This seems to be the only reasonable alternative at the moment. I'd rather not be carpet bombed with every single 4xx and 5xx error we raise as an exception and manually add them to Sentry filter lists. When we upgraded to the latest SDK our issues dashboard exploded with a lot of non-errors and is now even noisier than before.
mmerickel commentedon May 30, 2019
It seems to me that sentry should only log unhandled exceptions that propagate out of the app. If people register exception views to deal with exceptions then it feels reasonable that they will
sentry_sdk.capture_exceptionthemselves if they wish. The simplest way to do this is monkeypatching just therouter.__call__if that's possible.untitaker commentedon May 31, 2019
I'll change this behavior to what you all suggested in 0.9.0
untitaker commentedon May 31, 2019
One quick question @goodspark, you don't see subtypes of
HTTPExceptionbeing reported to Sentry by any chance? That would be a hard bug as we intend to explicitly ignore those.untitaker commentedon May 31, 2019
What do you think about this behavior: Capture exception if there's no errorhandler, or if the errorhandler returned a response with status code 500
rouge8 commentedon May 31, 2019
That makes sense to me.
untitaker commentedon Jun 1, 2019
Thanks for your patience, I'll release 0.9.0 next week.
untitaker commentedon Jun 3, 2019
0.9.0 is released
drnextgis commentedon Jun 18, 2019
Thanks! But amongst other test I'd like to have the following one (in
test_pyramid.py):untitaker commentedon Jun 18, 2019
ok, I'll add that.
test(pyramid): Add test as requested in #303