4.1.3: Add context propagation to the Zipkin tracing provider (#9119) #9385
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport of #9119 to Helidon 4.1.3
Description
Resolves #8848 for Zipkin.
Changes:
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.)
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 HelidonTracer
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 theprovider-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:
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 ofglobal()
.LazyValue
factory lambda and in theOpenTracingTracerProvider#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.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.(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.