Class TracingProducerInterceptor<K,V>

Type Parameters:
K - key class
V - value class
All Implemented Interfaces:
AutoCloseable, org.apache.kafka.clients.producer.ProducerInterceptor<K,V>, org.apache.kafka.common.Configurable

public class TracingProducerInterceptor<K,V> extends Object implements org.apache.kafka.clients.producer.ProducerInterceptor<K,V>
Default tracing producer kafka interceptor. Altrernative way to connect tracing to your kafka records. If you want to trace records, just connect this default implementation producer interceptor to kafka. If you want to customize filter messages to trace, then you need to override method filterRecord in child class and connect it to kafka. *
  • Constructor Details

    • TracingProducerInterceptor

      public TracingProducerInterceptor()
  • Method Details

    • onSend

      public org.apache.kafka.clients.producer.ProducerRecord<K,V> onSend(org.apache.kafka.clients.producer.ProducerRecord<K,V> producerRecord)
      Specified by:
      onSend in interface org.apache.kafka.clients.producer.ProducerInterceptor<K,V>
    • filterRecord

      public boolean filterRecord(org.apache.kafka.clients.producer.ProducerRecord<K,V> record, String clientId)
      Override this method if you need to set custom condition or logic to filter message to trace.
      record - producer record
      clientId - clinet ID
      true if this record need to trace, false - otherwise
    • onAcknowledgement

      public void onAcknowledgement(org.apache.kafka.clients.producer.RecordMetadata recordMetadata, Exception e)
      Specified by:
      onAcknowledgement in interface org.apache.kafka.clients.producer.ProducerInterceptor<K,V>
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface org.apache.kafka.clients.producer.ProducerInterceptor<K,V>
    • configure

      public void configure(Map<String,?> map)
      Specified by:
      configure in interface org.apache.kafka.common.Configurable