public interface Sender
extends zipkin.Component
Collector.
Unless mentioned otherwise, senders are not thread-safe. They were designed to be used by
AsyncReporter, which has a single reporting thread.
Those looking to initialize eagerly should call Component.check(). This can be used to reduce
latency on the first send operation, or to fail fast.
Implementation notes
The parameter is a list of encoded spans as opposed to an encoded message. This allows implementations flexibility on how to encode spans into a message. For example, a large span might need to be sent as a separate message to avoid kafka limits. Also, logging transports like scribe will likely write each span as a separate log line.
This accepts a list of encoded spans, as opposed a list of
spans like Span. This allows senders to be re-usable as model shapes change. This
also allows them to use their most natural message type. For example, kafka would more naturally
send messages as byte arrays.
If performance is critical, thrift encoding is most efficient,
sometimes 3x faster than json.
| Modifier and Type | Method and Description |
|---|---|
Encoding |
encoding()
Returns the encoding this sender requires spans to have.
|
int |
messageMaxBytes()
Maximum bytes sendable per message including overhead.
|
int |
messageSizeInBytes(List<byte[]> encodedSpans)
Before invoking
sendSpans(List, Callback), callers must consider message
overhead, which might be more than encoding overhead. |
void |
sendSpans(List<byte[]> encodedSpans,
Callback callback)
Sends a list of encoded spans to a transport such as http or Kafka.
|
Encoding encoding()
int messageMaxBytes()
messageSizeInBytes(List)int messageSizeInBytes(List<byte[]> encodedSpans)
sendSpans(List, Callback), callers must consider message
overhead, which might be more than encoding overhead. This is used to not exceed messageMaxBytes().
Note this is not always Encoding.listSizeInBytes(List), as some senders have
inefficient list encoding. For example, Scribe base64's then tags each span with a category.
void sendSpans(List<byte[]> encodedSpans, Callback callback)
Note: Eventhough there's a callback, there's no guarantee implementations won't block. Accordingly, this method should not be called on the operation being measured's thread.
encodedSpans - list of encoded spans.callback - signals either completion or failureIllegalStateException - if close was called.Copyright © 2016–2017 OpenZipkin. All rights reserved.