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

feat(tracing): Implement new browserTracingIntegration() #10327

Closed
wants to merge 3 commits into from

Conversation

mydea
Copy link
Member

@mydea mydea commented Jan 24, 2024

While looking to deprecate/replace instrumentNavigation with something without startTransaction, I figured it may actually be better to already make the functional replacement for browserTracingIntegration behave this way, so we can do this in one swoop.

This now exposes a new browserTracingIntegration() which relies on hooks to start the idle spans. I implemented this in Angular as an example for how this would work then - which also means that you can now instrument Angular without any further config for browserTracingIntegration() there!

This replaces #10324 and the previous, so far unreleased browserTracingIntegration().

@mydea mydea self-assigned this Jan 24, 2024
Copy link
Contributor

github-actions bot commented Jan 24, 2024

size-limit report 📦

Path Size
@sentry/browser (incl. Tracing, Replay, Feedback) - Webpack (gzipped) 77.9 KB (+0.08% 🔺)
@sentry/browser (incl. Tracing, Replay) - Webpack (gzipped) 69.1 KB (+0.09% 🔺)
@sentry/browser (incl. Tracing, Replay with Canvas) - Webpack (gzipped) 72.99 KB (+0.09% 🔺)
@sentry/browser (incl. Tracing, Replay) - Webpack with treeshaking flags (gzipped) 62.74 KB (+0.1% 🔺)
@sentry/browser (incl. Tracing) - Webpack (gzipped) 33.12 KB (+0.18% 🔺)
@sentry/browser (incl. Feedback) - Webpack (gzipped) 31.25 KB (0%)
@sentry/browser (incl. sendFeedback) - Webpack (gzipped) 31.26 KB (+0.01% 🔺)
@sentry/browser - Webpack (gzipped) 22.5 KB (0%)
@sentry/browser (incl. Tracing, Replay, Feedback) - ES6 CDN Bundle (gzipped) 75.63 KB (+0.09% 🔺)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (gzipped) 67.19 KB (+0.1% 🔺)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (gzipped) 33.04 KB (+0.21% 🔺)
@sentry/browser - ES6 CDN Bundle (gzipped) 24.43 KB (0%)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (minified & uncompressed) 211.79 KB (+0.18% 🔺)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (minified & uncompressed) 99.81 KB (+0.38% 🔺)
@sentry/browser - ES6 CDN Bundle (minified & uncompressed) 73.08 KB (0%)
@sentry/browser (incl. Tracing) - ES5 CDN Bundle (gzipped) 36.13 KB (+0.19% 🔺)
@sentry/react (incl. Tracing, Replay) - Webpack (gzipped) 69.5 KB (+0.09% 🔺)
@sentry/react - Webpack (gzipped) 22.55 KB (0%)
@sentry/nextjs Client (incl. Tracing, Replay) - Webpack (gzipped) 86.17 KB (+0.08% 🔺)
@sentry/nextjs Client - Webpack (gzipped) 50.46 KB (+0.12% 🔺)
@sentry-internal/feedback - Webpack (gzipped) 17.21 KB (0%)

@mydea
Copy link
Member Author

mydea commented Jan 24, 2024

Note: For react, we may still need a router option or something like this (so just for the browserTracingIntegration that is exported from @sentry/react, as we'll want to adjust the defaults depending on if this was set or not:

  1. If no router is passed, we use the regular defaults from browser
  2. If a router is passed, we disable instrumentPageLoad and instrumentNavigation for the default integration and instead emit them manually from the concrete router implementation

mydea added a commit that referenced this pull request Jan 24, 2024
Due to #10327, this
reverts changes to the browser tracing integration as we're actually
going to replace this differently.
@mydea mydea force-pushed the fn/newBrowserTracingIntegration branch from 6fc3734 to 92ba0ba Compare January 24, 2024 20:25
@mydea
Copy link
Member Author

mydea commented Jan 25, 2024

Actually I'd probably export utilities browserTracingStartPageLoadSpan(startSpanOptions) & browserTracingStartNavigationSpan(startSpanOptions) which can be used for manual instrumentation, then we don't need to document/publicly recommend to use getClient().emit(...) but we can abstract this away!

@mydea mydea force-pushed the fn/newBrowserTracingIntegration branch from 92ba0ba to a4488c1 Compare January 25, 2024 14:56
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.

The new APIs make sense to me and I think they work well with Angular and the other frameworks we mentioned in the call.

Reminder to myself that we should add some Angular e2e tests to cover this properly. But as we discussed we don't change anything behaviour-wise for the page load transaction so we should be good.

packages/angular/src/tracing.ts Outdated Show resolved Hide resolved
Comment on lines +68 to +74
return originalBrowserTracingIntegration({
...options,
instrumentPageLoad: true,
// We handle this manually
instrumentNavigation: false,
});
}
Copy link
Member

Choose a reason for hiding this comment

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

I guess one downside of this approach I just thought of is that there will be no navigation span/txn at all, if users don't register the TraceService. Previously they would have gotten the default browser one.

I think this is okay though - "incorrect" or incomplete SDK setup shouldn't be something we care too much about IMO. (Also, this is documented pretty clearly in docs)

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, I think I will refactor this based on what we talked about that we actually never overwrite the defaults like this but only do it via checking if something else registered a hook instead!

Co-authored-by: Lukas Stracke <lukas.stracke@sentry.io>
mydea added a commit that referenced this pull request Jan 26, 2024
Extracted this out of
#10327.

This PR:

* Introduces a new `browserTracingIntegration()`
* Does NOT deprecate BrowserTracing yet, as custom implementations in
Angular, Next, Sveltekit have not been migrated over yet, which would be
weird. We can deprecate it once we moved these over.
* Makes sure that custom implementations in Next & Sveltekit are "fixed"
automatically
* Uses a slim fork for the CDN bundles, to avoid shipping multiple
implementations in there.
* This means that in the CDN bundles, you can already use the new
syntax, but you cannot pass a custom routing instrumentation anymore,
and you also don't have the utility functions for it yet. I think this
is the best tradeoff for now, and it's probably not a super common case
to have custom routing instrumentation when using the Loader/CDN bundles
(and if you do, you have to stick to `new BrowserTracing()` until v8).

I copied the browser integration tests we have, which all pass!
@mydea
Copy link
Member Author

mydea commented Jan 29, 2024

this was implemented in a different PR.

@mydea mydea closed this Jan 29, 2024
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.

None yet

2 participants