Skip to content

feat(tracing): Add debug endpoint for raw trace item response#116127

Closed
mjq wants to merge 2 commits into
masterfrom
mjq/span-json-debug-button
Closed

feat(tracing): Add debug endpoint for raw trace item response#116127
mjq wants to merge 2 commits into
masterfrom
mjq/span-json-debug-button

Conversation

@mjq
Copy link
Copy Markdown
Member

@mjq mjq commented May 25, 2026

In general, but especially during our span streaming rollout, it's useful for debugging to be able to see the underlying data for a particular span before it is transformed by the Sentry API and frontend. This PR adds a superuser-only endpoint that returns the raw result from EAP's TraceItemDetails RPC.

This will be hooked up to a superuser-only button on the span details pane in the trace waterfall, similar to how we have the link to see raw transaction JSON for transactions (except the audience for this will be superusers only).


🤖: Claude Code (Opus 4.6) used to generate the code, with human editing + review. All words my own.

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label May 25, 2026
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label May 25, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🚨 Warning: This pull request contains Frontend and Backend changes!

It's discouraged to make changes to Sentry's Frontend and Backend in a single pull request. The Frontend and Backend are not atomically deployed. If the changes are interdependent of each other, they must be separated into two pull requests and be made forward or backwards compatible, such that the Backend or Frontend can be safely deployed independently.

Have questions? Please ask in the #discuss-dev-infra channel.

cursor[bot]

This comment was marked as resolved.

@github-actions
Copy link
Copy Markdown
Contributor

📊 Type Coverage Diff

✅ No new type safety issues introduced. Coverage: 93.58%

@mjq mjq marked this pull request as ready for review May 25, 2026 15:18
@mjq mjq requested review from a team as code owners May 25, 2026 15:18
@getsentry getsentry deleted a comment from github-actions Bot May 25, 2026
@staticmethod
def get(request: Request, project: Project, item_id: str) -> Response:
"""
Like ProjectTraceItemDetailsEndpoint, but returns the raw
Copy link
Copy Markdown
Contributor

@adrianviquez adrianviquez May 25, 2026

Choose a reason for hiding this comment

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

Looking at the logic in the ProjectTraceItemDetailsEndpoint, is the logic bw the that and this endpoint meant to be the same long term? If so, would it make sense extract the logic of each get endpoint into a helper? Smth like

def _build_trace_item_details_request(...):
  serializer = ProjectTraceItemDetailsEndpointSerializer(data=request.GET)
  ...
  return TraceItemDetailsRequest(...)

# ProjectTraceItemDetailsEndpoint endpoint
def get(...):
    req = _build_trace_item_details_request(...)
    resp = MessageToDict(snuba_rpc.trace_item_details_rpc(req))
    ...
    return Response(resp)

# ProjectTraceItemDetailsRawEndpoint endpoint
def get(...):
    if not superuser_has_permission(request):
        return Response(status=403)
    req = _build_trace_item_details_request(...)
    resp = MessageToDict(snuba_rpc.trace_item_details_rpc(req))
    return Response(resp)

?

Then the tests could for the most part apply to 1 common fn instead too

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

👍 @wmak suggested an alternative which is to add a debug param to the existing endpoint rather than making a new one, which is something I just learned we already do in other RPC-calling endpoints so it's an established pattern. Going to do that instead! But good call here anyway.

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 Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants