Class IsotopeContext
adoptFromRecord(ConsumerRecord) before processing each record so
that IsotopeProducerInterceptor can find the inbound trace context
and append the next hop instead of starting a new trace. The
(record, service) overload
additionally emits the stateless isotope.consume.age timer when the
Micrometer exporter is enabled.
For bipartite topology visibility, consumers also call
recordConsume(ConsumerRecord, String, Producer) to emit a
best-effort consume-edge marker to "isotope_consume_edge_markers".
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDefault topic thatrecordConsume(org.apache.kafka.clients.consumer.ConsumerRecord<?, ?>, java.lang.String, org.apache.kafka.clients.producer.Producer<byte[], byte[]>)writes markers to. -
Method Summary
Modifier and TypeMethodDescriptionstatic IsotopeadoptFromRecord(org.apache.kafka.clients.consumer.ConsumerRecord<?, ?> consumerRecord) Extracts the isotope from the given record's headers (if any) and installs it as the current thread-local context.static IsotopeadoptFromRecord(org.apache.kafka.clients.consumer.ConsumerRecord<?, ?> consumerRecord, String consumerService) LikeadoptFromRecord(ConsumerRecord), but also emits the stateless consume-sideisotope.consume.agetimer attributing the adoption toconsumerService.static voidclear()static Isotopecurrent()static voidrecordConsume(org.apache.kafka.clients.consumer.ConsumerRecord<?, ?> consumerRecord, String consumerService, org.apache.kafka.clients.producer.Producer<byte[], byte[]> emitter) Emits a best-effort consume-edge marker to "isotope_consume_edge_markers" using the default topic name.static voidrecordConsume(org.apache.kafka.clients.consumer.ConsumerRecord<?, ?> consumerRecord, String consumerService, org.apache.kafka.clients.producer.Producer<byte[], byte[]> emitter, String topic) Emits a best-effort consume-edge marker describing the consumption ofrecordbyconsumerService.static void
-
Field Details
-
CONSUME_EVENTS_TOPIC
Default topic thatrecordConsume(org.apache.kafka.clients.consumer.ConsumerRecord<?, ?>, java.lang.String, org.apache.kafka.clients.producer.Producer<byte[], byte[]>)writes markers to.- See Also:
-
-
Method Details
-
current
-
set
-
clear
public static void clear() -
adoptFromRecord
public static Isotope adoptFromRecord(org.apache.kafka.clients.consumer.ConsumerRecord<?, ?> consumerRecord) Extracts the isotope from the given record's headers (if any) and installs it as the current thread-local context. Returns the isotope adopted, ornullif the record carried no isotope.Emits no metric — use
adoptFromRecord(ConsumerRecord, String)to also record the statelessisotope.consume.agetimer. -
adoptFromRecord
public static Isotope adoptFromRecord(org.apache.kafka.clients.consumer.ConsumerRecord<?, ?> consumerRecord, String consumerService) LikeadoptFromRecord(ConsumerRecord), but also emits the stateless consume-sideisotope.consume.agetimer attributing the adoption toconsumerService. The age isnow - originTs— how stale the record was when this service adopted it to continue the trace — the adoption-path complement ofrecordConsume(org.apache.kafka.clients.consumer.ConsumerRecord<?, ?>, java.lang.String, org.apache.kafka.clients.producer.Producer<byte[], byte[]>)'s marker-pathisotope.consume.latency.The thread-local adoption itself is identical to the single-arg overload. The metric is a no-op when the record carries no isotope,
consumerServiceisnull, or the exporter is off (IsotopeMetrics.isEnabled()). -
recordConsume
public static void recordConsume(org.apache.kafka.clients.consumer.ConsumerRecord<?, ?> consumerRecord, String consumerService, org.apache.kafka.clients.producer.Producer<byte[], byte[]> emitter) Emits a best-effort consume-edge marker to "isotope_consume_edge_markers" using the default topic name. Equivalent torecordConsume(ConsumerRecord, String, Producer, String)withtopic = CONSUME_EVENTS_TOPIC. -
recordConsume
public static void recordConsume(org.apache.kafka.clients.consumer.ConsumerRecord<?, ?> consumerRecord, String consumerService, org.apache.kafka.clients.producer.Producer<byte[], byte[]> emitter, String topic) Emits a best-effort consume-edge marker describing the consumption ofrecordbyconsumerService. The marker is an empty-value record ontopicwhose headers forward every scalarx-isotope-*header from the inbound record plus a newIsotope.HEADER_CONSUMER_SERVICEnaming the consumer.No-op when the inbound record carries no
Isotope.HEADER_TRACE_ID- untagged records don't belong in the bipartite graph.Fire-and-forget: the send is async with no callback. The
Producerlifecycle is the caller's responsibility.When the Micrometer exporter is enabled (
), this also emits the stateless consume-edge metrics for the marker viainvalid reference
IsotopeMetrics#startIsotopeMetrics.recordConsume(java.lang.String, java.lang.String, java.lang.String, java.lang.String, long)— the consume-side analogue of the produce-sideIsotopeProducerInterceptoremission. For terminal consumers (those that did notadoptthe trace on this thread, socurrent()isnull) it additionally emits theisotope.consume.agetimer that adoption would otherwise miss; when the record was adopted, age was already emitted on the adoption path and is skipped here to avoid a double sample.
-