Package zipkin2.reporter.brave
Class ZipkinSpanHandler
java.lang.Object
brave.handler.SpanHandler
zipkin2.reporter.brave.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)
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classZipkinSpanHandler.Builder -
Field Summary
-
Method Summary
Modifier and Type Method Description voidclose()Implementations that throw exceptions on close have bugs.static brave.handler.SpanHandlercreate(Reporter<zipkin2.Span> spanReporter)booleanend(brave.propagation.TraceContext context, brave.handler.MutableSpan span, brave.handler.SpanHandler.Cause cause)booleanequals(Object o)Overridden to avoid duplicates when added viaTracing.Builder.addSpanHandler(SpanHandler)inthashCode()Overridden to avoid duplicates when added viaTracing.Builder.addSpanHandler(SpanHandler)static ZipkinSpanHandler.BuildernewBuilder(Reporter<zipkin2.Span> spanReporter)ZipkinSpanHandler.BuildertoBuilder()Allows this instance to be reconfigured, for exampleZipkinSpanHandler.Builder.alwaysReportSpans(boolean).StringtoString()
-
Method Details
-
create
- Since:
- 2.13
-
newBuilder
- Since:
- 2.13
-
toBuilder
Allows this instance to be reconfigured, for exampleZipkinSpanHandler.Builder.alwaysReportSpans(boolean).Note: Call
close()if you no longer need this instance, as otherwise it can leak resources.- Since:
- 2.15
-
close
public void close()Implementations that throw exceptions on close have bugs. This may result in log warnings, though.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Since:
- 2.15
-
end
public boolean end(brave.propagation.TraceContext context, brave.handler.MutableSpan span, brave.handler.SpanHandler.Cause cause)- Overrides:
endin classbrave.handler.SpanHandler
-
toString
-
equals
Overridden to avoid duplicates when added viaTracing.Builder.addSpanHandler(SpanHandler) -
hashCode
public final int hashCode()Overridden to avoid duplicates when added viaTracing.Builder.addSpanHandler(SpanHandler)
-