Package brave.opentracing
Class BraveTracer
java.lang.Object
brave.opentracing.BraveTracer
- All Implemented Interfaces:
io.opentracing.Tracer,java.io.Closeable,java.lang.AutoCloseable
public final class BraveTracer
extends java.lang.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
Modifier and Type Method Description BraveScopeactivateSpan(io.opentracing.Span span)BraveSpanactiveSpan()BraveSpanBuilderbuildSpan(java.lang.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 Details
-
create
Returns an implementation ofTracerwhich delegates to the provided BraveTracingcomponent, which coordinates with Brave'sCurrentTraceContextto implement ScopeManager. -
newBuilder
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
- Specified by:
scopeManagerin interfaceio.opentracing.Tracer
-
activeSpan
- Specified by:
activeSpanin interfaceio.opentracing.Tracer
-
activateSpan
- Specified by:
activateSpanin interfaceio.opentracing.Tracer
-
buildSpan
- 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
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 interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein interfaceio.opentracing.Tracer
-