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 class  BraveTracer.Builder  

    Nested classes/interfaces inherited from interface io.opentracing.Tracer

    io.opentracing.Tracer.SpanBuilder
  • Method Summary

    Modifier and Type Method Description
    BraveScope activateSpan​(io.opentracing.Span span)  
    BraveSpan activeSpan()  
    BraveSpanBuilder buildSpan​(java.lang.String operationName)  
    void close()  
    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.
    <C> BraveSpanContext extract​(io.opentracing.propagation.Format<C> format, C carrier)
    Extracts the underlying context using B3 encoding by default.
    <C> void inject​(io.opentracing.SpanContext spanContext, io.opentracing.propagation.Format<C> format, C carrier)
    Injects the underlying context using B3 encoding by default.
    static BraveTracer.Builder newBuilder​(brave.Tracing brave4)
    Returns a BraveTracer.Builder configured with the provided Brave Tracing provided Brave Tracing component and uses an instance of BraveScopeManager for its ScopeManager.
    BraveScopeManager scopeManager()  
    brave.Tracing unwrap()
    Returns the underlying Tracing instance used to configure this.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • 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.
    • newBuilder

      public static BraveTracer.Builder newBuilder​(brave.Tracing brave4)
      Returns a BraveTracer.Builder configured with the provided Brave Tracing provided Brave Tracing component and uses an instance of BraveScopeManager for its 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​(java.lang.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

      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 java.lang.AutoCloseable
      Specified by:
      close in interface java.io.Closeable
      Specified by:
      close in interface io.opentracing.Tracer