feat: Add Python span streaming migration skill#156
Conversation
String matching in ignoreSpans uses substring includes, not glob patterns. The `*` was treated as a literal character. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Reorganize the skill so each SDK (JavaScript, Python) has its own self-contained top-level section with the full detect-migrate-verify flow, instead of mixing SDK-specific content under shared phase headings. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Covers the full migration flow: enabling span streaming, migrating start_span/start_transaction/start_child/@trace/get_current_span, span data (set_data/set_tag/set_context to set_attribute), trace propagation (continue_trace, new_trace), sampling, ignore_spans, before_send_span, verification, and quick reference checklist. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 494c651. Configure here.
Each skill is now self-contained with its own intro, detection, migration steps, verification, and checklist. The old combined sentry-span-streaming skill is removed; the parent router and skill tree now point to both new skills directly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Users importing Span or Transaction directly from sentry_sdk.tracing need to replace both with StreamedSpan from sentry_sdk.traces. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Encourage agents to launch subagents for independent migration tasks when the codebase has many files to migrate. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…butes in span streaming In streaming mode, ignore_spans and before_send_span can only access attributes set at span start. Logic depending on late-set attributes (e.g. HTTP status codes) cannot be replicated and must be removed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…igration patterns Add migration guidance for uncommon patterns: scope-based span/transaction access and get_trace_context. Includes detection greps, before/after examples, common issues, and checklist items. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…et_attributes Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
|
||
| def traces_sampler(sampling_context): | ||
| if sampling_context["asgi_scope"].method not in ("GET", "POST"): | ||
| return 0.0 |
There was a problem hiding this comment.
Bug: The example code for traces_sampler incorrectly uses attribute access (.method) on the asgi_scope dictionary, which will cause a runtime AttributeError.
Severity: HIGH
Suggested Fix
Update the example code to use dictionary key access to retrieve the method from the asgi_scope. Change sampling_context["asgi_scope"].method to sampling_context["asgi_scope"]["method"].
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: skills/sentry-span-streaming-python/SKILL.md#L463
Potential issue: The example code for `traces_sampler` in the documentation demonstrates
accessing the `method` from `sampling_context["asgi_scope"]` using attribute notation
(`.method`). According to the ASGI specification, the scope is a dictionary, not an
object. Attempting to access a dictionary key with attribute notation will result in an
`AttributeError: 'dict' object has no attribute 'method'` at runtime. This will crash
the sampling logic for any developer who copies this example code into their
application.
| ... | ||
|
|
||
| # After | ||
| sentry_sdk.scope.Scope.set_custom_sampling_context({"asgi_scope": asgi_scope}) |
There was a problem hiding this comment.
Bug: The migration example calls sentry_sdk.scope.Scope.set_custom_sampling_context, which appears to be a non-existent class method, leading to a runtime error.
Severity: HIGH
Suggested Fix
Verify if the set_custom_sampling_context method exists and what its correct usage is. If it's an instance method, the example should show how to get a scope instance and call it. If it doesn't exist, the example should be corrected to use the proper API for setting custom sampling context, such as passing it to start_transaction.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: skills/sentry-span-streaming-python/SKILL.md#L474
Potential issue: The documentation provides a migration example that uses
`sentry_sdk.scope.Scope.set_custom_sampling_context(...)`. This method does not appear
to exist in the Sentry Python SDK's documented API. Furthermore, it is called as a class
method on `Scope`, whereas scope modifications are typically instance-level operations.
Developers following this migration guide will encounter a runtime `AttributeError`
because the method is not defined on the `Scope` class.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…bute Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
|
||
| headers = { | ||
| "sentry-trace": "4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-1", | ||
| "baggage": "sentry-trace_id=...", |
There was a problem hiding this comment.
Bug: The baggage header example is incomplete, showing only sentry-trace_id. This can break distributed tracing and sampling as it omits other required fields.
Severity: MEDIUM
Suggested Fix
Update the baggage header example to be more representative of a real-world header. Include other common fields to show that it's a multi-part value, for example: "baggage": "sentry-trace_id=...,sentry-environment=production,...". This provides a more accurate and less misleading example for users implementing trace propagation.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: skills/sentry-span-streaming-python/SKILL.md#L433
Potential issue: The code example for the `baggage` header in the `continue_trace`
section is incomplete. It only shows `"baggage": "sentry-trace_id=..."`. A real-world
`baggage` header contains multiple comma-separated key-value pairs (e.g.,
`sentry-environment`, `sentry-public_key`, `sentry-release`) which are essential for the
Dynamic Sampling Context (DSC). Users or AI agents copying this example would generate
incomplete headers, leading to broken trace continuity and incorrect sampling decisions
across distributed services. This is particularly problematic in a section meant to
guide users on migrating trace propagation.

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