feat(bottle): Add span streaming support to Bottle integration#6486
feat(bottle): Add span streaming support to Bottle integration#6486ericapisani wants to merge 2 commits into
Conversation
Fixes PY-2310 Fixes #6008
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 30649d5. Configure here.
Codecov Results 📊✅ 88735 passed | ⏭️ 6007 skipped | Total: 94742 | Pass Rate: 93.66% | Execution Time: 296m 45s 📊 Comparison with Base Branch
All tests are passing successfully. ✅ Patch coverage is 93.33%. Project has 2333 uncovered lines. Files with missing lines (1)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 89.92% 89.92% —%
==========================================
Files 191 191 —
Lines 23115 23135 +20
Branches 7952 7960 +8
==========================================
+ Hits 20783 20802 +19
- Misses 2332 2333 +1
- Partials 1309 1308 -1Generated by Codecov Action |
| ): | ||
| _capture_exception(res, handled=True) | ||
| if has_span_streaming_enabled(sentry_sdk.get_client().options): | ||
| with sentry_sdk.traces.start_span(name="bottle"): |
There was a problem hiding this comment.
Why a new span here? Currently, the Bottle integration relies on the WSGI integration to create the main segment span and doesn't add any spans on top -- I'd keep the overall span architecture the same
| try: | ||
| if integration.transaction_style == "url": | ||
| name = bottle_request.route.rule or "bottle" | ||
| else: | ||
| name = ( | ||
| bottle_request.route.name | ||
| or transaction_from_function(bottle_request.route.callback) | ||
| or "bottle" | ||
| ) | ||
|
|
||
| sentry_sdk.get_current_scope().set_transaction_name( | ||
| name, | ||
| source=SEGMENT_SOURCE_FOR_STYLE[integration.transaction_style], | ||
| ) | ||
| except RuntimeError: | ||
| pass |
There was a problem hiding this comment.
I think this is a nice place for this logic 👍🏻
Couple questions/comments:
- Maybe
Bottle requestwould be a bit more specific since justbottledoesn't specify what kind of span it is. We typically create different types of spans in WSGI context (requests, middlewares etc.) so it'd help to narrow it down for nicer categorization in Sentry. - Nit, but maybe we can move this block to a helper func similar to
_set_transaction_name_and_source, maybe_set_segment_name_and_source?

Add span streaming support to Bottle integration.
Fixes PY-2310
Fixes #6008