feat(python): Reintroduce Python span streaming docs - #18850
Conversation
This reverts commit ba13b79.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
| File | Line | Current Link | Should Be |
|---|---|---|---|
docs/platforms/python/tracing/configure-sampling/index.mdx |
607 | /platforms/python/configuration/sampling/#sampling-context |
/platforms/python/sampling/#sampling-context |
Each redirect hop loses ~15% of SEO link equity and adds latency for users.
Co-authored-by: Alex Krawiec <alex.krawiec@sentry.io>
| if span["attributes"].get(attribute): | ||
| span["attributes"][attribute] = "[Sanitized]" |
There was a problem hiding this comment.
Bug: The code directly accesses span["attributes"], but the attributes key is optional. This will cause a KeyError if a span without attributes is processed.
Severity: CRITICAL
Suggested Fix
Before accessing span["attributes"], add a defensive check to ensure the attributes key exists. If it doesn't, you can either return early or initialize it as an empty dictionary, for example: if "attributes" not in span: span["attributes"] = {}.
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: platform-includes/configuration/before-send-span/python.mdx#L10-L11
Potential issue: The code examples for the `before_send_span` callback access
`span["attributes"]` without first checking if the `attributes` key exists. According to
the SDK specification, the `attributes` key is optional. If a span without attributes is
processed by a user's callback implementing this example code, it will raise a
`KeyError: 'attributes'`, causing a runtime error in the user's application. This can
prevent spans from being processed correctly.
Also affects:
docs/platforms/python/tracing/streamed-spans/index.mdx:328~329
This reverts commit ba13b79.
We initially merged the streaming docs too early, so we had to revert. This PR reverts the revert and reintroduces the streaming docs again.
Changes on top:
_experimentsmentions as the options are now all top level (except forbefore_send_span, but we'll make a release with that before we merge this)DO NOT MERGE. We'll merge once ready.
IS YOUR CHANGE URGENT?
Help us prioritize incoming PRs by letting us know when the change needs to go live.
SLA
Thanks in advance for your help!
PRE-MERGE CHECKLIST
Make sure you've checked the following before merging your changes:
LEGAL BOILERPLATE
Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.
EXTRA RESOURCES