Class TracingKafkaConsumer<K,V>

java.lang.Object
org.springframework.cloud.sleuth.instrument.kafka.TracingKafkaConsumer<K,V>
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.kafka.clients.consumer.Consumer<K,V>

public class TracingKafkaConsumer<K,V> extends Object implements org.apache.kafka.clients.consumer.Consumer<K,V>
This decorates a Kafka Consumer. It creates and completes a Span.Kind.CONSUMER span for each record received. This span will be a child span of the one extracted from the record headers.
Since:
3.1.0
Author:
Anders Clausen, Flaviu Muresan
  • Constructor Summary

    Constructors
    Constructor
    Description
    TracingKafkaConsumer(org.apache.kafka.clients.consumer.Consumer<K,V> consumer, org.springframework.beans.factory.BeanFactory beanFactory)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    assign(Collection<org.apache.kafka.common.TopicPartition> collection)
     
    Set<org.apache.kafka.common.TopicPartition>
     
    Map<org.apache.kafka.common.TopicPartition,Long>
    beginningOffsets(Collection<org.apache.kafka.common.TopicPartition> collection)
     
    Map<org.apache.kafka.common.TopicPartition,Long>
    beginningOffsets(Collection<org.apache.kafka.common.TopicPartition> collection, Duration duration)
     
    void
     
    void
    close(Duration duration)
     
    void
     
    void
    commitAsync(Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata> map, org.apache.kafka.clients.consumer.OffsetCommitCallback offsetCommitCallback)
     
    void
    commitAsync(org.apache.kafka.clients.consumer.OffsetCommitCallback offsetCommitCallback)
     
    void
     
    void
    commitSync(Duration duration)
     
    void
    commitSync(Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata> map)
     
    void
    commitSync(Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata> map, Duration duration)
     
    Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata>
    committed(Set<org.apache.kafka.common.TopicPartition> set)
     
    Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata>
    committed(Set<org.apache.kafka.common.TopicPartition> set, Duration duration)
     
    org.apache.kafka.clients.consumer.OffsetAndMetadata
    committed(org.apache.kafka.common.TopicPartition topicPartition)
    Deprecated.
    org.apache.kafka.clients.consumer.OffsetAndMetadata
    committed(org.apache.kafka.common.TopicPartition topicPartition, Duration duration)
    Deprecated.
    currentLag(org.apache.kafka.common.TopicPartition topicPartition)
     
    Map<org.apache.kafka.common.TopicPartition,Long>
    endOffsets(Collection<org.apache.kafka.common.TopicPartition> collection)
     
    Map<org.apache.kafka.common.TopicPartition,Long>
    endOffsets(Collection<org.apache.kafka.common.TopicPartition> collection, Duration duration)
     
    void
     
    org.apache.kafka.clients.consumer.ConsumerGroupMetadata
     
    Map<String,List<org.apache.kafka.common.PartitionInfo>>
     
    Map<String,List<org.apache.kafka.common.PartitionInfo>>
    listTopics(Duration duration)
     
    Map<org.apache.kafka.common.MetricName,? extends org.apache.kafka.common.Metric>
     
    Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndTimestamp>
    offsetsForTimes(Map<org.apache.kafka.common.TopicPartition,Long> map)
     
    Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndTimestamp>
    offsetsForTimes(Map<org.apache.kafka.common.TopicPartition,Long> map, Duration duration)
     
    List<org.apache.kafka.common.PartitionInfo>
     
    List<org.apache.kafka.common.PartitionInfo>
     
    void
    pause(Collection<org.apache.kafka.common.TopicPartition> collection)
     
    Set<org.apache.kafka.common.TopicPartition>
     
    org.apache.kafka.clients.consumer.ConsumerRecords<K,V>
    poll(long l)
    Deprecated.
    org.apache.kafka.clients.consumer.ConsumerRecords<K,V>
    poll(Duration duration)
     
    long
    position(org.apache.kafka.common.TopicPartition topicPartition)
     
    long
    position(org.apache.kafka.common.TopicPartition topicPartition, Duration duration)
     
    void
    resume(Collection<org.apache.kafka.common.TopicPartition> collection)
     
    void
    seek(org.apache.kafka.common.TopicPartition topicPartition, long l)
     
    void
    seek(org.apache.kafka.common.TopicPartition topicPartition, org.apache.kafka.clients.consumer.OffsetAndMetadata offsetAndMetadata)
     
    void
    seekToBeginning(Collection<org.apache.kafka.common.TopicPartition> collection)
     
    void
    seekToEnd(Collection<org.apache.kafka.common.TopicPartition> collection)
     
    void
     
    void
    subscribe(Collection<String> collection, org.apache.kafka.clients.consumer.ConsumerRebalanceListener consumerRebalanceListener)
     
    void
    subscribe(Pattern pattern)
     
    void
    subscribe(Pattern pattern, org.apache.kafka.clients.consumer.ConsumerRebalanceListener consumerRebalanceListener)
     
     
    void
     
    void
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TracingKafkaConsumer

      public TracingKafkaConsumer(org.apache.kafka.clients.consumer.Consumer<K,V> consumer, org.springframework.beans.factory.BeanFactory beanFactory)
  • Method Details

    • assignment

      public Set<org.apache.kafka.common.TopicPartition> assignment()
      Specified by:
      assignment in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • subscription

      public Set<String> subscription()
      Specified by:
      subscription in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • subscribe

      public void subscribe(Collection<String> collection)
      Specified by:
      subscribe in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • subscribe

      public void subscribe(Collection<String> collection, org.apache.kafka.clients.consumer.ConsumerRebalanceListener consumerRebalanceListener)
      Specified by:
      subscribe in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • assign

      public void assign(Collection<org.apache.kafka.common.TopicPartition> collection)
      Specified by:
      assign in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • subscribe

      public void subscribe(Pattern pattern, org.apache.kafka.clients.consumer.ConsumerRebalanceListener consumerRebalanceListener)
      Specified by:
      subscribe in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • subscribe

      public void subscribe(Pattern pattern)
      Specified by:
      subscribe in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • unsubscribe

      public void unsubscribe()
      Specified by:
      unsubscribe in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • poll

      @Deprecated public org.apache.kafka.clients.consumer.ConsumerRecords<K,V> poll(long l)
      Deprecated.
      Specified by:
      poll in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • poll

      public org.apache.kafka.clients.consumer.ConsumerRecords<K,V> poll(Duration duration)
      Specified by:
      poll in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • commitSync

      public void commitSync()
      Specified by:
      commitSync in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • commitSync

      public void commitSync(Duration duration)
      Specified by:
      commitSync in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • commitSync

      public void commitSync(Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata> map)
      Specified by:
      commitSync in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • commitSync

      public void commitSync(Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata> map, Duration duration)
      Specified by:
      commitSync in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • commitAsync

      public void commitAsync()
      Specified by:
      commitAsync in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • commitAsync

      public void commitAsync(org.apache.kafka.clients.consumer.OffsetCommitCallback offsetCommitCallback)
      Specified by:
      commitAsync in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • commitAsync

      public void commitAsync(Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata> map, org.apache.kafka.clients.consumer.OffsetCommitCallback offsetCommitCallback)
      Specified by:
      commitAsync in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • seek

      public void seek(org.apache.kafka.common.TopicPartition topicPartition, long l)
      Specified by:
      seek in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • seek

      public void seek(org.apache.kafka.common.TopicPartition topicPartition, org.apache.kafka.clients.consumer.OffsetAndMetadata offsetAndMetadata)
      Specified by:
      seek in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • seekToBeginning

      public void seekToBeginning(Collection<org.apache.kafka.common.TopicPartition> collection)
      Specified by:
      seekToBeginning in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • seekToEnd

      public void seekToEnd(Collection<org.apache.kafka.common.TopicPartition> collection)
      Specified by:
      seekToEnd in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • position

      public long position(org.apache.kafka.common.TopicPartition topicPartition)
      Specified by:
      position in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • position

      public long position(org.apache.kafka.common.TopicPartition topicPartition, Duration duration)
      Specified by:
      position in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • committed

      @Deprecated public org.apache.kafka.clients.consumer.OffsetAndMetadata committed(org.apache.kafka.common.TopicPartition topicPartition)
      Deprecated.
      Specified by:
      committed in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • committed

      @Deprecated public org.apache.kafka.clients.consumer.OffsetAndMetadata committed(org.apache.kafka.common.TopicPartition topicPartition, Duration duration)
      Deprecated.
      Specified by:
      committed in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • committed

      public Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata> committed(Set<org.apache.kafka.common.TopicPartition> set)
      Specified by:
      committed in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • committed

      public Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata> committed(Set<org.apache.kafka.common.TopicPartition> set, Duration duration)
      Specified by:
      committed in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • metrics

      public Map<org.apache.kafka.common.MetricName,? extends org.apache.kafka.common.Metric> metrics()
      Specified by:
      metrics in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • partitionsFor

      public List<org.apache.kafka.common.PartitionInfo> partitionsFor(String s)
      Specified by:
      partitionsFor in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • partitionsFor

      public List<org.apache.kafka.common.PartitionInfo> partitionsFor(String s, Duration duration)
      Specified by:
      partitionsFor in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • listTopics

      public Map<String,List<org.apache.kafka.common.PartitionInfo>> listTopics()
      Specified by:
      listTopics in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • listTopics

      public Map<String,List<org.apache.kafka.common.PartitionInfo>> listTopics(Duration duration)
      Specified by:
      listTopics in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • paused

      public Set<org.apache.kafka.common.TopicPartition> paused()
      Specified by:
      paused in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • pause

      public void pause(Collection<org.apache.kafka.common.TopicPartition> collection)
      Specified by:
      pause in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • resume

      public void resume(Collection<org.apache.kafka.common.TopicPartition> collection)
      Specified by:
      resume in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • offsetsForTimes

      public Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndTimestamp> offsetsForTimes(Map<org.apache.kafka.common.TopicPartition,Long> map)
      Specified by:
      offsetsForTimes in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • offsetsForTimes

      public Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndTimestamp> offsetsForTimes(Map<org.apache.kafka.common.TopicPartition,Long> map, Duration duration)
      Specified by:
      offsetsForTimes in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • beginningOffsets

      public Map<org.apache.kafka.common.TopicPartition,Long> beginningOffsets(Collection<org.apache.kafka.common.TopicPartition> collection)
      Specified by:
      beginningOffsets in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • beginningOffsets

      public Map<org.apache.kafka.common.TopicPartition,Long> beginningOffsets(Collection<org.apache.kafka.common.TopicPartition> collection, Duration duration)
      Specified by:
      beginningOffsets in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • endOffsets

      public Map<org.apache.kafka.common.TopicPartition,Long> endOffsets(Collection<org.apache.kafka.common.TopicPartition> collection)
      Specified by:
      endOffsets in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • endOffsets

      public Map<org.apache.kafka.common.TopicPartition,Long> endOffsets(Collection<org.apache.kafka.common.TopicPartition> collection, Duration duration)
      Specified by:
      endOffsets in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • groupMetadata

      public org.apache.kafka.clients.consumer.ConsumerGroupMetadata groupMetadata()
      Specified by:
      groupMetadata in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • enforceRebalance

      public void enforceRebalance()
      Specified by:
      enforceRebalance in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • close

      public void close(Duration duration)
      Specified by:
      close in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • wakeup

      public void wakeup()
      Specified by:
      wakeup in interface org.apache.kafka.clients.consumer.Consumer<K,V>
    • currentLag

      public OptionalLong currentLag(org.apache.kafka.common.TopicPartition topicPartition)
      Specified by:
      currentLag in interface org.apache.kafka.clients.consumer.Consumer<K,V>