Package brave.opentracing
Class BraveTracer
- java.lang.Object
-
- brave.opentracing.BraveTracer
-
- All Implemented Interfaces:
io.opentracing.Tracer,Closeable,AutoCloseable
public final class BraveTracer extends Object implements io.opentracing.Tracer
Using a tracer, you can create a spans, inject span contexts into a transport, and extract span contexts from a transport Here's an example:Tracer tracer = BraveTracer.wrap(tracing); Span span = tracer.buildSpan("DoWork").start(); tracer.inject(span.context()); ... SpanContext clientContext = tracer.extract(Format.Builtin.HTTP_HEADERS, request.getHeaders()); Span clientSpan = tracer.buildSpan('...').asChildOf(clientContext).start();Propagation
This uses the same propagation as defined in zipkin for text formats. B3 Single is used for binary formats.- See Also:
BraveSpan,Propagation
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBraveTracer.Builder
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BraveScopeactivateSpan(io.opentracing.Span span)BraveSpanactiveSpan()BraveSpanBuilderbuildSpan(String operationName)voidclose()static BraveTracercreate(brave.Tracing brave4)Returns an implementation ofTracerwhich delegates to the provided BraveTracingcomponent, which coordinates with Brave'sCurrentTraceContextto implement ScopeManager.<C> BraveSpanContextextract(io.opentracing.propagation.Format<C> format, C carrier)Extracts the underlying context using B3 encoding by default.<C> voidinject(io.opentracing.SpanContext spanContext, io.opentracing.propagation.Format<C> format, C carrier)Injects the underlying context using B3 encoding by default.static BraveTracer.BuildernewBuilder(brave.Tracing brave4)Returns aBraveTracer.Builderconfigured with the provided BraveTracingprovided BraveTracingcomponent and uses an instance ofBraveScopeManagerfor itsScopeManager.BraveScopeManagerscopeManager()brave.Tracingunwrap()Returns the underlyingTracinginstance used to configure this.
-
-
-
Method Detail
-
create
public static BraveTracer create(brave.Tracing brave4)
Returns an implementation ofTracerwhich delegates to the provided BraveTracingcomponent, which coordinates with Brave'sCurrentTraceContextto implement ScopeManager.
-
newBuilder
public static BraveTracer.Builder newBuilder(brave.Tracing brave4)
Returns aBraveTracer.Builderconfigured with the provided BraveTracingprovided BraveTracingcomponent and uses an instance ofBraveScopeManagerfor itsScopeManager.
-
unwrap
public brave.Tracing unwrap()
Returns the underlyingTracinginstance used to configure this.
-
scopeManager
public BraveScopeManager scopeManager()
- Specified by:
scopeManagerin interfaceio.opentracing.Tracer
-
activeSpan
public BraveSpan activeSpan()
- Specified by:
activeSpanin interfaceio.opentracing.Tracer
-
activateSpan
public BraveScope activateSpan(io.opentracing.Span span)
- Specified by:
activateSpanin interfaceio.opentracing.Tracer
-
buildSpan
public BraveSpanBuilder buildSpan(String operationName)
- Specified by:
buildSpanin interfaceio.opentracing.Tracer
-
inject
public <C> void inject(io.opentracing.SpanContext spanContext, io.opentracing.propagation.Format<C> format, C carrier)Injects the underlying context using B3 encoding by default.- Specified by:
injectin interfaceio.opentracing.Tracer
-
extract
@Nullable public <C> BraveSpanContext extract(io.opentracing.propagation.Format<C> format, C carrier)
Extracts the underlying context using B3 encoding by default. Null is returned when there is no encoded context in the carrier, or upon error extracting it.- Specified by:
extractin interfaceio.opentracing.Tracer
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceio.opentracing.Tracer
-
-