Class LogEventsKafkaEmitter

java.lang.Object
io.confluent.logevents.connect.LogEventsKafkaEmitter
All Implemented Interfaces:
LogEventsEmitter

public class LogEventsKafkaEmitter extends Object implements LogEventsEmitter
LogEventsKafkaEmitter, used to emit log events from anywhere in connect cluster to a configured destination topic.

Log events provide better visibility into the progress of connector, by capturing specific and important events like failures, lifecycle events, config changes, etc. in the form of Kafka events. Further, these events are formatted as per the Cloudevents specification, which makes the consumption and usage of these events more portable and consistent across platforms.

Usage: Each Connect Worker instantiates the LogEventsKafkaEmitter based upon the worker's configuration. From there, any class that has access to the Worker instance can obtain this emitter and use the LogEvents methods to log specific events of interest. Helper class LogEvents is provided with static methods which help in construction of ConnectLogEntry objects and forward them to the emit(ConnectLogEntry, String, String, String). In future, instance of LogEventsEmitter will also be introduced into WorkerSourceConnectorContext, WorkerSinkConnectorContext, WorkerSourceTaskContext, WorkerSinkTaskContext objects, enabling the connectors to capture logs of interest in the form of LogEvents.

  • Constructor Details

    • LogEventsKafkaEmitter

      public LogEventsKafkaEmitter(io.confluent.telemetry.events.EventLogger eventLogger, LogEventsConfig logEventsConfig, String dataContentType)
    • LogEventsKafkaEmitter

      public LogEventsKafkaEmitter()
  • Method Details

    • start

      public void start(Map<String,?> configs)
      Start up the event logger. This must be called only once from worker.
      Parameters:
      configs - the configs; may not be null
    • onReceiveCallback

      public void onReceiveCallback(RemoteConnectLogsConfiguration newRemoteConfiguration)
    • logEventsConfig

      public LogEventsConfig logEventsConfig()
      Returns the initialized LogEventsConfig instance from the user configs. This should only be invoked after the start(Map) is invoked. It throws a runtime exception if invoked before the start was called.
      Returns:
      logEventsKafkaConfig instance, if this logEventsKafkaEmitter is already started.
      Throws:
      IllegalStateException - if invoked before the start was called.
    • emit

      public void emit(ConnectLogEntry connectLogEntry, String subject, String source, String type)
      Description copied from interface: LogEventsEmitter
      Construct a connect Log Event and emit it to the preconfigured destination.
      Specified by:
      emit in interface LogEventsEmitter
      Parameters:
      connectLogEntry - Payload containing details of the connect log event. May not be null.
      subject - From CloudEvents spec. Subject captures what the event is about. May not be null.
      source - From CloudEvents spec. Source captures the context in which the event happened. May not be null.
      type - From CloudEvents spec. Identifies the event type. May not be null.
    • stop

      public void stop()
      Needs to be called only once during teardown of the worker.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • configureRemoteConfigurationSource

      public io.confluent.remote.config.poller.RemoteConfigurationSource<RemoteConnectLogsConfiguration> configureRemoteConfigurationSource(Map<String,?> configs)
    • getRemoteConfiguration

      public RemoteConnectLogsConfiguration getRemoteConfiguration()