Skip to content
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

ref(browser): Improve active span handling for browserTracingIntegration #14959

Merged
merged 1 commit into from
Jan 10, 2025

Conversation

mydea
Copy link
Member

@mydea mydea commented Jan 9, 2025

Extracted this out of #14955

We used to rely on implied stuff here quite a bit, which breaks if we start returning non recording spans. Honestly this just surfaces that this is not really ideal as it is 😬 We already pass the client around there everywhere, so this PR updates this so we keep the active idle span as non-enumerable prop on the client, ensuring this is consistent and "pure".

@mydea mydea requested a review from Lms24 January 9, 2025 14:26
@mydea mydea self-assigned this Jan 9, 2025
@mydea mydea force-pushed the fn/browser-tracing-active-span branch from 6b99199 to 7547547 Compare January 9, 2025 14:32
Copy link
Contributor

github-actions bot commented Jan 9, 2025

size-limit report 📦

Path Size % Change Change
@sentry/browser 23.01 KB - -
@sentry/browser - with treeshaking flags 21.68 KB - -
@sentry/browser (incl. Tracing) 35.48 KB +0.08% +27 B 🔺
@sentry/browser (incl. Tracing, Replay) 72.26 KB +0.05% +31 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 62.77 KB +0.03% +18 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 76.52 KB +0.04% +28 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 88.54 KB +0.05% +39 B 🔺
@sentry/browser (incl. Feedback) 39.23 KB - -
@sentry/browser (incl. sendFeedback) 27.64 KB - -
@sentry/browser (incl. FeedbackAsync) 32.41 KB - -
@sentry/react 25.7 KB - -
@sentry/react (incl. Tracing) 38.24 KB +0.03% +11 B 🔺
@sentry/vue 27.15 KB - -
@sentry/vue (incl. Tracing) 37.28 KB +0.04% +14 B 🔺
@sentry/svelte 23.13 KB - -
CDN Bundle 24.28 KB - -
CDN Bundle (incl. Tracing) 35.76 KB +0.02% +7 B 🔺
CDN Bundle (incl. Tracing, Replay) 70.41 KB -0.01% -5 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback) 75.56 KB +0.01% +5 B 🔺
CDN Bundle - uncompressed 70.78 KB - -
CDN Bundle (incl. Tracing) - uncompressed 105.94 KB +0.02% +11 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 216.77 KB +0.01% +11 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 229.3 KB +0.01% +11 B 🔺
@sentry/nextjs (client) 38.36 KB +0.03% +10 B 🔺
@sentry/sveltekit (client) 36.01 KB +0.03% +9 B 🔺
@sentry/node 161.72 KB - -
@sentry/node - without tracing 97.48 KB - -
@sentry/aws-serverless 127.36 KB - -

View base workflow run

Copy link

codecov bot commented Jan 9, 2025

❌ 19 Tests Failed:

Tests completed Failed Passed Skipped
632 19 613 296
View the top 3 failed tests by shortest run time
performance.test.ts sends a navigation transaction even if the pageload span is still active
Stack Traces | 30s run time
performance.test.ts:57:5 sends a navigation transaction even if the pageload span is still active
client-app-routing-instrumentation.test.ts Creates a navigation transaction for `<Link />`
Stack Traces | 30s run time
client-app-routing-instrumentation.test.ts:136:5 Creates a navigation transaction for `<Link />`
performance.client.test.ts sends a navigation transaction
Stack Traces | 30s run time
performance.client.test.ts:26:1 sends a navigation transaction

To view more test analytics, go to the Test Analytics Dashboard
📢 Thoughts on this report? Let us know!

@@ -494,8 +491,7 @@ function registerInteractionListener(
const registerInteractionTransaction = (): void => {
const op = 'ui.action.click';

const activeSpan = getActiveSpan();
const rootSpan = activeSpan && getRootSpan(activeSpan);
const rootSpan = getActiveIdleSpan(client);
Copy link
Member

Choose a reason for hiding this comment

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

m/h: I'm a bit concerned about this as we don't check the scope anymore for the active span. Which means we diverge here from other places where we do something similar. Also, paired with my other comment, we'd need to ensure that we unset the span on the client whenever the span ends.

Copy link
Member Author

Choose a reason for hiding this comment

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

so I adjusted the idle spans to be unset when the idle (route) span ends. Then, I think this should be OK?

packages/browser/src/tracing/browserTracingIntegration.ts Outdated Show resolved Hide resolved
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.

It's a bit unusual to set a span on the client but if we get it working, I think it's reasonable. Isolation in multi-client setups is an advantage

@mydea mydea force-pushed the fn/browser-tracing-active-span branch 2 times, most recently from 3720405 to c470dd3 Compare January 9, 2025 15:43
@mydea mydea force-pushed the fn/browser-tracing-active-span branch from c470dd3 to 6ef7deb Compare January 10, 2025 08:14
@mydea mydea merged commit 1766d4c into develop Jan 10, 2025
122 checks passed
@mydea mydea deleted the fn/browser-tracing-active-span branch January 10, 2025 09:49
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