Class TraceContextPropagation
java.lang.Object
com.linecorp.armeria.client.brave.TraceContextPropagation
Manually propagates a
TraceContext
to a BraveClient
.-
Method Summary
Modifier and TypeMethodDescriptionstatic Consumer<ClientRequestContext>
inject
(Supplier<TraceContext> traceContextSupplier) Injects the currentTraceContext
throughClientBuilder.contextCustomizer(Consumer)
orClients.withContextCustomizer(Consumer)
.
-
Method Details
-
inject
@UnstableApi public static Consumer<ClientRequestContext> inject(Supplier<TraceContext> traceContextSupplier) Injects the currentTraceContext
throughClientBuilder.contextCustomizer(Consumer)
orClients.withContextCustomizer(Consumer)
. The injectedTraceContext
will be propagated toBraveClient
as a parentSpan
.Basically, a parent
TraceContext
is automatically propagated toBraveClient
if you useBraveService
. This method is useful if you want to manually propagate the currentTraceContext
toBraveClient
in non-Armeria server environment.Tracing threadLocalTracing = ...; Tracing requestContextTracing = Tracing.newBuilder() .currentTraceContext(RequestContextCurrentTraceContext.ofDefault()) .build(); Clients.builder(...) .contextCustomizer(TraceContextPropagation.inject(() -> { return threadLocalTracing.currentTraceContext().get(); }) .decorator(BraveClient.newDecorator(requestContextTracing)) .build();
-