Skip to content

fix(sdk-crash): Add Trace ID#117372

Merged
thetruecpaul merged 1 commit into
masterfrom
cpaul/061026/add_trace_sdk_crash
Jun 10, 2026
Merged

fix(sdk-crash): Add Trace ID#117372
thetruecpaul merged 1 commit into
masterfrom
cpaul/061026/add_trace_sdk_crash

Conversation

@thetruecpaul

Copy link
Copy Markdown
Contributor

We strip SDK crash errors in postprocess. This strips out their Trace ID; we need Trace IDs to store errors in EAP.

This PR adds a new Trace ID to these errors.

@thetruecpaul thetruecpaul requested review from a team and cleptric June 10, 2026 20:52
@thetruecpaul thetruecpaul requested a review from a team as a code owner June 10, 2026 20:52
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Jun 10, 2026
Comment on lines +134 to +136
value={
"trace_id": uuid4().hex,
"span_id": None,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bug: The code generates a trace_id but sets span_id to None, which is inconsistent and may cause issues in downstream systems that expect a valid span_id.
Severity: MEDIUM

Suggested Fix

Generate a valid span_id in addition to the trace_id. Instead of setting span_id to None, create a 16-character hex string, for example: "span_id": uuid4().hex[:16]. This ensures the trace context is complete and consistent.

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: src/sentry/utils/sdk_crashes/sdk_crash_detection.py#L134-L136

Potential issue: The code adds a trace context to SDK crash events by generating a
`trace_id` but explicitly sets the corresponding `span_id` to `None`. While the event
schema allows a null `span_id`, this is inconsistent with other parts of the codebase
where a valid hex `span_id` is always generated alongside a `trace_id`. This could cause
issues for downstream consumers like the EAP system, which may expect both a valid
`trace_id` and `span_id` to be present for tracing. A trace context with a valid trace
ID but a null span ID is semantically unusual and may be rejected by tracing
infrastructure.

Did we get this right? 👍 / 👎 to inform future reviews.

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.

Maybe it makes sense to fix this in the event manager. I imagine there could be more places that create an event that could lack a trace ID.

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.

We handle most of them in Relay — this appears to be unique among error-type occurrences in that it strips that relay-set default in postprocess. (Confirmed by looking at logs re: which projects are missing trace ID — only related to this case, it seems.)

Might be worth adding there as another backstop if this doesn't work, though.

We strip SDK crash errors in postprocess. This strips out their Trace ID; we need Trace IDs to store errors in EAP.

This PR adds a new Trace ID to these errors.
@thetruecpaul thetruecpaul force-pushed the cpaul/061026/add_trace_sdk_crash branch from 932b611 to d2d1d25 Compare June 10, 2026 21:10
@thetruecpaul thetruecpaul merged commit 6d9fc01 into master Jun 10, 2026
64 checks passed
@thetruecpaul thetruecpaul deleted the cpaul/061026/add_trace_sdk_crash branch June 10, 2026 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants