Class ActivateTracingSpan<R extends org.apache.kafka.connect.connector.ConnectRecord<R>>

java.lang.Object
io.debezium.transforms.tracing.ActivateTracingSpan<R>
Type Parameters:
R - the subtype of ConnectRecord on which this transformation will operate
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.kafka.common.Configurable, org.apache.kafka.connect.transforms.Transformation<R>

public class ActivateTracingSpan<R extends org.apache.kafka.connect.connector.ConnectRecord<R>> extends Object implements org.apache.kafka.connect.transforms.Transformation<R>
This SMT enables integration with a tracing system. The SMT creates a tracing span and enriches it with metadata from envelope and source info block.
It is possible to connect the span to a parent span created by a business application. The application then needs to export its tracing active span context into a database field. The SMT looks for a predefined field name in the after block and when found it extracts the parent span from it.
Author:
Jiri Pechanec
  • Field Details

    • DB_FIELDS_PREFIX

      private static final String DB_FIELDS_PREFIX
      See Also:
    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • DEFAULT_TRACING_SPAN_CONTEXT_FIELD

      private static final String DEFAULT_TRACING_SPAN_CONTEXT_FIELD
      See Also:
    • DEFAULT_TRACING_OPERATION_NAME

      private static final String DEFAULT_TRACING_OPERATION_NAME
      See Also:
    • TRACING_COMPONENT

      private static final String TRACING_COMPONENT
      See Also:
    • TX_LOG_WRITE_OPERATION_NAME

      private static final String TX_LOG_WRITE_OPERATION_NAME
      See Also:
    • OPEN_TRACING_AVAILABLE

      private static final boolean OPEN_TRACING_AVAILABLE
    • TRACING_SPAN_CONTEXT_FIELD

      public static final Field TRACING_SPAN_CONTEXT_FIELD
    • TRACING_OPERATION_NAME

      public static final Field TRACING_OPERATION_NAME
    • TRACING_CONTEXT_FIELD_REQUIRED

      public static final Field TRACING_CONTEXT_FIELD_REQUIRED
    • spanContextField

      private String spanContextField
    • operationName

      private String operationName
    • requireContextField

      private boolean requireContextField
    • smtManager

      private SmtManager<R extends org.apache.kafka.connect.connector.ConnectRecord<R>> smtManager
  • Constructor Details

    • ActivateTracingSpan

      public ActivateTracingSpan()
  • Method Details

    • configure

      public void configure(Map<String,?> props)
      Specified by:
      configure in interface org.apache.kafka.common.Configurable
    • setRequireContextField

      public void setRequireContextField(boolean requireContextField)
    • apply

      public R apply(R record)
      Specified by:
      apply in interface org.apache.kafka.connect.transforms.Transformation<R extends org.apache.kafka.connect.connector.ConnectRecord<R>>
    • traceRecord

      private R traceRecord(R record, org.apache.kafka.connect.data.Struct envelope, org.apache.kafka.connect.data.Struct source, org.apache.kafka.connect.data.Struct after, String propagatedSpanContext)
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface org.apache.kafka.connect.transforms.Transformation<R extends org.apache.kafka.connect.connector.ConnectRecord<R>>
    • config

      public org.apache.kafka.common.config.ConfigDef config()
      Specified by:
      config in interface org.apache.kafka.connect.transforms.Transformation<R extends org.apache.kafka.connect.connector.ConnectRecord<R>>
    • addFieldToSpan

      private void addFieldToSpan(io.opentracing.Tracer.SpanBuilder span, org.apache.kafka.connect.data.Struct struct, String field, String prefix)
    • isOpenTracingAvailable

      public static boolean isOpenTracingAvailable()
    • resolveOpenTracingApiAvailable

      private static boolean resolveOpenTracingApiAvailable()