-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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(core): Introduce Sentry.startActiveSpan
and Sentry.startSpan
#8803
Conversation
size-limit report 📦
|
packages/core/src/tracing/trace.ts
Outdated
|
||
const parentSpan = scope.getSpan(); | ||
|
||
function getActiveSpan(): Span | undefined { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l: The naming is a bit confusing IMHO, as it appears as if this would just get the currently active span, but actually we create a new active span? What about e.g. createNewSpan
or createChildSpan
or something like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great point - renamed
@@ -14,7 +14,7 @@ const enum Type { | |||
let hub: Hub; | |||
let client: TestClient; | |||
|
|||
describe('trace', () => { | |||
describe('startActiveSpan', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l: Should we keep the trace
tests around? 🤔 not sure, maybe it's fine to remove them as well 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I replaced the trace
tests with startActiveSpan
. I'll be removing trace
afterwards considering it was an internal API.
ref #8724
This PR introduces two new methods to the JavaScript SDK's public API.
Sentry.startActiveSpan
andSentry.startSpan
, detailed in the RFC about the new performance API.Sentry.startActiveSpan
automatically wraps a callback with a span and makes that span the active span for the execution context of the callback. The callback can be async or sync, and can return arbitrary values.Sentry.startSpan
just creates a span, but does not wrap it in a callback. It needs to be explicitly set on the scope just likeSentry.startTransaction
.Under the hood these methods will create a transaction or span depending on if there is already an active span on the scope.