Fix trace and traceSync not creating root spans when newRoot is true #214
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Which problem is this PR solving?
trace
andtraceSync
have anewRoot
optional parameter that works by usingContext.root
to start the span. However, if there is a context with a span attached to the root zone, then usingContext.root
will make the span a child of the one held by the context attached to the root zone.Short description of the change
The
Tracer
defined by the SDK supports thenewRoot
optional parameter that results in appropriately configuring the span's parent span context to be invalid regardless of any span potentially visible via the given context.However, the
Tracer
defined by the API does not support thenewRoot
optional parameter. Ideally, this interface would be updated to include the optional parameter. But this is a breaking change.Therefore, to resolve the issue of
newRoot
not creating root spans,trace
andtraceSync
type check thetracer
to see if it is the SDK'sTracer
. If so, the tracer'snewRoot
option is used. Otherwise, the API'stracer
is used as usual.How Has This Been Tested?
The unit tests added in this PR were ran with and without the changes. Without the changes, the unit tests fail. With the changes, the unit tests pass.
Checklist: