Class ZipkinSpanHandler

  • All Implemented Interfaces:
    Closeable, AutoCloseable
    Direct Known Subclasses:
    AsyncZipkinSpanHandler

    public class ZipkinSpanHandler
    extends brave.handler.SpanHandler
    implements Closeable
    This allows you to send spans recorded by Brave to a pre-configured Zipkin reporter.

    If you can't use AsyncZipkinSpanHandler because you are using an old format, construct the span handler like this:

    
     reporter = AsyncReporter.builder(URLConnectionSender.create("http://localhost:9411/api/v1/spans"))
                             .build(SpanBytesEncoder.JSON_V1);
     tracingBuilder.addSpanHandler(ZipkinSpanHandler.create(reporter));
     

    Note: Use AsyncZipkinSpanHandler if you are using SpanBytesEncoder.JSON_V2 format. This handler has to convert MutableSpan into Span, and that conversion happens inline (during production requests) upon Span.finish() or Span.flush().

    Since:
    2.13
    See Also:
    AsyncZipkinSpanHandler, Tracing.Builder.addSpanHandler(SpanHandler)
    • Method Detail

      • create

        public static brave.handler.SpanHandler create​(Reporter<zipkin2.Span> spanReporter)
        Since:
        2.13
      • close

        public void close()
        Implementations that throw exceptions on close have bugs. This may result in log warnings, though.
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
        Since:
        2.15
      • end

        public boolean end​(brave.propagation.TraceContext context,
                           brave.handler.MutableSpan span,
                           brave.handler.SpanHandler.Cause cause)
        Overrides:
        end in class brave.handler.SpanHandler
      • equals

        public final boolean equals​(Object o)
        Overridden to avoid duplicates when added via Tracing.Builder.addSpanHandler(SpanHandler)
        Overrides:
        equals in class Object
      • hashCode

        public final int hashCode()
        Overridden to avoid duplicates when added via Tracing.Builder.addSpanHandler(SpanHandler)
        Overrides:
        hashCode in class Object