Add decorators for Kafka Streams to enable tracing.
KafkaStreamsTracing
completes a span onprocess
orprocessValues
This does not trace all operations by default. See [RATIONALE.md] for why.
First, setup the generic Kafka Streams component like this:
import brave.kafka.streams.KafkaStreamsTracing;
...
kafkaStreamsTracing = KafkaStreamsTracing.create(tracing);
KIP-820 introduces new processor APIs to the Kafka Streams DSL. You must use version >= v3.4.0 to instrument applications.
To trace a processor in your application use kafkaStreamsTracing.process
like so:
builder.stream(inputTopic)
.process(kafkaStreamsTracing.process(
"process",
customProcessor));
or use kafkaStreamsTracing.processValues
like so:
builder.stream(inputTopic)
.processValues(kafkaStreamsTracing.processValues(
"processValues",
customProcessor));
For more details, see here.
To create a Kafka Streams with Tracing Client Supplier enabled, pass your topology and configuration like this:
KafkaStreams kafkaStreams = kafkaStreamsTracing.kafkaStreams(topology, streamsConfig);
- This tracer is only compatible with Kafka Streams versions including headers support ( > 2.0.0).