-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(core): Replace idle transaction with idle span #9972
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
Conversation
idleTimeout: number; | ||
finalTimeout: number; | ||
// TODO FN: Do we need this?? | ||
// customSamplingContext?: CustomSamplingContext; |
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.
This is a general thing that already came up - do we need to add this to startSpan
somehow? 🤔
*/ | ||
export function startIdleSpan(options: IdleSpanOptions): Span | undefined { | ||
// Activities store a list of active spans | ||
const activities = new Map<string, boolean>(); |
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.
Keeping this is a map instead of a POJO, makes cleanup etc. easier!
|
||
const FINISH_REASON_TAG = 'finishReason'; | ||
|
||
const FINISH_REASON_HEARTBEAT_FAILED = 'heartbeatFailed'; |
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.
Rewrote this to proper constants instead of accessing array elements.
|
||
DEBUG_BUILD && logger.log('[Tracing] finishing idle span', new Date(endTimestamp * 1000).toISOString(), span.op); | ||
|
||
childSpans.forEach(childSpan => { |
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.
Instead of looking at the spanRecorder
of the transaction, we keep the child spans manually here.
} | ||
|
||
client.on('spanStart', span => { | ||
if (_finished) { |
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.
Instead of patching the span recorder, we hook into spanStart
and check here if the new span is a (nested) child span of the idle span.
_popActivity(span.spanId); | ||
|
||
if (span.spanId === spanId) { | ||
endIdleSpan(); |
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.
Instead of monkey-patching end, we instead trigger this here when we detect that we are ending the idle span.
size-limit report 📦
|
Deprecate the `spanRecorder` field on the `Span` class. For now there's no replacement yet. I'm not entirely sure how we're going to keep track of spans within the SDK. #9972 shows an alternative for `IdleSpan` which no longer seems to rely on the `spanRecorder`. Another possibility might be to make the recorder private which might be enough, too.
This is a draft, replacing
startIdleTransaction
withstartIdleSpan
.Missing for this is adding tests for this, but wanted to check first if the approach seems good to everyone.
Some notes:
onScope
option, as we always put it on the scope right now. So no need to expose this for now.This currently depends on "buggy" behavior ofThis for now still usesstartSpanManual
in regards to scope forking in Browser. But that's OK I guessscope.setSpan()
, we may need to revisit this in v8, but should be OK for now