Class OtlpMetricExporter

java.lang.Object
com.codename1.backend.otel.OtlpMetricExporter
All Implemented Interfaces:
MetricReader

public final class OtlpMetricExporter extends Object implements MetricReader

Exports Metrics over OTLP/HTTP, every cn1.otel.metrics.intervalMillis (OTEL_METRIC_EXPORT_INTERVAL, one minute by default), with cumulative temporality.

Configured like the tracer, with the metrics-specific settings taking precedence the way the OpenTelemetry specification says:

Key Environment Default
cn1.otel.metrics.endpoint OTEL_EXPORTER_OTLP_METRICS_ENDPOINT cn1.otel.endpoint + /v1/metrics
cn1.otel.metrics.headers OTEL_EXPORTER_OTLP_METRICS_HEADERS cn1.otel.headers
cn1.otel.metrics.protocol OTEL_EXPORTER_OTLP_METRICS_PROTOCOL cn1.otel.protocol
cn1.otel.metrics.enabled true

OTEL_SDK_DISABLED=true turns it off with the tracer.

  • Field Details

  • Constructor Details

    • OtlpMetricExporter

      public OtlpMetricExporter(String defaultServiceName)
  • Method Details

    • open

      public boolean open(Config config) throws IOException
      Description copied from interface: MetricReader
      Reads the configuration and starts. Answers false when the deployment has metrics turned off, in which case nothing is started; one that throws must leave nothing started either, and changes nothing it was already doing -- the server does not shut down a reader whose open() failed.
      Specified by:
      open in interface MetricReader
      Throws:
      IOException
    • export

      public boolean export()
      Sends one export now. Answers whether the collector accepted it.
    • shutdown

      public void shutdown(int timeoutMillis)
      Description copied from interface: MetricReader
      Sends what is left and stops, waiting up to timeoutMillis.
      Specified by:
      shutdown in interface MetricReader
    • status

      public Map status()
      Exports attempted, failures, and the last error, for the management view.