-
Notifications
You must be signed in to change notification settings - Fork 96
Consolidating Span and RootSpan to allow Spans to recursively have children #441
Consolidating Span and RootSpan to allow Spans to recursively have children #441
Conversation
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 think this is a good step in the right direction. I would also want Tracer
to support trace contexts that aren't root spans, and maybe even to collapse the distinction between Span
and RootSpan
.
But doing this step-by-step makes sense to me, and I think this general approach is a decent first step.
@mayurkale22 what do you think?
Codecov Report
@@ Coverage Diff @@
## master #441 +/- ##
=========================================
+ Coverage 94.34% 94.75% +0.4%
=========================================
Files 150 148 -2
Lines 8884 9940 +1056
Branches 731 750 +19
=========================================
+ Hits 8382 9419 +1037
- Misses 502 521 +19
Continue to review full report at Codecov.
|
@mayurkale22 @draffensperger Please take a look. PR description updated. All tests are passing. I'd like to get this merged quickly since it touches so many files that keeping it up to date is a challenge. Thanks to @hekike for helping me keep this PR up to date! |
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the ℹ️ Googlers: Go here for more info. |
I signed the CLA in the meantime. |
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.
First pass. Looks great!
Nit: Should we rename rootSpan -> span
& rootSpans -> spans
variable names in seperate PR?
packages/opencensus-core/src/trace/model/no-record/no-record-root-span.ts
Outdated
Show resolved
Hide resolved
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.
LGTM pending a few minor comments.
I do support getting this in given the number of files it touches and think that further cleanup / improvement should be in follow up PRs.
/** Gets the ID of the parent span. */ | ||
get parentSpanId(): string { | ||
if (!this.parentSpan) { | ||
return 'no-parent'; |
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.
Can this just return the empty string (''
) which means "no parent" in other context?
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.
Done
|
||
/** Recursively gets the descendant spans. */ | ||
allDescendants(): types.Span[] { | ||
console.log('Calling allDescendants', this.name); |
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.
Can this and the other log lines below be removed?
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.
Removed. Sorry about that.
traceId: this.traceId, | ||
spanId: this.id, | ||
name: this.name, | ||
options: 0x1, // always traced |
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'm assuming this was adapted from SpanBase
- will it cause all spans to be sampled? @mayurkale22
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.
Hmm... I didn't touch this line, just moved it.
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'm assuming this was adapted from SpanBase - will it cause all spans to be sampled?
No. The Sampling Decision happens at the top level (when we create the root span using startRootSpan
). Depending on the decision, it creates either RootSpan
(which has options set to 0x1) or NoRecordRootSpan
(options set to 0x0). Does it make sense?
duration: childSpan.duration | ||
})); | ||
} | ||
// tslint:disable-next-line:no-any |
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.
Since this doesn't use any
below, can you remove this tslint disable comment?
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.
Removed
Squashed commits: [a4f2234] Get the test passing [8276c98] Get allDescendants() working [379b2eb] Big refactor, tests are mostly passing [6d93312] Lerna handles cross-package dependencies [3567e2e] Rough draft of making Span and RootSpan almost identical [eba18f3] Set 'shared' based on the type of span [b56a884] Reformat tests [b1b6dfb] Use parentSpanId if provided [9d4e601] Tests that ensure nested spans are properly translated for Zipkin [585034e] Add tests for nested spans.
Ping @googlebot |
A Googler has manually verified that the CLAs look good. (Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.) ℹ️ Googlers: Go here for more info. |
packages/opencensus-exporter-zpages/src/zpages-frontend/page-handlers/tracez.page-handler.ts
Outdated
Show resolved
Hide resolved
packages/opencensus-exporter-zpages/src/zpages-frontend/page-handlers/tracez.page-handler.ts
Outdated
Show resolved
Hide resolved
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the ℹ️ Googlers: Go here for more info. |
A Googler has manually verified that the CLAs look good. (Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.) ℹ️ Googlers: Go here for more info. |
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.
LGTM, thanks for the contribution.
Consolidate the functionality of Span and RootSpan to allow Spans to recursively have children.
git diff master:packages/opencensus-core/src/trace/model/span-base.ts span-refactor:packages/opencensus-core/src/trace/model/span.ts
allDescendants()
yet. They still get just the root's immediate children. I think we can do that in a subsequent PR.