Class DebeziumOpenLineageEmitter

java.lang.Object
io.debezium.openlineage.DebeziumOpenLineageEmitter

public class DebeziumOpenLineageEmitter extends Object
A utility class for emitting OpenLineage events from Debezium connectors.

This class serves as a facade for the underlying OpenLineage integration, providing static methods for initializing the emitter and emitting lineage events at various points in the Debezium connector lifecycle. The implementation uses a thread-safe approach to ensure proper initialization across multiple threads.

The emitter will only be active if OpenLineage integration is enabled in the configuration. Otherwise, a no-operation implementation is used that performs no actual emission.

Author:
Mario Fiore Vitale
See Also:
  • Field Details

  • Constructor Details

    • DebeziumOpenLineageEmitter

      public DebeziumOpenLineageEmitter()
  • Method Details

    • emit

      public static void emit(ConnectorContext connectorContext, io.debezium.connector.common.DebeziumTaskState state)
      Emits a lineage event for the given source task state.
      Parameters:
      connectorContext - The connector context
      state - The current state of the source task
      Throws:
      IllegalStateException - If the emitter has not been initialized for this connector
    • emit

      public static void emit(ConnectorContext connectorContext, io.debezium.connector.common.DebeziumTaskState state, Throwable t)
      Emits a lineage event for the given source task state and exception.

      This method is typically used for error reporting.

      Parameters:
      connectorContext - The connector context
      state - The current state of the source task
      t - The exception that occurred during processing
      Throws:
      IllegalStateException - If the emitter has not been initialized for this connector
    • emit

      public static void emit(ConnectorContext connectorContext, io.debezium.connector.common.DebeziumTaskState state, List<DatasetMetadata> datasetMetadata)
      Emits a lineage inputDatasetMetadata for the given source task state and table inputDatasetMetadata.

      This method is typically used for emitting input dataset lineage.

      Parameters:
      connectorContext - The connector context
      state - The current state of the source task
      datasetMetadata - A list of input dataset metadata containing metadata for lineage
      Throws:
      IllegalStateException - If the emitter has not been initialized for this connector
    • emit

      public static void emit(ConnectorContext connectorContext, io.debezium.connector.common.DebeziumTaskState state, List<DatasetMetadata> datasetMetadata, Throwable t)
      Emits a lineage event for the given source task state, table event, and exception.

      This method provides the most detailed lineage information, including both table metadata and any exception that occurred during processing.

      Parameters:
      connectorContext - The connector context
      state - The current state of the source task
      datasetMetadata - A list of input dataset metadata containing metadata for lineage
      t - The exception that occurred during processing, may be null
      Throws:
      IllegalStateException - If the emitter has not been initialized for this connector
    • connectorContext

      public static ConnectorContext connectorContext(Map<String,String> config, String connectorName, UUID runId)
    • cleanup

      public static void cleanup(ConnectorContext connectorContext)
      Removes the emitter for the specified connector. Should be called when a connector is stopped or destroyed.
      Parameters:
      connectorContext - The context the connector
    • getEmitter

      private static LineageEmitter getEmitter(ConnectorContext connectorContext)
    • init

      private static LineageEmitter init(ConnectorContext connectorContext)
    • getNoOpLineageEmitter

      private static NoOpLineageEmitter getNoOpLineageEmitter()
    • isOpenLineageDisabled

      private static boolean isOpenLineageDisabled(ConnectorContext connectorContext)