-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(nextjs): Mark clientside prefetch request spans with http.request.prefetch: true
attribute
#15980
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
feat(nextjs): Mark clientside prefetch request spans with http.request.prefetch: true
attribute
#15980
Changes from 2 commits
303369c
0cdb568
9c357f5
e11d453
62eba88
3eea48c
5ac833a
94588fd
d23e282
3f782ca
618efe7
f57e14c
c26c793
8addc76
cf111cc
1530703
0aeb77e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import type { Integration } from '@sentry/core'; | ||
import { SEMANTIC_ATTRIBUTE_SENTRY_OP } from '@sentry/core'; | ||
import { browserTracingIntegration as originalBrowserTracingIntegration } from '@sentry/react'; | ||
import { nextRouterInstrumentNavigation, nextRouterInstrumentPageLoad } from './routing/nextRoutingInstrumentation'; | ||
|
||
|
@@ -12,6 +13,16 @@ export function browserTracingIntegration( | |
...options, | ||
instrumentNavigation: false, | ||
instrumentPageLoad: false, | ||
onRequestSpanStart(...args) { | ||
const [span, { headers }] = args; | ||
|
||
// Next.js prefetch requests have a `next-router-prefetch` header | ||
if (headers?.get('next-router-prefetch')) { | ||
span?.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'http.client.prefetch'); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Q: Have we checked if this change plays well with the product? Specifically I'm thinking of the "Network Requests" insights module wondering if Also, might be worth adding the op to dev docs, wdyt? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very good point getsentry/sentry-docs#13239 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Based on an internal discussion we have agreed to instead add a |
||
|
||
return options.onRequestSpanStart?.(...args); | ||
}, | ||
}); | ||
|
||
const { instrumentPageLoad = true, instrumentNavigation = true } = options; | ||
|
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.
l: do we care about cases where users register their own
browserTracingIntegration()
? As in should we merge a possible custom implementation with our logic? Not sure what our general approach to this is so feel free to declare undefined behaviour :DThere 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.
I think user's would be always importing this
browserTracingIntegration
(the Next.js one) so the behavior should already be merged (see line 23). Unless I am misunderstanding.