Skip to content
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

Fix trace and traceSync not creating root spans when newRoot is true #214

Merged
merged 1 commit into from
Mar 4, 2025

Conversation

blakeroberts-wk
Copy link
Contributor

Which problem is this PR solving?

trace and traceSync have a newRoot optional parameter that works by using Context.root to start the span. However, if there is a context with a span attached to the root zone, then using Context.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 the newRoot 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 the newRoot 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 and traceSync type check the tracer to see if it is the SDK's Tracer. If so, the tracer's newRoot option is used. Otherwise, the API's tracer 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:

  • Unit tests have been added
  • Documentation has been updated

…eating new root spans even when a context with a span is attached to the root zone
@blakeroberts-wk
Copy link
Contributor Author

QA +1 CI is sufficient

attributes: spanAttributes,
kind: spanKind,
links: spanLinks);
// TODO: use start span option `newRoot` instead
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has this TODO essentially been resolved now? thoughts on removing it here and below?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. The option is only on the sdk's implementation class of the api's interface which doesn't have the option. The next breaking release (0.16.0) will need to contain the change to add the new option to the interface that will allow us to remove this TODO and simplify the code down to just invoking the method on the given interface

@blakeroberts-wk
Copy link
Contributor Author

@Workiva/release-management-p

Copy link

@rmconsole-wf rmconsole-wf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 from RM

@btr-rmconsole-1 btr-rmconsole-1 bot merged commit b6b2089 into master Mar 4, 2025
3 checks passed
@btr-rmconsole-1 btr-rmconsole-1 bot deleted the fix-new-root branch March 4, 2025 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants