-
Notifications
You must be signed in to change notification settings - Fork 619
feat(bottle): Add span streaming support to Bottle integration #6486
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
Changes from all commits
30649d5
4d7da81
0d92dd7
472eadb
decefd3
5753f41
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,9 @@ | |
| ) | ||
| from sentry_sdk.integrations._wsgi_common import RequestExtractor | ||
| from sentry_sdk.integrations.wsgi import SentryWsgiMiddleware | ||
| from sentry_sdk.tracing import SOURCE_FOR_STYLE | ||
| from sentry_sdk.traces import SOURCE_FOR_STYLE as SEGMENT_SOURCE_FOR_STYLE | ||
| from sentry_sdk.tracing import SOURCE_FOR_STYLE as TRANSACTION_SOURCE_FOR_STYLE | ||
| from sentry_sdk.tracing_utils import has_span_streaming_enabled | ||
| from sentry_sdk.utils import ( | ||
| capture_internal_exceptions, | ||
| ensure_integration_enabled, | ||
|
|
@@ -102,6 +104,11 @@ | |
| ) | ||
| res = old_handle(self, environ) | ||
|
|
||
| if has_span_streaming_enabled(sentry_sdk.get_client().options): | ||
| _set_segment_name_and_source( | ||
| transaction_style=integration.transaction_style | ||
| ) | ||
|
Check warning on line 110 in sentry_sdk/integrations/bottle.py
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Post-handle naming can fail requestsMedium Severity After a successful Additional Locations (1)Reviewed by Cursor Bugbot for commit 5753f41. Configure here. |
||
|
|
||
| return res | ||
|
|
||
| Bottle._handle = _patched_handle | ||
|
|
@@ -163,6 +170,25 @@ | |
| return file.content_length | ||
|
|
||
|
|
||
| def _set_segment_name_and_source(transaction_style: str) -> None: | ||
| try: | ||
| if transaction_style == "url": | ||
| name = bottle_request.route.rule or "bottle request" | ||
| else: | ||
| name = ( | ||
| bottle_request.route.name | ||
| or transaction_from_function(bottle_request.route.callback) | ||
| or "bottle request" | ||
| ) | ||
|
|
||
| sentry_sdk.get_current_scope().set_transaction_name( | ||
| name, | ||
| source=SEGMENT_SOURCE_FOR_STYLE[transaction_style], | ||
| ) | ||
| except RuntimeError: | ||
|
Check warning on line 188 in sentry_sdk/integrations/bottle.py
|
||
| pass | ||
|
|
||
|
|
||
| def _set_transaction_name_and_source( | ||
| event: "Event", transaction_style: str, request: "Any" | ||
| ) -> None: | ||
|
|
@@ -185,7 +211,9 @@ | |
| pass | ||
|
|
||
| event["transaction"] = name | ||
| event["transaction_info"] = {"source": SOURCE_FOR_STYLE[transaction_style]} | ||
| event["transaction_info"] = { | ||
| "source": TRANSACTION_SOURCE_FOR_STYLE[transaction_style] | ||
| } | ||
|
|
||
|
|
||
| def _make_request_event_processor( | ||
|
|
||


Uh oh!
There was an error while loading. Please reload this page.