Package zipkin2.reporter
Class AsyncReporter<S>
- java.lang.Object
-
- zipkin2.reporter.Component
-
- zipkin2.reporter.AsyncReporter<S>
-
- Type Parameters:
S- type of the span, usuallySpan
public class AsyncReporter<S> extends 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
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static AsyncReporter.Builderbuilder(Sender sender)Likecreate(Sender), except you can configure settings such as the timeout.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.voidflush()Calling this will flush any pending spans to the transport on the current thread.voidreport(S span)Schedules the span to be sent onto the transport.StringtoString()
-
-
-
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.
-
report
public void report(S span)
Description copied from interface:ReporterSchedules the span to be sent onto the transport.
-
flush
public 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 void close()
Shuts down the sender thread, and increments drop metrics if there were any unsent spans.
-
-