Skip to content

Conversation

@mydea
Copy link
Member

@mydea mydea commented Dec 21, 2023

@lforst noticed that currently startSpan() and startSpanManual do not fork the scope, which is also a slightly different behavior than it is in OTEL.

This adjusts this to better align, so that we always fork a scope. We also always leave the span on the forked scope, even after it was finished.

In a follow up, we can thus also get rid of the finish callback arg for startSpanManual, as users can/should simply call span.end() themselves then.

@mydea mydea requested review from AbhiPrasad and lforst December 21, 2023 12:31
@mydea mydea self-assigned this Dec 21, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Dec 21, 2023

size-limit report 📦

Path Size
@sentry/browser (incl. Tracing, Replay, Feedback) - Webpack (gzipped) 75.63 KB (+0.05% 🔺)
@sentry/browser (incl. Tracing, Replay) - Webpack (gzipped) 67.06 KB (+0.06% 🔺)
@sentry/browser (incl. Tracing, Replay) - Webpack with treeshaking flags (gzipped) 60.65 KB (+0.09% 🔺)
@sentry/browser (incl. Tracing) - Webpack (gzipped) 31.64 KB (+0.09% 🔺)
@sentry/browser (incl. Feedback) - Webpack (gzipped) 30.22 KB (-0.01% 🔽)
@sentry/browser - Webpack (gzipped) 21.91 KB (0%)
@sentry/browser (incl. Tracing, Replay, Feedback) - ES6 CDN Bundle (gzipped) 73.06 KB (+0.05% 🔺)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (gzipped) 64.76 KB (+0.06% 🔺)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (gzipped) 30.97 KB (+0.12% 🔺)
@sentry/browser - ES6 CDN Bundle (gzipped) 22.95 KB (-0.03% 🔽)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (minified & uncompressed) 203.15 KB (+0.03% 🔺)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (minified & uncompressed) 93.07 KB (+0.06% 🔺)
@sentry/browser - ES6 CDN Bundle (minified & uncompressed) 68.06 KB (-0.03% 🔽)
@sentry/browser (incl. Tracing) - ES5 CDN Bundle (gzipped) 33.97 KB (+0.27% 🔺)
@sentry/react (incl. Tracing, Replay) - Webpack (gzipped) 67.44 KB (+0.06% 🔺)
@sentry/react - Webpack (gzipped) 21.95 KB (0%)
@sentry/nextjs Client (incl. Tracing, Replay) - Webpack (gzipped) 84.21 KB (+0.06% 🔺)
@sentry/nextjs Client - Webpack (gzipped) 48.83 KB (+0.08% 🔺)
@sentry-internal/feedback - Webpack (gzipped) 16.56 KB (0%)

}

if (isThenable(maybePromiseResult)) {
Promise.resolve(maybePromiseResult).then(
Copy link
Contributor

Choose a reason for hiding this comment

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

If it's thenable, why do we have Promise.resolve in here?

Copy link
Contributor

Choose a reason for hiding this comment

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

@Lms24 is fixing this right now.


return maybePromiseResult;
if (isThenable(maybePromiseResult)) {
Promise.resolve(maybePromiseResult).then(undefined, () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Promise.resolve(maybePromiseResult).then(undefined, () => {
Promise.resolve(maybePromiseResult).catch(() => {

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's not change things unrelated to this PR.

});

expect(_span).toBeDefined();
expect(_span?.endTimestamp).toBeDefined();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
expect(_span?.endTimestamp).toBeDefined();
expect(_span.endTimestamp).toBeDefined();

Copy link
Member Author

Choose a reason for hiding this comment

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

sadly, TS still complains about this even if I check for defined-ness above 😬

expect(span).toBeDefined();
expect(span?.endTimestamp).toBeUndefined();

span?.finish();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
span?.finish();
span.finish();


span?.finish();

expect(span?.endTimestamp).toBeDefined();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
expect(span?.endTimestamp).toBeDefined();
expect(span.endTimestamp).toBeDefined();


expect(initialScope.getSpan()).toBeUndefined();

span?.finish();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
span?.finish();
span.finish();

@mydea mydea merged commit b6a7cef into develop Dec 21, 2023
@mydea mydea deleted the fn/trace-apis branch December 21, 2023 15:31
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.

4 participants