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

OpenTelemetryTracer#spanBuilder always sets parent to active span; how can developers create a root span (with no parent)? #8736

Closed
tjquinno opened this issue May 8, 2024 · 0 comments
Assignees
Labels
Projects

Comments

@tjquinno
Copy link
Member

tjquinno commented May 8, 2024

Environment Details

  • Helidon Version: 4.x
  • Helidon SE or Helidon MP
  • JDK version:
  • OS:
  • Docker version (if applicable):

Problem Description

The Helidon OpenTelemetryTracer#spanBuilder implementation of our neutral Tracer interface always sets the parent of the new span builder to the currently-active span (if there is one).

How can developers create a root OTel span (with no parent)?

Answer

OpenTelemetry's SpanBuilder type exposes the setNoParent() method which does exactly what you expect...it clears out any current parent setting for the span builder.

So developers using the Helidon tracing API can do the following _if they know they are using the Helidon OpenTelemetry implementation of the Helidon tracing API:

    Span rootSpan = tracer.spanBuilder("rootSpan")
            .update(builder -> builder.unwrap(io.opentelemetry.api.trace.SpanBuilder.class).setNoParent())
            .start();

The example code works only if the Helidon OpenTelemetry implementation is in use. The unwrap will fail (in fact it will probably not even compile) if you are using a different Helidon tracer provider.

@tjquinno tjquinno added this to Triage in Backlog via automation May 8, 2024
@tjquinno tjquinno changed the title OpenTelemetryTracer#spanBuilder always sets parent to active span; should this be left to the developer? OpenTelemetryTracer#spanBuilder always sets parent to active span; should this be left to the developer? (probably yes) May 20, 2024
@tjquinno tjquinno self-assigned this May 22, 2024
@tjquinno tjquinno moved this from Triage to Sprint Scope in Backlog May 22, 2024
@tjquinno tjquinno added bug Something isn't working P2 and removed triage labels May 22, 2024
@tjquinno tjquinno changed the title OpenTelemetryTracer#spanBuilder always sets parent to active span; should this be left to the developer? (probably yes) OpenTelemetryTracer#spanBuilder always sets parent to active span; how can developers create a root span (with no parent)? May 24, 2024
@tjquinno tjquinno removed the bug Something isn't working label May 24, 2024
Backlog automation moved this from Sprint Scope to Closed May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Backlog
  
Closed
Development

No branches or pull requests

1 participant