Class TracingProducerInterceptor<K,V>
java.lang.Object
io.micronaut.tracing.opentelemetry.instrument.kafka.TracingProducerInterceptor<K,V>
- Type Parameters:
K
- key classV
- 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. *
- Since:
- 5.0.0
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
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.void
onAcknowledgement
(org.apache.kafka.clients.producer.RecordMetadata recordMetadata, Exception e)
-
Constructor Details
-
TracingProducerInterceptor
public TracingProducerInterceptor()
-
-
Method Details
-
onSend
-
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.- Parameters:
record
- producer recordclientId
- clinet ID- Returns:
- true if this record need to trace, false - otherwise
-
onAcknowledgement
public void onAcknowledgement(org.apache.kafka.clients.producer.RecordMetadata recordMetadata, Exception e) -
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceorg.apache.kafka.clients.producer.ProducerInterceptor<K,
V>
-
configure
- Specified by:
configure
in interfaceorg.apache.kafka.common.Configurable
-