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): Expose new browserTracingIntegration #10351

Merged
merged 5 commits into from Jan 26, 2024

Conversation

mydea
Copy link
Member

@mydea mydea commented Jan 25, 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 mydea self-assigned this Jan 25, 2024
@@ -57,6 +57,9 @@ export {
BrowserTracing,
defaultRequestInstrumentationOptions,
instrumentOutgoingRequests,
browserTracingIntegration,
startBrowserTracingNavigationSpan,
Copy link
Member Author

Choose a reason for hiding this comment

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

These two APIs would be used by custom instrumentation, e.g. Angular, Ember, Next etc.

}

// If `browserTracingIntegration()` was added, we need to force-convert it to our custom one
if (isNewBrowserTracingIntegration(browserTracing)) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is all pretty hacky 😬 but the best I could come up with! It should work well enough for 99% of cases.

},
// TODO v8: Remove this again
// This is private API that we use to fix converted BrowserTracing integrations in Next.js & SvelteKit
options,
Copy link
Member Author

Choose a reason for hiding this comment

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

Could not think of a better way to allow us to solve this 😬 I'd say it's OK for now, we can remove it in v8.

Copy link
Member

Choose a reason for hiding this comment

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

We need to refactor how options works in general with BrowserTracing, there's some duplication around setting defaults that I think we can improve.

Copy link
Contributor

github-actions bot commented Jan 25, 2024

size-limit report 📦

Path Size
@sentry/browser (incl. Tracing, Replay, Feedback) - Webpack (gzipped) 77.89 KB (+0.02% 🔺)
@sentry/browser (incl. Tracing, Replay) - Webpack (gzipped) 69.08 KB (+0.03% 🔺)
@sentry/browser (incl. Tracing, Replay with Canvas) - Webpack (gzipped) 72.97 KB (+0.03% 🔺)
@sentry/browser (incl. Tracing, Replay) - Webpack with treeshaking flags (gzipped) 62.72 KB (+0.02% 🔺)
@sentry/browser (incl. Tracing) - Webpack (gzipped) 33.12 KB (+0.05% 🔺)
@sentry/browser (incl. Feedback) - Webpack (gzipped) 31.28 KB (0%)
@sentry/browser (incl. sendFeedback) - Webpack (gzipped) 31.29 KB (0%)
@sentry/browser - Webpack (gzipped) 22.54 KB (0%)
@sentry/browser (incl. Tracing, Replay, Feedback) - ES6 CDN Bundle (gzipped) 75.71 KB (+0.14% 🔺)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (gzipped) 67.26 KB (+0.16% 🔺)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (gzipped) 33.11 KB (+0.32% 🔺)
@sentry/browser - ES6 CDN Bundle (gzipped) 24.47 KB (+0.03% 🔺)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (minified & uncompressed) 211.89 KB (+0.2% 🔺)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (minified & uncompressed) 99.91 KB (+0.43% 🔺)
@sentry/browser - ES6 CDN Bundle (minified & uncompressed) 73.23 KB (+0.08% 🔺)
@sentry/browser (incl. Tracing) - ES5 CDN Bundle (gzipped) 36.2 KB (+0.25% 🔺)
@sentry/react (incl. Tracing, Replay) - Webpack (gzipped) 69.49 KB (+0.02% 🔺)
@sentry/react - Webpack (gzipped) 22.58 KB (0%)
@sentry/nextjs Client (incl. Tracing, Replay) - Webpack (gzipped) 86.19 KB (+0.05% 🔺)
@sentry/nextjs Client - Webpack (gzipped) 50.49 KB (+0.1% 🔺)
@sentry-internal/feedback - Webpack (gzipped) 17.21 KB (0%)
@sentry/browser (incl. browserTracingIntegration) - Webpack (gzipped) 33.02 KB (added)

Copy link
Member

@AbhiPrasad AbhiPrasad left a comment

Choose a reason for hiding this comment

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

A little afraid I missed reviewing an export somewhere, but otherwise looks good!

@mydea
Copy link
Member Author

mydea commented Jan 25, 2024

So I added two further utilities:

disableDefaultBrowserTracingNavigationSpan()
disableDefaultBrowserTracingPageLoadSpan()

These can be used by custom instrumentation to ensure we don't trigger the default spans.

@mydea mydea force-pushed the fn/newBrowserTracingIntegrationOnly branch from ed19b05 to af7fc5c Compare January 25, 2024 21:48
Comment on lines 233 to 236
// eslint-disable-next-line deprecation/deprecation
const sourceFromData = context.data && context.data[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];
// eslint-disable-next-line deprecation/deprecation
const sourceFromMetadata = finalContext.metadata && finalContext.metadata.source;
Copy link
Member

Choose a reason for hiding this comment

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

m: Shouldn't we additionally look for the source in context.attributes[SEMANTIC_ATTRIBUTES_SENTRY_SOURCE]?

Copy link
Member Author

Choose a reason for hiding this comment

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

I just directly copied this over for now, metadata is a getter that merges that attribute in, so it should still work normally :) in v8 we adjust this then!

Copy link
Member Author

Choose a reason for hiding this comment

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

ah wait nevermind, my comment is incorrect, I think you're right, let's also check attributes 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

added a check for this, also in the original browser tracing integration!

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.

Looks good to me!

@mydea mydea merged commit adccbe6 into develop Jan 26, 2024
94 checks passed
@mydea mydea deleted the fn/newBrowserTracingIntegrationOnly branch January 26, 2024 15:54
mydea added a commit that referenced this pull request Jan 31, 2024
Also deprecate the routing Instrumentation.

This is WIP on top of
#10351, to show how
that would work.

No idea how to get the tests working for this, though...
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

3 participants