Class IsotopeProducerInterceptor<K,V>

java.lang.Object
ai.signalroom.kafka.isotope.IsotopeProducerInterceptor<K,V>
All Implemented Interfaces:
AutoCloseable, org.apache.kafka.clients.producer.ProducerInterceptor<K,V>, org.apache.kafka.common.Configurable

public class IsotopeProducerInterceptor<K,V> extends Object implements org.apache.kafka.clients.producer.ProducerInterceptor<K,V>
Producer-side half of the isotope tracer.

On every send(), this interceptor finds (or creates) the in-flight Isotope, appends a hop describing this produce edge, and writes the JSON-encoded isotope plus seven scalar headers describing the just-appended hop. Sourcing order: thread-local context, inbound header, or a fresh trace stamped with "isotope.service.name"<K,V>.

  • Field Details

    • SERVICE_NAME_CONFIG

      public static final String SERVICE_NAME_CONFIG
      See Also:
    • PIPELINE_NAME_CONFIG

      public static final String PIPELINE_NAME_CONFIG
      Names the logical pipeline a fresh trace belongs to (e.g. orders vs location). Only the trace's origin uses this value — it is stamped once at Isotope.newTrace(java.lang.String) and then forwarded unchanged on every hop, so downstream services inherit it from the inbound record and never need to set it.
      See Also:
  • Constructor Details

    • IsotopeProducerInterceptor

      public IsotopeProducerInterceptor()
  • Method Details

    • configure

      public void configure(Map<String,?> configs)
      Specified by:
      configure in interface org.apache.kafka.common.Configurable
    • 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>
    • onAcknowledgement

      public void onAcknowledgement(org.apache.kafka.clients.producer.RecordMetadata metadata, Exception exception)
      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>