Skip to content

feat(core): Ensure trace APIs always return a span#10942

Merged
AbhiPrasad merged 3 commits intodevelopfrom
fn/non-recording-span
Mar 6, 2024
Merged

feat(core): Ensure trace APIs always return a span#10942
AbhiPrasad merged 3 commits intodevelopfrom
fn/non-recording-span

Conversation

@mydea
Copy link
Copy Markdown
Member

@mydea mydea commented Mar 6, 2024

When tracing is disabled or otherwise skipped, they return a non recording span instead of undefined.

This aligns the startSpan, startSpanManual and startInactiveSpan APIs with opentelemetry, where you also always get a span back.

Especially, this makes our APIs much nicer to use, as you don't need to guard for span existence everywhere anymore 🎉

I tried to update all tests etc. to use this and remove some unnecessary check (side note: I wonder if we could add an eslint rule: https://typescript-eslint.io/rules/no-unnecessary-condition/) I'll look into maybe adding this rule as well.

@mydea mydea requested review from AbhiPrasad, Lms24, lforst and s1gr1d March 6, 2024 10:07
@mydea mydea self-assigned this Mar 6, 2024
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 6, 2024

size-limit report 📦

Path Size
@sentry/browser (incl. Tracing, Replay, Feedback) - Webpack (gzipped) 77.52 KB (+0.19% 🔺)
@sentry/browser (incl. Tracing, Replay) - Webpack (gzipped) 68.74 KB (+0.24% 🔺)
@sentry/browser (incl. Tracing, Replay with Canvas) - Webpack (gzipped) 72.66 KB (+0.22% 🔺)
@sentry/browser (incl. Tracing, Replay) - Webpack with treeshaking flags (gzipped) 62.28 KB (+0.22% 🔺)
@sentry/browser (incl. Tracing) - Webpack (gzipped) 32.97 KB (+0.42% 🔺)
@sentry/browser (incl. browserTracingIntegration) - Webpack (gzipped) 32.97 KB (+0.42% 🔺)
@sentry/browser (incl. Feedback) - Webpack (gzipped) 31.36 KB (+0.06% 🔺)
@sentry/browser (incl. sendFeedback) - Webpack (gzipped) 31.37 KB (+0.06% 🔺)
@sentry/browser - Webpack (gzipped) 22.57 KB (+0.06% 🔺)
@sentry/browser (incl. Tracing, Replay, Feedback) - ES6 CDN Bundle (gzipped) 75.58 KB (+0.21% 🔺)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (gzipped) 67.18 KB (+0.19% 🔺)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (gzipped) 33.06 KB (+0.45% 🔺)
@sentry/browser - ES6 CDN Bundle (gzipped) 23.98 KB (+0.04% 🔺)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (minified & uncompressed) 211.04 KB (+0.24% 🔺)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (minified & uncompressed) 99.84 KB (+0.51% 🔺)
@sentry/browser - ES6 CDN Bundle (minified & uncompressed) 71.67 KB (+0.03% 🔺)
@sentry/browser (incl. Tracing) - ES5 CDN Bundle (gzipped) 36.22 KB (+0.47% 🔺)
@sentry/react (incl. Tracing, Replay) - Webpack (gzipped) 69 KB (+0.2% 🔺)
@sentry/react - Webpack (gzipped) 22.6 KB (+0.06% 🔺)
@sentry/nextjs Client (incl. Tracing, Replay) - Webpack (gzipped) 85.44 KB (+0.18% 🔺)
@sentry/nextjs Client - Webpack (gzipped) 49.84 KB (+0.28% 🔺)
@sentry-internal/feedback - Webpack (gzipped) 17.41 KB (0%)

mydea added 3 commits March 6, 2024 10:54
When tracing is disabled or otherwise skipped, they return a non recording span instead of undefined.
@mydea mydea force-pushed the fn/non-recording-span branch from 1cc9bbc to 412dd69 Compare March 6, 2024 11:03
@AbhiPrasad
Copy link
Copy Markdown
Contributor

I'm gonna merge this in because I need it for a change

@AbhiPrasad AbhiPrasad merged commit f688034 into develop Mar 6, 2024
@AbhiPrasad AbhiPrasad deleted the fn/non-recording-span branch March 6, 2024 18:16
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