Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.

public final class OtlpMetricExporter

  1. Object
  2. OtlpMetricExporter

ImplementsMetricReader

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:

KeyEnvironmentDefault
cn1.otel.metrics.endpointOTEL_EXPORTER_OTLP_METRICS_ENDPOINTcn1.otel.endpoint + /v1/metrics
cn1.otel.metrics.headersOTEL_EXPORTER_OTLP_METRICS_HEADERScn1.otel.headers
cn1.otel.metrics.protocolOTEL_EXPORTER_OTLP_METRICS_PROTOCOLcn1.otel.protocol
cn1.otel.metrics.enabledtrue

OTEL_SDK_DISABLED=true turns it off with the tracer.

Fields

public static final String ENABLED = "cn1.otel.metrics.enabled"
public static final String ENDPOINT = "cn1.otel.metrics.endpoint"
public static final String HEADERS = "cn1.otel.metrics.headers"
public static final String PROTOCOL = "cn1.otel.metrics.protocol"
public static final String INTERVAL = "cn1.otel.metrics.intervalMillis"

Constructors

public OtlpMetricExporter(String defaultServiceName)

Methods

public boolean open(Config config) throws IOExceptionReads the configuration and starts.
public boolean export()Sends one export now.
public void shutdown(int timeoutMillis)Sends what is left and stops, waiting up to timeoutMillis.
public Map status()Exports attempted, failures, and the last error, for the management view.

Inherited methods

Field details

ENABLED

public static final String ENABLED = "cn1.otel.metrics.enabled"

ENDPOINT

public static final String ENDPOINT = "cn1.otel.metrics.endpoint"

HEADERS

public static final String HEADERS = "cn1.otel.metrics.headers"

PROTOCOL

public static final String PROTOCOL = "cn1.otel.metrics.protocol"

INTERVAL

public static final String INTERVAL = "cn1.otel.metrics.intervalMillis"

Constructor details

OtlpMetricExporter

public OtlpMetricExporter(String defaultServiceName)

Method details

open

public boolean open(Config config) throws IOException
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.

export

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

shutdown

public void shutdown(int timeoutMillis)
Sends what is left and stops, waiting up to timeoutMillis.

status

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