OtlpMetrics
Exports Effect metrics over OTLP/HTTP.
This module periodically snapshots metrics from the current Effect context, serializes them as OTLP resource metrics, and posts them to a metrics endpoint such as an OpenTelemetry Collector or vendor intake. It is meant for long-running services that already update Metric counters, gauges, histograms, frequencies, or summaries. The exporter supports cumulative reporting from a fixed start time and delta reporting from the previous export.
Constructors
Signature
declare const make: (options: { readonly exportInterval?: Duration.Input; readonly headers?: Headers.Input; readonly resource?: { readonly attributes?: Record<string, unknown>; readonly serviceName?: string; readonly serviceVersion?: string; }; readonly shutdownTimeout?: Duration.Input; readonly temporality?: AggregationTemporality; readonly url: string;}) => Effect.Effect< void, never, Exporter.Flusher | HttpClient.HttpClient | OtlpSerialization | Scope.Scope>;Layers
Layer that starts the OTLP metrics exporter created by make.
Signature
declare function layer(options: { readonly exportInterval?: Input; readonly headers?: Input; readonly resource?: { readonly attributes?: Record<string, unknown>; readonly serviceName?: string; readonly serviceVersion?: string; }; readonly shutdownTimeout?: Input; readonly temporality?: AggregationTemporality; readonly url: string;}): Layer<Flusher, never, HttpClient | OtlpSerialization>;layerFromConfig
Creates an OTLP metrics layer from OpenTelemetry configuration.
Signature
declare function layerFromConfig(options?: { readonly headers?: Input; readonly resource?: { readonly attributes?: Record<string, unknown>; readonly serviceName?: string; readonly serviceVersion?: string; };}): Layer<Flusher, never, HttpClient | OtlpSerialization>;Models
AggregationTemporality type
Determines how metric values relate to the time interval over which they are aggregated.
Details
"cumulative" reports total since a fixed start time. Each data point depends on all previous measurements. This is the default behavior.
"delta" reports changes since the last export. Each interval is independent with no dependency on previous measurements.
Signature
type AggregationTemporality = "cumulative" | "delta";MetricsData interface
OTLP metrics payload serialized by OtlpMetrics.
Signature
interface MetricsData { readonly resourceMetrics: readonly Array<IResourceMetrics>;}
Starts a scoped OTLP metrics exporter.
Details
The exporter snapshots registered Effect metrics on the configured interval, serializes them with the selected aggregation temporality, and flushes during scope finalization up to
shutdownTimeout. Manual flushing also triggers a snapshot. With delta temporality, each successful export advances the previous-export state, so frequent successful flushes narrow the delta aggregation windows.