Repository navigation
feat(test-anthropic): Migrate start_transaction to streamed spans - #104
Merged
Merged
Conversation
Neither start_transaction call passed op=, so setting sentry.op to the span name fabricates data that was not there before. Drop the attributes dict and let the spans carry only their name.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Converts the 2 live
sentry_sdk.start_transaction(...)calls intest-anthropictosentry_sdk.traces.start_span(...), since this project already runs withtrace_lifecycle="stream"andstart_transactionnow returns aNoOpSpanunder that mode.main_async.py:start_transaction(name="anthropic-async")→sentry_sdk.traces.start_span(name="anthropic-async", attributes={"sentry.op": "anthropic-async"})main_tool.py:start_transaction(name="anthropic-sync-tool")→sentry_sdk.traces.start_span(name="anthropic-sync-tool", attributes={"sentry.op": "anthropic-sync-tool"})Both files now also
import sentry_sdk.tracesexplicitly, since it is not re-exported fromsentry_sdk/__init__.py.main.py'sstart_transactioncall is commented out and was left untouched.Intentionally out of scope
The 4
@sentry_sdk.trace(...)decorators (main.py:10,main_async.py:11,main_tool.py:10,main_tool.py:31) were not converted. They usetemplate=SPANTEMPLATE.AI_AGENT/AI_TOOL, but the streaming decorator (sentry_sdk.traces.trace) only acceptsname/attributes/active— notemplateoropparameter — so converting them now would silently drop the AI span templates. This needs SDK support for a streaming-compatible span template before it can be migrated, and is left as a follow-up.Test plan
python -m py_compileonmain.py,main_async.py,main_tool.pygit diffconfirms no@sentry_sdk.traceline was touched