Class DebeziumTracingProducerInterceptor<K,V>
- All Implemented Interfaces:
AutoCloseable,org.apache.kafka.clients.producer.ProducerInterceptor<K,,V> org.apache.kafka.common.Configurable
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final io.opentelemetry.context.propagation.TextMapGetter<org.apache.kafka.clients.producer.ProducerRecord<?,?>> private Objectprivate static final org.slf4j.Loggerprivate Methodprivate static final io.opentelemetry.api.OpenTelemetryprivate static final io.opentelemetry.context.propagation.TextMapPropagatorprivate static final io.opentelemetry.api.trace.Tracer -
Constructor Summary
ConstructorsConstructorDescriptionThe constructor for the DebeziumTracingProducerInterceptor. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidvoidonAcknowledgement(org.apache.kafka.clients.producer.RecordMetadata recordMetadata, Exception e)
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
openTelemetry
private static final io.opentelemetry.api.OpenTelemetry openTelemetry -
tracer
private static final io.opentelemetry.api.trace.Tracer tracer -
TEXT_MAP_PROPAGATOR
private static final io.opentelemetry.context.propagation.TextMapPropagator TEXT_MAP_PROPAGATOR -
GETTER
private static final io.opentelemetry.context.propagation.TextMapGetter<org.apache.kafka.clients.producer.ProducerRecord<?,?>> GETTER -
interceptorInstance
-
onSendMethod
-
-
Constructor Details
-
DebeziumTracingProducerInterceptor
public DebeziumTracingProducerInterceptor()The constructor for the DebeziumTracingProducerInterceptor.In this interceptor, we use a dynamic approach to handle the OpenTelemetry tracing interceptor due to versioning issues. The problem arises because different versions of OpenTelemetry have their tracing interceptor in different packages. For example, in versions before 1.23.0, the tracing interceptor is in the "io.opentelemetry.instrumentation.kafkaclients" package, but from version 1.23.0 onwards, it is in the "io.opentelemetry.instrumentation.kafkaclients.v2_6" package.
The OpenTelemetry interceptor is also part of an alpha package, which means it's subject to change, and there is no guarantee of backward compatibility. That's why a dynamic approach is used here. We maintain an array of possible class names (
OpenTelemetryInterceptorVersion) for the OpenTelemetry tracing interceptor, and we attempt to instantiate one of them at runtime. We also use reflection to access the 'onSend' method from the interceptor.This allows the Debezium Kafka Connector to work with different versions of OpenTelemetry.
-
-
Method Details
-
onSend
-
onAcknowledgement
public void onAcknowledgement(org.apache.kafka.clients.producer.RecordMetadata recordMetadata, Exception e) -
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceorg.apache.kafka.clients.producer.ProducerInterceptor<K,V>
-
configure
- Specified by:
configurein interfaceorg.apache.kafka.common.Configurable
-