Class KafkaTracing


  • public final class KafkaTracing
    extends java.lang.Object
    Use this class to decorate your Kafka consumer / producer and enable Tracing.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  KafkaTracing.Builder  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <K,​V>
      org.apache.kafka.clients.consumer.Consumer<K,​V>
      consumer​(org.apache.kafka.clients.consumer.Consumer<K,​V> consumer)
      Extracts or creates a Span.Kind.CONSUMER span for each message received.
      static KafkaTracing create​(brave.Tracing tracing)  
      static KafkaTracing.Builder newBuilder​(brave.Tracing tracing)  
      brave.Span nextSpan​(org.apache.kafka.clients.consumer.ConsumerRecord<?,​?> record)
      Use this to create a span for processing the given record.
      <K,​V>
      org.apache.kafka.clients.producer.Producer<K,​V>
      producer​(org.apache.kafka.clients.producer.Producer<K,​V> producer)
      Starts and propagates Span.Kind.PRODUCER span for each message sent.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • create

        public static KafkaTracing create​(brave.Tracing tracing)
      • consumer

        public <K,​V> org.apache.kafka.clients.consumer.Consumer<K,​V> consumer​(org.apache.kafka.clients.consumer.Consumer<K,​V> consumer)
        Extracts or creates a Span.Kind.CONSUMER span for each message received. This span is injected onto each message so it becomes the parent when a processor later calls nextSpan(ConsumerRecord).
      • producer

        public <K,​V> org.apache.kafka.clients.producer.Producer<K,​V> producer​(org.apache.kafka.clients.producer.Producer<K,​V> producer)
        Starts and propagates Span.Kind.PRODUCER span for each message sent.
      • nextSpan

        public brave.Span nextSpan​(org.apache.kafka.clients.consumer.ConsumerRecord<?,​?> record)
        Use this to create a span for processing the given record. Note: the result has no name and is not started.

        This creates a child from identifiers extracted from the record headers, or a new span if one couldn't be extracted.