Skip to content

feat(bottle): Add span streaming support to Bottle integration#6486

Open
ericapisani wants to merge 2 commits into
masterfrom
py-2310-migrate-bottle
Open

feat(bottle): Add span streaming support to Bottle integration#6486
ericapisani wants to merge 2 commits into
masterfrom
py-2310-migrate-bottle

Conversation

@ericapisani
Copy link
Copy Markdown
Member

Add span streaming support to Bottle integration.

Fixes PY-2310
Fixes #6008

@ericapisani ericapisani requested a review from a team as a code owner June 2, 2026 18:49
@linear-code
Copy link
Copy Markdown

linear-code Bot commented Jun 2, 2026

PY-2310

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ 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.

Comment thread sentry_sdk/integrations/bottle.py Outdated
Comment thread sentry_sdk/integrations/bottle.py Outdated
Comment thread sentry_sdk/integrations/bottle.py Outdated
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

Codecov Results 📊

88735 passed | ⏭️ 6007 skipped | Total: 94742 | Pass Rate: 93.66% | Execution Time: 296m 45s

📊 Comparison with Base Branch

Metric Change
Total Tests 📈 +383
Passed Tests 📈 +383
Failed Tests
Skipped Tests

All tests are passing successfully.

✅ Patch coverage is 93.33%. Project has 2333 uncovered lines.
✅ Project coverage is 89.92%. Comparing base (base) to head (head).

Files with missing lines (1)
File Patch % Lines
sentry_sdk/integrations/bottle.py 93.33% ⚠️ 2 Missing
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        -1

Generated by Codecov Action

Comment thread sentry_sdk/integrations/bottle.py
):
_capture_exception(res, handled=True)
if has_span_streaming_enabled(sentry_sdk.get_client().options):
with sentry_sdk.traces.start_span(name="bottle"):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment on lines +109 to +124
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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a nice place for this logic 👍🏻

Couple questions/comments:

  • Maybe Bottle request would be a bit more specific since just bottle doesn'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?

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.

Migrate bottle to span first

2 participants