Class TracingKafkaProducer<K,​V>

  • All Implemented Interfaces:
    Closeable, AutoCloseable, org.apache.kafka.clients.producer.Producer<K,​V>

    public class TracingKafkaProducer<K,​V>
    extends Object
    implements org.apache.kafka.clients.producer.Producer<K,​V>
    This decorates a Kafka Producer and creates a Span.Kind.PRODUCER span for each record sent. This span is also injected onto each record (via headers) so it becomes the parent when a consumer later receives the record.
    Since:
    3.1.0
    Author:
    Anders Clausen, Flaviu Muresan
    • Constructor Detail

      • TracingKafkaProducer

        public TracingKafkaProducer​(org.apache.kafka.clients.producer.Producer<K,​V> producer,
                                    org.springframework.beans.factory.BeanFactory beanFactory)
    • Method Detail

      • initTransactions

        public void initTransactions()
        Specified by:
        initTransactions in interface org.apache.kafka.clients.producer.Producer<K,​V>
      • beginTransaction

        public void beginTransaction()
                              throws org.apache.kafka.common.errors.ProducerFencedException
        Specified by:
        beginTransaction in interface org.apache.kafka.clients.producer.Producer<K,​V>
        Throws:
        org.apache.kafka.common.errors.ProducerFencedException
      • sendOffsetsToTransaction

        public void sendOffsetsToTransaction​(Map<org.apache.kafka.common.TopicPartition,​org.apache.kafka.clients.consumer.OffsetAndMetadata> map,
                                             String s)
                                      throws org.apache.kafka.common.errors.ProducerFencedException
        Specified by:
        sendOffsetsToTransaction in interface org.apache.kafka.clients.producer.Producer<K,​V>
        Throws:
        org.apache.kafka.common.errors.ProducerFencedException
      • sendOffsetsToTransaction

        public void sendOffsetsToTransaction​(Map<org.apache.kafka.common.TopicPartition,​org.apache.kafka.clients.consumer.OffsetAndMetadata> map,
                                             org.apache.kafka.clients.consumer.ConsumerGroupMetadata consumerGroupMetadata)
                                      throws org.apache.kafka.common.errors.ProducerFencedException
        Specified by:
        sendOffsetsToTransaction in interface org.apache.kafka.clients.producer.Producer<K,​V>
        Throws:
        org.apache.kafka.common.errors.ProducerFencedException
      • commitTransaction

        public void commitTransaction()
                               throws org.apache.kafka.common.errors.ProducerFencedException
        Specified by:
        commitTransaction in interface org.apache.kafka.clients.producer.Producer<K,​V>
        Throws:
        org.apache.kafka.common.errors.ProducerFencedException
      • abortTransaction

        public void abortTransaction()
                              throws org.apache.kafka.common.errors.ProducerFencedException
        Specified by:
        abortTransaction in interface org.apache.kafka.clients.producer.Producer<K,​V>
        Throws:
        org.apache.kafka.common.errors.ProducerFencedException
      • send

        public Future<org.apache.kafka.clients.producer.RecordMetadata> send​(org.apache.kafka.clients.producer.ProducerRecord<K,​V> producerRecord)
        Specified by:
        send in interface org.apache.kafka.clients.producer.Producer<K,​V>
      • send

        public Future<org.apache.kafka.clients.producer.RecordMetadata> send​(org.apache.kafka.clients.producer.ProducerRecord<K,​V> producerRecord,
                                                                             org.apache.kafka.clients.producer.Callback callback)
        Specified by:
        send in interface org.apache.kafka.clients.producer.Producer<K,​V>
      • flush

        public void flush()
        Specified by:
        flush in interface org.apache.kafka.clients.producer.Producer<K,​V>
      • partitionsFor

        public List<org.apache.kafka.common.PartitionInfo> partitionsFor​(String s)
        Specified by:
        partitionsFor in interface org.apache.kafka.clients.producer.Producer<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.producer.Producer<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.producer.Producer<K,​V>
      • close

        public void close​(Duration duration)
        Specified by:
        close in interface org.apache.kafka.clients.producer.Producer<K,​V>