Package zipkin2.reporter
Class AsyncReporter<S>
- java.lang.Object
-
- zipkin2.Component
-
- zipkin2.reporter.AsyncReporter<S>
-
- Type Parameters:
S- type of the span, usuallySpan
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable,Reporter<S>
public abstract class AsyncReporter<S> extends zipkin2.Component implements Reporter<S>, Flushable
As spans are reported, they are encoded and added to a pending queue. The task of sending spans happens on a separate thread which callsflush(). By doing so, callers are protected from latency or exceptions possible when exporting spans out of process.Spans are bundled into messages based on size in bytes or a timeout, whichever happens first.
The thread that sends flushes spans to the Sender does so in a synchronous loop. This means that even asynchronous transports will wait for an ack before sending a next message. We do this so that a surge of spans doesn't overrun memory or bandwidth via hundreds or thousands of in-flight messages. The downside of this is that reporting is limited in speed to what a single thread can clear. When a thread cannot clear the backlog, new spans are dropped.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAsyncReporter.Builder
-
Constructor Summary
Constructors Constructor Description AsyncReporter()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static AsyncReporter.Builderbuilder(Sender sender)Likecreate(Sender), except you can configure settings such as the timeout.abstract voidclose()Shuts down the sender thread, and increments drop metrics if there were any unsent spans.static AsyncReporter<zipkin2.Span>create(Sender sender)Builds a json reporter for Zipkin V2.abstract voidflush()Calling this will flush any pending spans to the transport on the current thread.
-
-
-
Method Detail
-
create
public static AsyncReporter<zipkin2.Span> create(Sender sender)
-
builder
public static AsyncReporter.Builder builder(Sender sender)
Likecreate(Sender), except you can configure settings such as the timeout.
-
flush
public abstract void flush()
Calling this will flush any pending spans to the transport on the current thread.Note: If you set
message timeoutto zero, you must call this externally as otherwise spans will never be sent.- Specified by:
flushin interfaceFlushable- Throws:
IllegalStateException- if closed
-
close
public abstract void close()
Shuts down the sender thread, and increments drop metrics if there were any unsent spans.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classzipkin2.Component
-
-