-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(react-router): Add otel instrumentation for server requests #16147
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: develop
Are you sure you want to change the base?
Conversation
|
|
||
// Set the source and overwrite attributes on the root span to ensure the transaction name | ||
// is derived from the raw URL pathname rather than any parameterized route that may be set later | ||
// TODO: try to set derived parameterized route from build here (args[0]) |
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.
want to ship this in a follow-up
...2e-tests/test-applications/react-router-7-framework/app/routes/performance/dynamic-param.tsx
Show resolved
Hide resolved
get(target, prop, receiver) { | ||
if (prop === 'createRequestHandler') { | ||
const original = target[prop]; | ||
return function wrappedCreateRequestHandler(this: unknown, ...args: unknown[]) { |
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.
return function wrappedCreateRequestHandler(this: unknown, ...args: unknown[]) { | |
return function sentryWrappedCreateRequestHandler(this: unknown, ...args: unknown[]) { |
l: Can we prefix this with sentry? :)
return function wrappedCreateRequestHandler(this: unknown, ...args: unknown[]) { | ||
const originalRequestHandler = original.apply(this, args); | ||
|
||
return async function wrappedRequestHandler(request: Request, initialContext?: unknown) { |
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.
return async function wrappedRequestHandler(request: Request, initialContext?: unknown) { | |
return async function sentryWrappedRequestHandler(request: Request, initialContext?: unknown) { |
l: and this one too
overwrite | ||
) { | ||
event.transaction = overwrite; | ||
delete event.contexts?.trace?.data?.[SEMANTIC_ATTRIBUTE_SENTRY_OVERWRITE]; |
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: Can this attribute end up on transactions that don't match all those conditions above and thus won't be deleted? Does that matter? I'm wondering if we should just always delete at the end of the processor.
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.
Good call
This PR adds OpenTelemetry instrumentation for server-side requests in React Router by tracing server requests for data loaders and actions.