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

Tags provided in config are missing in traces while using OpenTracing #7998

Closed
nairiti-sharma opened this issue Nov 14, 2023 · 4 comments
Closed
Assignees
Labels
3.x Issues for 3.x version branch bug Something isn't working P2 tracing

Comments

@nairiti-sharma
Copy link

Environment Details

  • Helidon Version: 3.2.2
  • Helidon SE
  • JDK version: JDK 17

While using OpenTracing on 3.2.2, we observed that tags set in config files do not appear in the traces collected. In case of Open Telemetry , this works fine.

While creating spanBuilder in OpenTelemetryTracer, the following is used.

@Override
public Span.Builder<?> spanBuilder(String name) {
    OpenTelemetrySpanBuilder builder = new OpenTelemetrySpanBuilder(delegate.spanBuilder(name));
    tags.forEach(builder::tag);
    return builder;
}

But, in case of OpenTracingTracer, it is as below, where setting the tag part is missing (tags.forEach(builder::tag);)

public Span.Builder<?> spanBuilder(String name) {
    return new OpenTracingSpanBuilder(delegate, delegate.buildSpan(name));
}
@m0mus m0mus added tracing 3.x Issues for 3.x version branch bug Something isn't working P2 labels Nov 16, 2023
@dalexandrov
Copy link
Contributor

dalexandrov commented Nov 22, 2023

Hello,
can you please provide more details?
I have created a sample Helidon SE project with OpenTracing and Zipkin, and it works ok:

The config is:

tracing:
  service: "helidon-service"
  tags:
    tag1: "tag1-value"
    tag2: "tag2-value"
image

@vasanth-bhat
Copy link

Thanks, Tried out sample, sending traces to "jaeger-all-in-one"
There is one difference.

In case of. "helidon-tracing-jaeger", the tracer tags from config show up as Process tags

image

@vasanth-bhat
Copy link

With "helidon-tracing-zipkins" , these show up as regular Span tags, and not under Process (Tracer Tags)

image

@dalexandrov dalexandrov removed their assignment Dec 7, 2023
@m0mus m0mus modified the milestones: 4.0.3, 3.2.6 Dec 21, 2023
@tjquinno
Copy link
Member

tjquinno commented Feb 7, 2024

Closing this issue: works as designed.

TL;DR - The Zipkin data model does not support trace-level (also known as process-level) tags, although Jaeger and the Helidon tracing API do. To preserve trace-level tags in the only way available, the Helidon adapter for Zipkin adds them to each span. That is why the U/I distinguishes between process and span tags for Jaeger but not for Zipkin.

Zipkin doc of their data model Scroll down to the Model section and expand Trace. It consists only of a list of spans; there are no tags at the trace level (or under Endpoint which might have been another option).

To create an example:

Prep

  1. Start with the Helidon SE QuickStart app.

  2. Add the following to application.yaml:

    tracing:
      service: "test-my-app"
      enabled: true
      sample-type: "const"
      sample-param: 1
      propagation: [ "jaeger", "b3_single", "w3c" ]
      span-processor-type: simple
      tags:
        tag1: "tag1-value"  # JAEGER_TAGS
        tag2: "tag2-value"  # JAEGER_TAGS
      boolean-tags:
        tag3: true          # JAEGER_TAGS
        tag4: false         # JAEGER_TAGS
      int-tags:
        tag5: 145           # JAEGER_TAGS
        tag6: 741           # JAEGER_TAGS
    
  3. Add the following to pom.xml:

        <dependency>
            <groupId>io.helidon.tracing</groupId>
            <artifactId>helidon-tracing</artifactId>
        </dependency>
        <dependency>
            <groupId>io.helidon.tracing</groupId>
            <artifactId>helidon-tracing-jaeger</artifactId>
        </dependency>
    <!--    <dependency> -->
    <!--        <groupId>io.helidon.tracing</groupId> -->
    <!--        <artifactId>helidon-tracing-zipkin</artifactId> -->
    <!--    </dependency> -->
    
  4. In the GreetService class change the body of the getDefaultMessageHandler method to this:

    Tracer tracer = request.context().get(Tracer.class).orElse(Tracer.global());
    Span.Builder<?> spanBuilder = tracer.spanBuilder("anon-greeting").tag("sp1", "val1");
    request.context().get(SpanContext.class).ifPresent(spanBuilder::parent);
    Span span = spanBuilder.start();
    try (Scope scope = span.activate()) {
        sendResponse(response, "World");
        span.end();
    } catch (Exception ex) {
        span.end(ex);
    }
    
  5. Start Jaeger and Zipkin locally.

Try with Jaeger

  1. Build and run the Helidon QuickStart SE app you modified.

  2. Access the default greeting endpoint: curl http://localhost:8080/greet

  3. Browse to http://localhost:16686, the Jaeger U/I.

  4. From the Services droplist select test-my-app (that is the tracing service name in application.yaml).

  5. Click the Find Traces button, then click the top trace row, then click the anon-greeting span.

    The Tags display shows (among others) sp1=val1 which is a span-level tag assigned explicitly in the updated GreetService code. The Process display shows (among others) tag1=tag1-value (and tag2 and tag3) which are tracer-level tags assigned in the updated application.yaml in the tracing section.

image

  1. Stop the quickstart app.

Try with Zipkin

  1. In the dependencies you added to pom.xml comment out the one for Jaeger and uncomment the one for Zipkin.
  2. Build and run the app again.
  3. Browse to http://localhost:9411, the Zipkin U/I.
  4. Click the Run Query button, then click the SHOW button next to the trace it displays.
  5. Click the up-arrow near the upper left of the window which expands to show the child spans.
  6. the top span, then click the + sign next to the trace.
  7. Click the anon-greeting span, then click SHOW ALL ANNOTATIONS button.
  8. The Tags list includes both the tracer-level tags (tag1, tag2, etc.) and the span-level tag (sp1).
    image

@tjquinno tjquinno closed this as completed Feb 7, 2024
@tjquinno tjquinno removed this from the 3.2.6 milestone Feb 7, 2024
@m0mus m0mus added this to Backlog Aug 12, 2024
@m0mus m0mus moved this to Closed in Backlog Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.x Issues for 3.x version branch bug Something isn't working P2 tracing
Projects
Archived in project
Development

No branches or pull requests

5 participants