Skip to content

feat(react-router): Export wrappers for server loaders and actions #16481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 5, 2025

Conversation

chargome
Copy link
Member

@chargome chargome commented Jun 4, 2025

This PR exports two new functions for wrapping server actions and loaders: wrapServerAction + wrapServerLoader.
Since #16327 is blocking our automatic instrumentation, these two wrappers can be used to selectively trace actions and loaders on the server.

I have also added a new e2e that basically tests the existing functionality without the ReactRouterServer integration, but using manual wrappers instead.

@chargome chargome requested a review from RulaKhaled June 4, 2025 11:25
@chargome chargome self-assigned this Jun 4, 2025
@chargome chargome requested review from Lms24 and s1gr1d June 4, 2025 12:02
Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

Thanks for taking care of this! Had two questions but both shouldn't block merging this, so approving.

Comment on lines 53 to 57
root.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OVERWRITE, args.request.url);
root.setAttributes({
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',
[SEMANTIC_ATTRIBUTE_SENTRY_OVERWRITE]: `${args.request.method} ${pathname}`,
});
Copy link
Member

Choose a reason for hiding this comment

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

2 questions:

  • have you tried using the updateSpanName helper instead of the overwrite attribute? Not sure if 1:1 the same just noticed that we have a similar pattern in the SDK already.
  • I guess there's no way right now to get a parameterized route from the arguments or some other available context?

Copy link
Member Author

Choose a reason for hiding this comment

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

  1. Yes, the overriding happens quite late, the SEMANTIC_ATTRIBUTE_SENTRY_OVERWRITE attribute was the only one working consistently
  2. Not ootb but we can figure this out in a follow up PR, as we have access to the manifest :)

@chargome chargome merged commit cfa8d41 into develop Jun 5, 2025
163 checks passed
@chargome chargome deleted the cg-rr-wrappers branch June 5, 2025 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants