Skip to content

feat(core): Make custom tracing methods return spans & set default op #10633

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

Merged
merged 2 commits into from
Feb 13, 2024

Conversation

mydea
Copy link
Member

@mydea mydea commented Feb 13, 2024

This should make using these much easier:

  • add a default op to the spans, so users don't need to specify them.
  • Return the created span (or undefined), ensuring users don't need to do all the checking for op etc. themselves.

Also make some small adjustments to ember & angular instrumentation to leverage some of these changes.

@mydea mydea requested review from lforst and Lms24 February 13, 2024 09:20
@mydea mydea self-assigned this Feb 13, 2024
Copy link
Contributor

github-actions bot commented Feb 13, 2024

size-limit report 📦

Path Size
@sentry/browser (incl. Tracing, Replay, Feedback) - Webpack (gzipped) 77.95 KB (0%)
@sentry/browser (incl. Tracing, Replay) - Webpack (gzipped) 69.18 KB (0%)
@sentry/browser (incl. Tracing, Replay with Canvas) - Webpack (gzipped) 73.11 KB (0%)
@sentry/browser (incl. Tracing, Replay) - Webpack with treeshaking flags (gzipped) 62.79 KB (0%)
@sentry/browser (incl. Tracing) - Webpack (gzipped) 33.37 KB (0%)
@sentry/browser (incl. browserTracingIntegration) - Webpack (gzipped) 33.26 KB (+0.07% 🔺)
@sentry/browser (incl. Feedback) - Webpack (gzipped) 31.16 KB (0%)
@sentry/browser (incl. sendFeedback) - Webpack (gzipped) 31.16 KB (0%)
@sentry/browser - Webpack (gzipped) 22.43 KB (0%)
@sentry/browser (incl. Tracing, Replay, Feedback) - ES6 CDN Bundle (gzipped) 76.09 KB (0%)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (gzipped) 67.6 KB (0%)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (gzipped) 33.59 KB (0%)
@sentry/browser - ES6 CDN Bundle (gzipped) 24.64 KB (0%)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (minified & uncompressed) 212.93 KB (0%)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (minified & uncompressed) 101.55 KB (0%)
@sentry/browser - ES6 CDN Bundle (minified & uncompressed) 73.83 KB (0%)
@sentry/browser (incl. Tracing) - ES5 CDN Bundle (gzipped) 36.83 KB (0%)
@sentry/react (incl. Tracing, Replay) - Webpack (gzipped) 69.55 KB (0%)
@sentry/react - Webpack (gzipped) 22.46 KB (0%)
@sentry/nextjs Client (incl. Tracing, Replay) - Webpack (gzipped) 87.35 KB (+0.05% 🔺)
@sentry/nextjs Client - Webpack (gzipped) 50.48 KB (+0.09% 🔺)
@sentry-internal/feedback - Webpack (gzipped) 17.1 KB (0%)

Comment on lines 420 to +424
client.emit('startNavigationSpan', spanOptions);

const span = getActiveSpan();
const op = span && spanToJSON(span).op;
return op === 'navigation' ? span : undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we maybe have the emit hook return the span? Otherwise, we start racing again.

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 hooks so far have been designed with having no return value, always - which sometimes is a bit of a restriction but keeps the API very clean and slim. IMHO this should be very safe, we are in browser and there is only a single thread, there isn't really a way this could not work as far as I see, and type-wise we return Span | undefined anyhow so you have to write this defensively anyhow...?

Copy link
Member Author

Choose a reason for hiding this comment

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

Also note that we can still change this later, as this is completely internal now - so if we figure this is not accurate enough, we can change how this works transparently :)

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure if this is clean and slim 🤔 Fine for now but to me this is very smelly.

Copy link
Member Author

Choose a reason for hiding this comment

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

the hooks API itself is clean, in this concrete case it is not ideal of course - we can revisit this for sure!

This should make using these much easier.
Also adjust the ember instrumentation to use these
@mydea mydea force-pushed the fn/browserTracingSpans branch from 448d33b to 43baead Compare February 13, 2024 09:50
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.

Good changes!

@Lms24
Copy link
Member

Lms24 commented Feb 13, 2024

If we already have tests, can we adjust them to check for the return value? If not, no worries, we'll check this implicitly with the routing instrumentation tests.

@mydea
Copy link
Member Author

mydea commented Feb 13, 2024

I added some tests for this, makes sense overall!

@mydea mydea force-pushed the fn/browserTracingSpans branch from 1172281 to 1550d4c Compare February 13, 2024 10:29
@mydea mydea merged commit b5829e1 into develop Feb 13, 2024
@mydea mydea deleted the fn/browserTracingSpans branch February 13, 2024 10:52
@mydea mydea mentioned this pull request Feb 13, 2024
mydea added a commit that referenced this pull request Feb 13, 2024
…#10633)

This should make using these much easier:

* add a default `op` to the spans, so users don't need to specify them.
* Return the created span (or undefined), ensuring users don't need to
do all the checking for op etc. themselves.

Also make some small adjustments to ember & angular instrumentation to
leverage some of these changes.
mydea added a commit that referenced this pull request Feb 13, 2024
…#10633)

This should make using these much easier:

* add a default `op` to the spans, so users don't need to specify them.
* Return the created span (or undefined), ensuring users don't need to
do all the checking for op etc. themselves.

Also make some small adjustments to ember & angular instrumentation to
leverage some of these changes.
mydea added a commit that referenced this pull request Feb 13, 2024
…#10633)

This should make using these much easier:

* add a default `op` to the spans, so users don't need to specify them.
* Return the created span (or undefined), ensuring users don't need to
do all the checking for op etc. themselves.

Also make some small adjustments to ember & angular instrumentation to
leverage some of these changes.
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.

3 participants