Find file History
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
src Check-health for Kafka Collector (#2168) Aug 19, 2018
README.md updated example to suggest v2 encoding Jan 5, 2019
pom.xml [maven-release-plugin] prepare for next development iteration Jan 17, 2019

README.md

collector-kafka10

KafkaCollector

This collector is implemented as a Kafka consumer supporting Kafka brokers running version 0.10.0.0 or later. It polls a Kafka topic for messages that contain a list of spans in json or TBinaryProtocol big-endian encoding. These spans are pushed to a span consumer.

For information about running this collector as a module in Zipkin server, see zipkin-autoconfigure/collector-kafka10.

When using this collector as a library outside of Zipkin server, zipkin2.collector.kafka.KafkaCollector.Builder includes defaults that will operate against a Kafka topic name zipkin.

Encoding spans into Kafka messages

The message's binary data includes a list of spans. Supported encodings are the same as the http POST /spans body.

Json

The message's binary data is a list of spans in json. The first character must be '[' (decimal 91).

Codec.JSON.writeSpans(spans) performs the correct json encoding.

Here's an example, sending a list of a single span to the zipkin topic:

$ kafka-console-producer.sh --broker-list $ADVERTISED_HOST:9092 --topic zipkin
[{"traceId":"1","name":"bang","id":"2","timestamp":1470150004071068,"duration":1,"localEndpoint":{"serviceName":"flintstones"},"tags":{"lc":"bamm-bamm"}}]

Thrift

The message's binary data includes a list header followed by N spans serialized in TBinaryProtocol

Codec.THRIFT.writeSpans(spans) encodes spans in the following fashion:

write_byte(12) // type of the list elements: 12 == struct
write_i32(count) // count of spans that will follow
for (int i = 0; i < count; i++) {
  writeTBinaryProtocol(spans(i))
}

Legacy encoding

Older versions of zipkin accepted a single span per message, as opposed to a list per message. This practice is deprecated, but still supported.