Skip to content

fix(performance): Fix INP spans not retrieving correct origin transaction name #12358

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

Closed
wants to merge 2 commits into from

Conversation

edwardgou-sentry
Copy link
Contributor

Adds a registerInpInteractionListener handler to browser tracing that caches an interactions to transaction name mapping (interactionIdToRouteNameMapping). This mapping allows us to fetch the correct origin transaction name that an INP occurred on, instead of looking for an active pageload/navigation span (which is inaccurate, and might not even exist at the time of INP).

This also reduces the chances that transaction will be undefined for INP spans, which mitigates this issue: getsentry/sentry#71435

Copy link
Contributor

github-actions bot commented Jun 5, 2024

size-limit report 📦

Path Size
@sentry/browser 21.74 KB (0%)
@sentry/browser (incl. Tracing) 32.97 KB (+0.62% 🔺)
@sentry/browser (incl. Tracing, Replay) 68.57 KB (+0.34% 🔺)
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 61.88 KB (+0.37% 🔺)
@sentry/browser (incl. Tracing, Replay with Canvas) 72.63 KB (+0.32% 🔺)
@sentry/browser (incl. Tracing, Replay, Feedback) 84.74 KB (+0.28% 🔺)
@sentry/browser (incl. Tracing, Replay, Feedback, metrics) 86.59 KB (+0.27% 🔺)
@sentry/browser (incl. metrics) 25.92 KB (0%)
@sentry/browser (incl. Feedback) 37.89 KB (0%)
@sentry/browser (incl. sendFeedback) 26.32 KB (0%)
@sentry/browser (incl. FeedbackAsync) 30.86 KB (0%)
@sentry/react 24.51 KB (0%)
@sentry/react (incl. Tracing) 36.01 KB (+0.57% 🔺)
@sentry/vue 25.73 KB (0%)
@sentry/vue (incl. Tracing) 34.81 KB (+0.6% 🔺)
@sentry/svelte 21.87 KB (0%)
CDN Bundle 23.11 KB (0%)
CDN Bundle (incl. Tracing) 34.72 KB (+0.62% 🔺)
CDN Bundle (incl. Tracing, Replay) 68.66 KB (+0.34% 🔺)
CDN Bundle (incl. Tracing, Replay, Feedback) 73.84 KB (+0.32% 🔺)
CDN Bundle - uncompressed 68 KB (0%)
CDN Bundle (incl. Tracing) - uncompressed 102.87 KB (+0.68% 🔺)
CDN Bundle (incl. Tracing, Replay) - uncompressed 212.76 KB (+0.33% 🔺)
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 225.22 KB (+0.31% 🔺)
@sentry/nextjs (client) 35.37 KB (+0.62% 🔺)
@sentry/sveltekit (client) 33.61 KB (+0.62% 🔺)
@sentry/node 115.24 KB (0%)
@sentry/node - without tracing 94.55 KB (0%)
@sentry/aws-serverless 103.72 KB (-0.01% 🔽)

@edwardgou-sentry
Copy link
Contributor Author

might have to figure out how to reduce bundle size on this one, or raise the threshold

mydea added a commit that referenced this pull request Jun 5, 2024
Instead of #12358, this is a simpler change which ensures we pick the transaction from the scope instead.

I also added tests for the various different scenarios, to ensure we see how they behave:

1. INP is emitted _during_ pageload (span is active)
2. INP is emitted _after_ pageload
a. Pageload is parametrized (route)
b. Pageload is unparametrized (URL)
Copy link
Member

@mydea mydea left a comment

Choose a reason for hiding this comment

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

I would prefer if we could instead do something like #12372, which is much simpler and should be good enough for the vast majority of cases I believe...? This change is pretty complex, subject to leak memory and increases bundle size, which is not ideal 😬

If @edwardgou-sentry you think the other PR is not sufficient here, let's connect on what other things we could explore to improve this!

@edwardgou-sentry
Copy link
Contributor Author

I would prefer if we could instead do something like #12372, which is much simpler and should be good enough for the vast majority of cases I believe...? This change is pretty complex, subject to leak memory and increases bundle size, which is not ideal 😬

If @edwardgou-sentry you think the other PR is not sufficient here, let's connect on what other things we could explore to improve this!

👍 left a comment in the other pr!

mydea added a commit that referenced this pull request Jun 6, 2024
Instead of #12358, this is a simpler change which ensures we pick the transaction from the scope instead.

I also added tests for the various different scenarios, to ensure we see how they behave:

1. INP is emitted _during_ pageload (span is active)
2. INP is emitted _after_ pageload
a. Pageload is parametrized (route)
b. Pageload is unparametrized (URL)
mydea added a commit that referenced this pull request Jun 6, 2024
Instead of #12358, this is a simpler change which ensures we pick the transaction from the scope instead.

I also added tests for the various different scenarios, to ensure we see how they behave:

1. INP is emitted _during_ pageload (span is active)
2. INP is emitted _after_ pageload
a. Pageload is parametrized (route)
b. Pageload is unparametrized (URL)
@edwardgou-sentry
Copy link
Contributor Author

Closing this PR in favour of #12372

mydea added a commit that referenced this pull request Jun 6, 2024
Instead of #12358, this is a simpler change which ensures we pick the transaction from the scope instead.

I also added tests for the various different scenarios, to ensure we see how they behave:

1. INP is emitted _during_ pageload (span is active)
2. INP is emitted _after_ pageload
a. Pageload is parametrized (route)
b. Pageload is unparametrized (URL)
mydea added a commit that referenced this pull request Jun 7, 2024
Instead of #12358, this is a simpler change which ensures we pick the transaction from the scope instead.

I also added tests for the various different scenarios, to ensure we see how they behave:

1. INP is emitted _during_ pageload (span is active)
2. INP is emitted _after_ pageload
a. Pageload is parametrized (route)
b. Pageload is unparametrized (URL)
mydea added a commit that referenced this pull request Jun 7, 2024
Instead of #12358, this is a simpler change which ensures we pick the transaction from the scope instead.

I also added tests for the various different scenarios, to ensure we see how they behave:

1. INP is emitted _during_ pageload (span is active)
2. INP is emitted _after_ pageload
a. Pageload is parametrized (route)
b. Pageload is unparametrized (URL)
mydea added a commit that referenced this pull request Jun 7, 2024
Instead of #12358,
this is a simpler change which ensures we pick the transaction from the
scope instead.

I also added tests for the various different scenarios, to ensure we see
how they behave:

1. INP is emitted _during_ pageload (span is active)
2. INP is emitted _after_ pageload

a. Pageload is parametrized (route)
b. Pageload is unparametrized (URL)

When the pageload is unparametrized (default browser SDK), the
transaction is not added to the DSC envelope header (which is correct
and also what we do in other places). it is _always_ added to the span
attributes now, though. If no span is active, it will use
transactionName from the last active pageload/navigation span.

There may be edge cases where this is not 100% correct (e.g. if the INP
span is only emitted once the pageload is done but another navigation
already started) but IMHO these are more edge cases and this change is
probably fine for now..?

(While at it, I also added an origin to the INP spans)
billyvg pushed a commit that referenced this pull request Jun 10, 2024
Instead of #12358,
this is a simpler change which ensures we pick the transaction from the
scope instead.

I also added tests for the various different scenarios, to ensure we see
how they behave:

1. INP is emitted _during_ pageload (span is active)
2. INP is emitted _after_ pageload

a. Pageload is parametrized (route)
b. Pageload is unparametrized (URL)

When the pageload is unparametrized (default browser SDK), the
transaction is not added to the DSC envelope header (which is correct
and also what we do in other places). it is _always_ added to the span
attributes now, though. If no span is active, it will use
transactionName from the last active pageload/navigation span.

There may be edge cases where this is not 100% correct (e.g. if the INP
span is only emitted once the pageload is done but another navigation
already started) but IMHO these are more edge cases and this change is
probably fine for now..?

(While at it, I also added an origin to the INP spans)
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.

2 participants