MetricExporter

interface MetricExporter

Receives aggregated metrics and delivers them to a backend. Implementing this one interface is enough for a new backend; aggregation, cardinality guarding, temporality, and scheduling are inherited.

Implementations must not throw - a telemetry failure must never surface inside a user's s3.getObject() call - and must not block indefinitely, since export runs on the reader's collection coroutine. The reader does no batching, so chunk against backend limits internally. export is never called concurrently with itself.

Install one exporter into one reader. An exporter that owns a transport closes it in shutdown, so a shared instance is silenced for the remaining readers as soon as the first one closes.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
abstract suspend fun export(metrics: List<MetricData>)

Deliver one collection cycle's worth of metrics.

Link copied to clipboard
abstract suspend fun shutdown()

Release resources held by this exporter. Called after the reader's final flush, so closing a transport here loses nothing. Must be idempotent - reachable from a provider's close() and from a caller holding the exporter directly.