Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.
public final class OtlpMetricExporter
- Object
- 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:
| 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.
Fields
Constructors
public OtlpMetricExporter(String defaultServiceName) |
Methods
public boolean open(Config config)
throws IOException | Reads 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 IOExceptionReads 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.
Throws
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.