Skip to content

ref(o11y): Remove redundant span status assignment#759

Merged
alexander-alderman-webb merged 14 commits into
mainfrom
webb/remove-explicit-status
Jul 23, 2026
Merged

ref(o11y): Remove redundant span status assignment#759
alexander-alderman-webb merged 14 commits into
mainfrom
webb/remove-explicit-status

Conversation

@alexander-alderman-webb

@alexander-alderman-webb alexander-alderman-webb commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

The with sentry_sdk.start_transaction() and with sentry_sdk.start_span() context managers set the span status to internal_error when they exit with an exception. Explicitly catching Exception and setting the status is therefore redundant (since the except: block re-raised within the context manager's scope).

Changed so that we do not add complexity when branching for span streaming.

@alexander-alderman-webb
alexander-alderman-webb marked this pull request as ready for review July 21, 2026 13:19
@alexander-alderman-webb
alexander-alderman-webb requested a review from a team as a code owner July 21, 2026 13:19

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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 1 potential issue.

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 43ec0e3. Configure here.

Comment thread clients/python/src/taskbroker_client/worker/workerchild.py
Comment thread clients/python/src/taskbroker_client/worker/workerchild.py

@markstory markstory left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Makes sense to me.

task_func(*args, **kwargs)
transaction.set_status(SPANSTATUS.OK)
except Exception:
transaction.set_status(SPANSTATUS.INTERNAL_ERROR)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Where is this being set in the new code? Does the sdk do this automatically?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's in the SDK. It's set in Span.__exit__() (or StreamedSpan.__exit__()) in the SDK (invoked when the context manager exits). The link to the former is below.

https://github.com/getsentry/sentry-python/blob/3a50950e632d9923f45a9b6fb18d89e1f27badad/sentry_sdk/tracing.py#L395

@alexander-alderman-webb
alexander-alderman-webb changed the base branch from webb/add-init-to-tests to main July 22, 2026 14:31
@alexander-alderman-webb
alexander-alderman-webb merged commit b693908 into main Jul 23, 2026
30 checks passed
@alexander-alderman-webb
alexander-alderman-webb deleted the webb/remove-explicit-status branch July 23, 2026 13:21
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.

3 participants