-
Notifications
You must be signed in to change notification settings - Fork 647
ref: Move HTTP client breadcrumbs to integrations (1) #7130
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
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 |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| from sentry_sdk.integrations import DidNotEnable, Integration | ||
| from sentry_sdk.scope import should_send_default_pii | ||
| from sentry_sdk.tracing_utils import ( | ||
| add_http_breadcrumb, | ||
| add_http_request_source, | ||
| has_span_streaming_enabled, | ||
| propagate_trace_headers, | ||
|
|
@@ -128,6 +129,21 @@ def send(self: "Client", request: "Request", **kwargs: "Any") -> "Response": | |
| with capture_internal_exceptions(): | ||
| add_http_request_source(span) | ||
|
|
||
| breadcrumb_data = { | ||
| SPANDATA.HTTP_METHOD: request.method, | ||
| SPANDATA.HTTP_STATUS_CODE: rv.status_code, | ||
| "reason": rv.reason_phrase, | ||
| } | ||
| if parsed_url: | ||
| breadcrumb_data.update( | ||
| { | ||
| "url": parsed_url.url, | ||
| SPANDATA.HTTP_QUERY: parsed_url.query, | ||
| SPANDATA.HTTP_FRAGMENT: parsed_url.fragment, | ||
| } | ||
| ) | ||
| add_http_breadcrumb(rv.status_code, breadcrumb_data) | ||
|
|
||
|
Comment on lines
+142
to
+146
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. Bug: In non-streaming mode, two identical breadcrumbs are created for each HTTP request: one by Suggested FixThe Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews.
Contributor
Author
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. The function will be removed in part 2 (#7131). I'll merge part 2 into this PR before merging into master. |
||
| return rv | ||
|
|
||
| Client.send = send # type: ignore | ||
|
|
@@ -220,6 +236,21 @@ async def send( | |
| with capture_internal_exceptions(): | ||
| add_http_request_source(span) | ||
|
|
||
| breadcrumb_data = { | ||
| SPANDATA.HTTP_METHOD: request.method, | ||
| SPANDATA.HTTP_STATUS_CODE: rv.status_code, | ||
| "reason": rv.reason_phrase, | ||
| } | ||
| if parsed_url: | ||
| breadcrumb_data.update( | ||
| { | ||
| "url": parsed_url.url, | ||
| SPANDATA.HTTP_QUERY: parsed_url.query, | ||
| SPANDATA.HTTP_FRAGMENT: parsed_url.fragment, | ||
| } | ||
| ) | ||
| add_http_breadcrumb(rv.status_code, breadcrumb_data) | ||
|
|
||
| return rv | ||
|
|
||
| AsyncClient.send = send # type: ignore | ||
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.
Breadcrumb skipped when no span is created
Medium Severity
In span streaming mode with no active parent span,
httpx,httpx2,aiohttpandboto3return early before reaching the new breadcrumb code, so no HTTP breadcrumb is recorded at all.pyreqwestplaces the call after the span context manager and does record one, making behaviour inconsistent and leaving breadcrumbs still coupled to span creation, which is what this change aims to remove.Additional Locations (2)
sentry_sdk/integrations/aiohttp.py#L507-L526sentry_sdk/integrations/boto3.py#L133-L139Reviewed by Cursor Bugbot for commit f6a9c0c. Configure here.