Class 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
    • Method Detail

      • create

        public static BraveTracer create​(brave.Tracing brave4)
        Returns an implementation of Tracer which delegates to the provided Brave Tracing component, which coordinates with Brave's CurrentTraceContext to implement ScopeManager.
      • unwrap

        public brave.Tracing unwrap()
        Returns the underlying Tracing instance used to configure this.
      • scopeManager

        public BraveScopeManager scopeManager()
        Specified by:
        scopeManager in interface io.opentracing.Tracer
      • activeSpan

        public BraveSpan activeSpan()
        Specified by:
        activeSpan in interface io.opentracing.Tracer
      • activateSpan

        public BraveScope activateSpan​(io.opentracing.Span span)
        Specified by:
        activateSpan in interface io.opentracing.Tracer
      • buildSpan

        public BraveSpanBuilder buildSpan​(String operationName)
        Specified by:
        buildSpan in interface io.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:
        inject in interface io.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:
        extract in interface io.opentracing.Tracer
      • close

        public void close()
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
        Specified by:
        close in interface io.opentracing.Tracer