-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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(tracing): Split @sentry/tracing
into runtime specific packages
#5815
Comments
Continuing the thread from #5611 (comment):
I think so. Ideally, we wouldn't need hub extensions anymore since it's all already there.
We had an internal discussion about this some time ago and we would like to turn off auto-discovery by default for the next major because of the startup time. |
If we move the existing runtime agnostic code over to I still need to do some experimentation to see how much it adds if the code is fully integrated to the hub without extensions. I would guess this could add 5-10kB since the code ends up in the |
I did the experimenting and moved tracing into |
This PR on my fork shows how the runtime agnostic code from |
After doing some experimenting, we cannot use the approach in #7345 because this would break older bundlers. |
As per #7372, we must do this change in v8 |
A possible option we can take on here is to create a new tracing package - and then make This new package can export everything without side effects so it can be tree-shaken/not slow down the node package. |
IMHO that can be fine, we can make the package purely private/internal, so it would really just be an implementation detail! |
It's been a while, but I think we worked around the older bundler issues while still having named package exports with the Electron SDK by outputting the cjs build output into correctly named directories in the root of the package. "exports": {
"./main": {
"require": "./main/index.js",
"import": "./esm/main/index.js"
},
"./renderer": {
"require": "./renderer/index.js",
"import": "./esm/renderer/index.js"
}
}, We don't actually have any webpack 4 e2e tests, but I just did some quick testing and with the above, both The major downside here is that cjs gets used and therefore no tree shaking occurs. In the case of the Electron SDK, this means that all the session replay code gets bundled. cjs is no doubt why we've seen issues like this even when Replay isn't used. |
This is what I ran into, and unfortunately means we can't move forward with this for the stock browser package. |
Once the above two linked PRs are merged, I'm guessing the next steps go something like:
For v8
|
@timfish one thing we'll have to consider is hub extensions and auto discovery of database integrations. We'll want to make sure the flow looks like so: Browserimport * as Sentry from '@sentry/browser';
Sentry.init({
dsn: "__DSN__",
tracesSampleRate: 1.0,
integrations: [new Sentry.BrowserTracing()]
}); If you don't want to use import * as Sentry from '@sentry/browser';
Sentry.addTracingExtensions();
Sentry.init({
dsn: "__DSN__",
tracesSampleRate: 1.0,
}); Nodeimport * as Sentry from '@sentry/node';
Sentry.addTracingExtensions();
Sentry.discoverTracingIntegrations();
Sentry.init({
dsn: "__DSN__",
tracesSampleRate: 1.0,
}); |
We need to think about what types need re-exporting from node/browser from Once the migration is complete, but before we add any deprecation jsdocs, we'll try to migrate all the Sentry packages to use node/browser rather than tracing. This should give us a good idea of what exports we need! |
Since we've removed Next up is docs work in getsentry/sentry-docs#6518 and final deprecation in #7586, but we can use those issues to track this. |
Problem Statement
After some discussions around supporting newer JavaScript runtimes (#5611) @lforst pointed out the first thing that needs tackling is
@sentry/tracing
!This package currently contains:
Goal: Remove the tracing package, move stuff into core/browser/node
Solution Brainstorm
It looks like the runtime agnostic code can safely be moved to
@sentry/core
without affecting bundle sizes since if it goes unused it gets tree-shaken.The runtime specific code could be moved into package exports under the specific runtime, ie.
@sentry/browser/tracing
and@sentry/node/tracing
. We've been using this in the Electron SDK for a while to keep bundlers happy with the two different contexts we run in. We can't export the tracing code at the root of the packages since importing tracing has side-effects!I haven't marked this issue as
Breaking
yet because I think it would be possible to move this code while keeping@sentry/tracing
as a stub that would simply re-export the moved code.@sentry/tracing
would have to depend on both@sentry/browser
and@sentry/node
so I'm not sure how viable this is yet or if it's worth that extra step 🤔Tasks
@sentry/tracing
code to@sentry/core
#7091BrowserTracing
to@sentry/browser
#7342@sentry/node
#7346@sentry/tracing
#7340Cleanup
@sentry/tracing
usage sentry-docs#6518The text was updated successfully, but these errors were encountered: