Class AsyncReporter<S>

  • Type Parameters:
    S - type of the span, usually Span
    All Implemented Interfaces:
    Closeable, Flushable, Reporter<S>

    public class AsyncReporter<S>
    extends Component
    implements Reporter<S>, Closeable, 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 calls flush(). 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 BytesMessageSender 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.