Skip to content

Conversation

alexander-alderman-webb
Copy link
Contributor

@alexander-alderman-webb alexander-alderman-webb commented Oct 9, 2025

Description

Add code source as described in getsentry/sentry-docs#15161.

Factors out functionality from SQL query source and tests that it works in the HTTP request setting.

Issues

Closes #4881

Reminders

@alexander-alderman-webb alexander-alderman-webb marked this pull request as ready for review October 9, 2025 12:33
@alexander-alderman-webb alexander-alderman-webb requested a review from a team as a code owner October 9, 2025 12:33
cursor[bot]

This comment was marked as outdated.

span.finish()

with capture_internal_exceptions():
add_http_request_source(span)
Copy link

Choose a reason for hiding this comment

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

Bug: Span Data Overwriting After Completion

The add_http_request_source call is placed after span.finish() in the finally block. Adding source information to an already finished span means this data might not be properly recorded, as finished spans are generally immutable.

Fix in Cursor Fix in Web

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I placed add_http_request_source(span) after the span is finished because you need the end timestamp to determine the delay in receiving a response to the HTTP request.

It's done analogously in asyncpg and sqlalchemy.

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.

Add code source for outgoing HTTP requests
1 participant