-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(react-router): Add Instrumentation API guide #16171
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
base: master
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
612602d to
22bf82d
Compare
inventarSarah
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall! 👍
I added a few suggestions to make the writing more consistent
|
|
||
| </Alert> | ||
|
|
||
| React Router 7.9.5+ provides an [instrumentation API](https://reactrouter.com/how-to/instrumentation) that enables automatic span creation for loaders, actions, middleware, navigations, fetchers, lazy routes, and request handlers—without manual wrapper functions. Transaction names use parameterized route patterns (e.g., `/users/:id`), and errors are automatically captured with proper context. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
q: "Transaction names use parameterized route patterns" -> is this true for all transactions or specific ones?
| <SplitSection> | ||
| <SplitSectionText> | ||
|
|
||
| **Before** (manual wrappers): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| **Before** (manual wrappers): | |
| **Before migrating** (manual wrappers): |
| <SplitSection> | ||
| <SplitSectionText> | ||
|
|
||
| **After** (instrumentation API): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| **After** (instrumentation API): | |
| **After migrating** (instrumentation API): |
|
|
||
| </Alert> | ||
|
|
||
| React Router 7.9.5+ provides an [instrumentation API](https://reactrouter.com/how-to/instrumentation) that enables automatic span creation for loaders, actions, middleware, navigations, fetchers, lazy routes, and request handlers—without manual wrapper functions. Transaction names use parameterized route patterns (e.g., `/users/:id`), and errors are automatically captured with proper context. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| React Router 7.9.5+ provides an [instrumentation API](https://reactrouter.com/how-to/instrumentation) that enables automatic span creation for loaders, actions, middleware, navigations, fetchers, lazy routes, and request handlers—without manual wrapper functions. Transaction names use parameterized route patterns (e.g., `/users/:id`), and errors are automatically captured with proper context. | |
| React Router 7.9.5+ provides an [instrumentation API](https://reactrouter.com/how-to/instrumentation) that enables automatic span creation for loaders, actions, middleware, navigations, fetchers, lazy routes, and request handlers without the need for manual wrapper functions. Transaction names use parameterized route patterns, such as `/users/:id`, and errors are automatically captured with proper context. |
| Export `unstable_instrumentations` from your `entry.server.tsx` to enable automatic server-side tracing. | ||
|
|
||
| The `createSentryServerInstrumentation()` function instruments: | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to you to simplify this list?
It looks to me like a lot of repetition that adds little value.
For example:
The `createSentryServerInstrumentation()` function creates spans for:
- Request handlers (root HTTP server spans)
- Loaders
- Actions
- Middleware
- Lazy route loading
|
|
||
| **After** (instrumentation API): | ||
|
|
||
| Add the instrumentation export once in `entry.server.tsx`, and all loaders/actions are automatically traced. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Add the instrumentation export once in `entry.server.tsx`, and all loaders/actions are automatically traced. | |
| After adding the instrumentation export once in `entry.server.tsx`, all loaders and actions are traced automatically. |
|
|
||
| If you're not seeing spans for your loaders and actions: | ||
|
|
||
| 1. **Check React Router version**: The instrumentation API requires React Router 7.9.5 or later |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 1. **Check React Router version**: The instrumentation API requires React Router 7.9.5 or later | |
| 1. Check that the React Router version is 7.9.5 or later |
small updates to the list to make it consistent with the list in the second expandable
| If you're not seeing spans for your loaders and actions: | ||
|
|
||
| 1. **Check React Router version**: The instrumentation API requires React Router 7.9.5 or later | ||
| 2. **Verify the export**: Ensure `unstable_instrumentations` is exported from `entry.server.tsx` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 2. **Verify the export**: Ensure `unstable_instrumentations` is exported from `entry.server.tsx` | |
| 2. Make sure `unstable_instrumentations` is exported from `entry.server.tsx` |
|
|
||
| 1. **Check React Router version**: The instrumentation API requires React Router 7.9.5 or later | ||
| 2. **Verify the export**: Ensure `unstable_instrumentations` is exported from `entry.server.tsx` | ||
| 3. **Check sample rate**: Verify `tracesSampleRate` is set in your server configuration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 3. **Check sample rate**: Verify `tracesSampleRate` is set in your server configuration | |
| 3. Verify `tracesSampleRate` is set in your server configuration |
|
|
||
| 1. Update to the latest SDK version | ||
| 2. Check that the instrumentation export is correctly configured | ||
| 3. The manual wrappers (`wrapServerLoader`, `wrapServerAction`) will log a debug message when skipped |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 3. The manual wrappers (`wrapServerLoader`, `wrapServerAction`) will log a debug message when skipped | |
| 3. Verify that the manual wrappers (`wrapServerLoader`, `wrapServerAction`) log a debug message when skipped |
small update for consistency
DESCRIBE YOUR PR
Documents: getsentry/sentry-javascript#18580
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:
EXTRA RESOURCES