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

Add context propagation to the Zipkin tracing provider #9119

Merged
merged 4 commits into from
Oct 14, 2024

Conversation

tjquinno
Copy link
Member

@tjquinno tjquinno commented Aug 8, 2024

Description

Resolves #8848 for Zipkin.

Changes:

  1. Add a context propagator implementation for Zipkin. This permits Helidon to propagate Zipkin trace information across threads within a Helidon server. (That's distinct from trace propagation via HTTP headers which is handled in other code and already worked prior to this PR.)

  2. Correct the handling of the global tracer in the Helidon OpenTracing provider component.

    Our Zipkin tracing provider component relies to some extent on our OpenTracing provider types. If a user includes the Zipkin tracing provider then OpenTracing comes along and our Zipkin implementation uses OpenTracing.

    Previously, invoking OpenTracingTracerProvider#global() would return a new Helidon Tracer instance every time. Those instances would all wrap the single OpenTracing global tracer (whatever it is), but that's inefficient and caused failures in an existing propagation test in the provider-tests component. That test had been excluded for Zipkin because of the prior lack of propagation support.

    This PR changes two aspects of the global tracer handling in OpenTracing:

    1. Use LazyValue for the Helidon global tracer maintained by our OpenTracing provider so we reuse it appropriately rather than creating a new one on each invocation of global().
    2. Both in the LazyValue factory lambda and in the OpenTracingTracerProvider#global(Tracer) method not only set or update the Helidon global tracer lazy value but also manage OpenTracing's similar mechanism. OpenTracing lets us supply code we want OpenTracing to run to create the OpenTracing global tracer. By specifying our code for this work we make sure our global Helidon tracer and the delegate global tracer in OpenTracing are in step.
  3. Remove the exclusion in the Zipkin provider pom.xml of the common context propagation test. The pom does now invoke it in a separate surefire execution to make sure the test has a functioning global tracer undisturbed by other tests.

  4. (Otherwise untouched for this enhancement) Add public constructor to ZipkinTracerProvider to clear the Javadoc warning.

Documentation

Bug fix. Our tracing documentation does not discuss context propagation across threads within a server, so this PR has no doc impact.

@tjquinno tjquinno self-assigned this Aug 8, 2024
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Aug 8, 2024
@tjquinno tjquinno marked this pull request as draft August 8, 2024 21:33
@tjquinno
Copy link
Member Author

tjquinno commented Aug 8, 2024

I have asked Tomas about the test failure. Basically, now that Zipkin is properly doing context propagation the test which is failing is finding tracing information in the context where it does not expect it (because our Zipkin code did not do propagation previously).

The changes to the global tracer handling automatically created a functional tracer (not a no-op one) even when no tracing config was present. That was incorrect. I've revised those changes.

@tjquinno tjquinno marked this pull request as ready for review August 9, 2024 16:54
@tjquinno tjquinno merged commit 91627f7 into helidon-io:main Oct 14, 2024
44 checks passed
@tjquinno tjquinno deleted the 4.x-zipkin-prop branch October 14, 2024 12:43
barchetta pushed a commit to barchetta/helidon that referenced this pull request Oct 14, 2024
* Add context propagation to the Zipkin tracing provider

Signed-off-by: Tim Quinn <[email protected]>
barchetta added a commit that referenced this pull request Oct 14, 2024
* Add context propagation to the Zipkin tracing provider

Signed-off-by: Tim Quinn <[email protected]>
Co-authored-by: Tim Quinn <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Zipkin (and OpenTracing) tracing providers do not provide context propagation
2 participants