Skip to content

flask: close the transaction in the exception handler #635

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

Merged
merged 2 commits into from
Nov 14, 2019
Merged

Conversation

beniwohli
Copy link
Contributor

What does this pull request do?

The request_finished signal isn't sent if an unhandled exception
occurs, and other signals (e.g. request_teardown don't provide the
response object.

As a workaround, we close the transaction in the exception handler.
This requires us to move some logic into the request_started handler
to ensure it is run.

Unfortunately, this means we don't have any response context data,
as the response isn't created yet when the exception handler is called.

Why is it important?

So far, no transaction at all is captured when an error occurs. While
this solution isn't perfect, it gets us pretty close without having
to resort to wrapping/patching Flask APIs.

Related issues

closes #629

@beniwohli beniwohli marked this pull request as ready for review November 14, 2019 15:22
@beniwohli beniwohli requested a review from basepi November 14, 2019 15:23
The `request_finished` signal isn't sent if an unhandled exception
occurs, and other signals (e.g. `request_teardown` don't provide the
`response` object.

fixes #629
@basepi basepi merged commit 2cfba87 into master Nov 14, 2019
@beniwohli beniwohli deleted the fix-629 branch November 29, 2019 13:44
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.

Flask integration doesn't send transaction for unhandled errors
2 participants