-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
ref: Collect child spans references via non-enumerable on Span object #10715
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
size-limit report 📦
|
@@ -401,6 +402,8 @@ export class SentrySpan implements SpanInterface { | |||
childSpan.spanRecorder.add(childSpan); | |||
} | |||
|
|||
addChildSpanReferenceToSpan(childSpan, 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.
l: nit, but I think I would prefer an order of parent, child, for the arguments 🤔 Makes it a bit easier to reason about IMHO... also the reference
is a bit redundant here I'd say, what about:
addChildSpanToSpan(span, childSpan);
but no strong feelings, I'm also OK with what is currently here!
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.
Sounds good!
@@ -401,6 +402,8 @@ export class SentrySpan implements SpanInterface { | |||
childSpan.spanRecorder.add(childSpan); | |||
} | |||
|
|||
addChildSpanToSpan(this, 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.
addChildSpanToSpan(this, childSpan); | |
// For now, we capture this here as well in order to ensure backwards compatibility | |
// eventually this will only be captured in `startSpan` methods | |
addChildSpanToSpan(this, 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.
some small nits, but overall looks great to me 👍
packages/core/src/tracing/trace.ts
Outdated
export function getSpanTree(span: SpanWithPotentialChildren): Span[] { | ||
const resultSet = new Set<Span>(); | ||
|
||
function recurse(span: SpanWithPotentialChildren): void { |
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.
function recurse(span: SpanWithPotentialChildren): void { | |
function addSpanChildren(span: SpanWithPotentialChildren): void { |
I'd name this a bit more expressively here?
packages/core/src/tracing/trace.ts
Outdated
resultSet.add(span); | ||
const childSpans = span[CHILD_SPANS_FIELD] ? Array.from(span[CHILD_SPANS_FIELD]) : []; | ||
for (const childSpan of childSpans) { | ||
recurse(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.
recurse(childSpan); | |
addSpanChildren(childSpan); |
packages/core/src/tracing/trace.ts
Outdated
} | ||
} | ||
|
||
recurse(span); |
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.
recurse(span); | |
addSpanChildren(span); |
Instead of relying on a transactions span recorder when starting spans we are tracking child spans via a non-enumerable on the parent span.