Package zipkin2.reporter.kafka
Class KafkaSender
- java.lang.Object
-
- zipkin2.reporter.Component
-
- zipkin2.reporter.Sender
-
- zipkin2.reporter.kafka.KafkaSender
-
- All Implemented Interfaces:
Closeable,AutoCloseable,BytesMessageSender
public final class KafkaSender extends Sender
This sends (usually json v2) encoded spans to a Kafka topic.Usage
This type is designed for
the async reporter.Here's a simple configuration, configured for json:
sender = KafkaSender.create("localhost:9092");Here's an example that overrides properties and protocol buffers encoding:
Properties overrides = new Properties(); overrides.put(ProducerConfig.MAX_BLOCK_MS_CONFIG, 5000); sender = KafkaSender.newBuilder() .bootstrapServers("host1:9092,host2:9092") .overrides(overrides) .encoding(Encoding.PROTO3) .build();Compatibility with Zipkin Server
Zipkin server should be v1.26 or higher.Implementation Notes
This sender is thread-safe. This sender is linked against Kafka 0.10.2+, which allows it to work with Kafka 0.10+ brokers
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classKafkaSender.BuilderConfiguration including defaults needed to send spans to a Kafka topic.-
Nested classes/interfaces inherited from interface zipkin2.reporter.BytesMessageSender
BytesMessageSender.Base
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description CheckResultcheck()Deprecated.voidclose()static KafkaSendercreate(String bootstrapServers)Creates a sender that sendsEncoding.JSONmessages.Encodingencoding()intmessageMaxBytes()intmessageSizeInBytes(int encodedSizeInBytes)intmessageSizeInBytes(List<byte[]> encodedSpans)static KafkaSender.BuildernewBuilder()voidsend(List<byte[]> encodedSpans)This sends all the spans as a single message.Call<Void>sendSpans(List<byte[]> encodedSpans)Deprecated.KafkaSender.BuildertoBuilder()StringtoString()
-
-
-
Method Detail
-
create
public static KafkaSender create(String bootstrapServers)
Creates a sender that sendsEncoding.JSONmessages.
-
newBuilder
public static KafkaSender.Builder newBuilder()
-
toBuilder
public KafkaSender.Builder toBuilder()
-
messageSizeInBytes
public int messageSizeInBytes(List<byte[]> encodedSpans)
-
messageSizeInBytes
public int messageSizeInBytes(int encodedSizeInBytes)
- Specified by:
messageSizeInBytesin interfaceBytesMessageSender- Overrides:
messageSizeInBytesin classSender
-
encoding
public Encoding encoding()
-
messageMaxBytes
public int messageMaxBytes()
-
sendSpans
@Deprecated public Call<Void> sendSpans(List<byte[]> encodedSpans)
Deprecated.
-
send
public void send(List<byte[]> encodedSpans)
This sends all the spans as a single message.NOTE: this blocks until the metadata server is available.
- Specified by:
sendin interfaceBytesMessageSender- Overrides:
sendin classSender
-
check
@Deprecated public CheckResult check()
Deprecated.
-
close
public void close()
-
-