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

fix(browser): Avoid recording long task spans starting before their parent span #14183

Merged
merged 4 commits into from
Nov 5, 2024

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented Nov 5, 2024

This PR fixes inconsistent behaviour in our browserTracingIntegration, where we'd previously add ui.long-task spans to an ongoing (navigation) transaction, even if the long task started before the navigation transaction started.

Most other browserTracingIntegration spans (resource, timing, measure/mark spans) are already dropped/not started if their start time stamp is earlier than the navigation start time stamp. This happens in one central location but it does not apply to long-task spans because they have to be handled separately.

This PR specifically:

  • not checks for the start time stamp and drops long task spans starting before a navigation spans started.
  • refactors the start and end logic a bit to compensate for bundle size increase (see comment)
  • adds a regression test that previously would fail

Note: We have similar behaviour for long animation frame spans. I'll probably open another PR to adjust the logic there as well.

continue;
}

startAndEndSpan(parent, startTime, startTime + duration, {
Copy link
Member Author

@Lms24 Lms24 Nov 5, 2024

Choose a reason for hiding this comment

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

small refactor: I switched from manually starting and ending the span to using the startAndEndSpan helper which does just that. However, the helper would also adjust the navigation span start time stamp if the stamp was started beforehand.
I medium-strongly feel we should not adjust this start time stamp b/c the long task might have nothing to do with the navigation but it would look like it otherwise.
If reviewers prefer the other way around (i.e. actually record the span and adjust the transaction start time), I'm also fine with that.

Copy link
Contributor

github-actions bot commented Nov 5, 2024

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 22.76 KB - -
@sentry/browser - with treeshaking flags 21.54 KB - -
@sentry/browser (incl. Tracing) 35.18 KB +0.07% +25 B 🔺
@sentry/browser (incl. Tracing, Replay) 71.9 KB +0.05% +33 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 62.33 KB +0.07% +40 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 76.22 KB +0.05% +33 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 89.02 KB +0.05% +40 B 🔺
@sentry/browser (incl. Feedback) 39.9 KB - -
@sentry/browser (incl. sendFeedback) 27.4 KB - -
@sentry/browser (incl. FeedbackAsync) 32.2 KB - -
@sentry/react 25.51 KB - -
@sentry/react (incl. Tracing) 38.15 KB +0.08% +30 B 🔺
@sentry/vue 26.9 KB - -
@sentry/vue (incl. Tracing) 37.07 KB +0.08% +28 B 🔺
@sentry/svelte 22.9 KB - -
CDN Bundle 24.1 KB - -
CDN Bundle (incl. Tracing) 36.99 KB +0.08% +27 B 🔺
CDN Bundle (incl. Tracing, Replay) 71.66 KB +0.05% +34 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 77 KB +0.05% +37 B 🔺
CDN Bundle - uncompressed 70.66 KB - -
CDN Bundle (incl. Tracing) - uncompressed 109.79 KB +0.06% +60 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 222.31 KB +0.03% +60 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 235.52 KB +0.03% +60 B 🔺
@sentry/nextjs (client) 38.23 KB +0.08% +28 B 🔺
@sentry/sveltekit (client) 35.78 KB +0.09% +30 B 🔺
@sentry/node 131.52 KB - -
@sentry/node - without tracing 95.64 KB - -
@sentry/aws-serverless 105.91 KB -0.01% -1 B 🔽

View base workflow run

@Lms24 Lms24 self-assigned this Nov 5, 2024
@Lms24 Lms24 requested review from AbhiPrasad and lforst November 5, 2024 12:37
Copy link
Member

@lforst lforst left a comment

Choose a reason for hiding this comment

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

☀️

@@ -40,7 +40,7 @@ module.exports = [
path: 'packages/browser/build/npm/esm/index.js',
import: createImport('init', 'browserTracingIntegration'),
gzip: true,
limit: '36 KB',
limit: '36.5 KB',
Copy link
Member Author

@Lms24 Lms24 Nov 5, 2024

Choose a reason for hiding this comment

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

we're just ~15 bytes over the previous limit but I figured I'd give the limit a slightly bigger bump as we usually do

@Lms24 Lms24 merged commit ac57e53 into develop Nov 5, 2024
143 checks passed
@Lms24 Lms24 deleted the lms/fix-browser-longtask-starttime branch November 5, 2024 13:12
Lms24 added a commit that referenced this pull request Nov 6, 2024
…ore their parent span (#14186)

- Check for start time of parent navigation span and don't start
long animation frame span if its start timestamp is earlier than the
navigation start time stamp
- Refactor span starting logic to use common helper function to
compensate the bundle size increase
- Add regression test that failed previously
- Improve regression test from #14183 to avoid flakes and improve the
in-test navigation
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