-
Notifications
You must be signed in to change notification settings - Fork 509
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
Fix spans for streaming responses in WSGI based frameworks #3798
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found.
Additional details and impacted files@@ Coverage Diff @@
## master #3798 +/- ##
==========================================
+ Coverage 79.89% 79.94% +0.04%
==========================================
Files 137 137
Lines 15385 15424 +39
Branches 2611 2615 +4
==========================================
+ Hits 12292 12330 +38
- Misses 2222 2223 +1
Partials 871 871
|
…hed." This reverts commit 1fe8679.
…ntry/sentry-python into antonpirker/fix-streaming-response
…ntry/sentry-python into antonpirker/fix-streaming-response
32c40ed
to
c612326
Compare
15eb914
to
30d18fa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a couple of comments. As long as the tests for the various integrations that use the WSGI middleware are happy, I think this looks good.
transaction_duration = ( | ||
datetime.now(timezone.utc) - current_scope.transaction.start_timestamp | ||
).total_seconds() | ||
if transaction_duration > MAX_TRANSACTION_DURATION_SECONDS: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to check this here? Since this function can only get called when the timer fires this should always be the case
if timer is not None: | ||
timer.cancel() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we maybe always cancel the timer as the first step in this function without the conditional checks on lines 749-752?
What I'm worried might happen is that if we for some reason don't cancel the timer (because there is no transaction anymore for instance), it'll still fire the _finish_long_running_transaction
event at a later point and might potentially end up cancelling a different active transaction. IDK if that can realistically happen due to how we pass the scopes around, but probably doesn't hurt to be more cautious here.
Fixes spans in streaming responses in WSGI based frameworks. Only close the transaction once the response was consumed. This way all the spans created during creation of the response will be recorded with the transaction.
This PR makes sure that:
Fixes #3736