Fixes #566: set CurrentRootSpan whenever created span is RootSpan#570
Conversation
Codecov Report
@@ Coverage Diff @@
## master #570 +/- ##
==========================================
+ Coverage 95.3% 95.35% +0.04%
==========================================
Files 148 148
Lines 10590 10570 -20
Branches 746 744 -2
==========================================
- Hits 10093 10079 -14
+ Misses 497 491 -6
Continue to review full report at Codecov.
|
|
The logic seems reasonable. I wonder if: should be: which would leave you less vulnerable to changes in the http code. |
| this.tracer.setCurrentRootSpan(this); | ||
| } | ||
|
|
||
| if (this.isRootSpan()) this.tracer.setCurrentRootSpan(this); |
There was a problem hiding this comment.
Why is !this.parentSpanId insufficient for determining that a span is a root span?
There was a problem hiding this comment.
A span, with a parent, can be generated in one of two ways:
- An outgoing call that's a child of an incoming request. (Handled correctly)
- An incoming call that's generated with trace and span id headers. (Not handled correctly).
In case #2, the incoming span id is set to the parent id and outgoing calls are assigned a completely new trace id. It seems like a stop ship defect, tbh.
There was a problem hiding this comment.
OK, I understand now, in case #2 the span is not really a "root" span from the overall trace's perspective (the true root of the trace lies in an upstream service), but rather is only a "root" from this particular Node.js process's perspective.
In my opinion at some time in the future, it might be nice to just consolidate the distinction between a "root span" and a regular span as in this case it's actually incorrect to call it a root since it's only a root relative to this process. But I can approve this to unblock the issue.
There was a problem hiding this comment.
In my opinion at some time in the future, it might be nice to just consolidate the distinction between a "root span" and a regular span as in this case it's actually incorrect to call it a root since it's only a root relative to this process. But I can approve this to unblock the issue.
I agree with you and I think we should consider this in OpenTelemetry project.
|
@draffensperger Any more thoughts on this? It's a blocking defect for us. |
Thanks for the suggestion, but I am not sure about the extra check. AFAIK Root Span should always be set to context manager. For me, |
Fair enough. Please merge away. I will use our systems to thoroughly test the fix and report whatever I find. |
After consolidation of
SpanandRootSpan, we set the RootSpan to CurrentRootSpan only whenparentSpanIdis null.Which is:
This causes an issue when
parentSpanIdis propagating on wire. In that case, although we create a newRootSpanit does not get set to CurrentRootSpan, therefore we create a new root span (instead of child span) for subsequent (outgoing) request.which is:
Please use #566 (comment) example to reproduce the problem.
This PR will set CurrentRootSpan whenever created/started span is
RootSpan.