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

SpanBuilder: Add convenience method for parent-less span #1407

Open
cedricziel opened this issue Oct 16, 2024 · 1 comment
Open

SpanBuilder: Add convenience method for parent-less span #1407

cedricziel opened this issue Oct 16, 2024 · 1 comment

Comments

@cedricziel
Copy link
Contributor

Is your feature request related to a problem?
When batch-processing messages from a queue, it is not great to have all message spans related to the parent span, but rather be traces on their own.

In the Java instrumentation, there is a convenience builder method called setNoParent, which sets an empty context to create a fresh trace.

Describe the solution you'd like
Add a convenience method to the SpanBuilder to ease creation of parent-less spans.

Describe alternatives you've considered
There's an unintuitive workaround which requires instrinsic knowledge about the SDK:

$span = $tracer-spanBuilder('process')
  ->setParent(Context::getRoot()) // set an empty root
  ->startSpan();

Additional context
Add any other context about the feature request here.

@brettmc
Copy link
Collaborator

brettmc commented Oct 16, 2024

We actually used to have this, but it looks like it was consolidated into setParent some time ago: https://github.com/open-telemetry/opentelemetry-php/pull/820/files
I think that setParent(false) is the same thing, if that helps but could be better documented?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants