Class KafkaExporter

java.lang.Object
io.confluent.telemetry.exporter.AbstractExporter
io.confluent.telemetry.exporter.kafka.KafkaExporter
All Implemented Interfaces:
Exporter, AutoCloseable

public class KafkaExporter extends AbstractExporter
  • Field Details

  • Constructor Details

  • Method Details

    • doEmit

      public void doEmit(ContextExportableMetric metric)
      Specified by:
      doEmit in class AbstractExporter
    • close

      public void close() throws Exception
      Throws:
      Exception
    • getProducer

      public org.apache.kafka.clients.producer.Producer<byte[], io.opentelemetry.proto.metrics.v1.MetricsData> getProducer()
    • setMetricsRegistry

      public void setMetricsRegistry(org.apache.kafka.common.metrics.Metrics metrics)
      Sets the Metrics registry for this exporter.

      The Metrics object is associated with the TelemetryReporter instance. When the TelemetryReporter is reconfigured, the old KafkaExporter instance is closed, and a new KafkaExporter instance is created.

      The null check if (metrics.metric(exporterMetricName) == null) is essential because the created KafkaExporter instance receives the same Metrics object. Since KafkaProducer can be shared by the exporters, we need to make sure that the same metric is not already registered with this Metrics instance.

      Parameters:
      metrics - The Metrics registry to use.
    • newBuilder

      public static KafkaExporter.Builder newBuilder()
    • newBuilder

      public static KafkaExporter.Builder newBuilder(KafkaExporterConfig config)
      Create a new Builder using values from the ConfluentTelemetryConfig.