#OpenTelemetry Metrics SDK

This package implements synchronous and observable metric instruments, exporters, views, and reader coordination.

#Main types

  • SdkMeterProvider: owns resource, exporters, and readers
  • SdkMeter: creates instruments scoped to a name/version/schema URL
  • Counter, UpDownCounter, Histogram, Gauge: supported synchronous instruments
  • ObservableCounter, ObservableUpDownCounter, ObservableGauge: callback driven instruments sampled during collection
  • ManualReader: pulls a snapshot on demand
  • PeriodicMetricReader: pushes snapshots on an interval
  • Temporality: selects cumulative vs delta style reporting for readers
  • Stream, StreamBuilder: view output configuration for renaming, attribute filtering, and cardinality limits
  • MetricExporter, InMemoryMetricExporter: exporter abstraction and test helper

#Aggregation model

The current implementation stores one point per unique attribute set and emits one of these aggregations:

  • Aggregation::Sum
  • Aggregation::Gauge
  • Aggregation::Histogram

Histograms keep count, sum, min, and max. They do not currently compute bucket boundaries.

#Reader behavior

ManualReader::builder() creates a detached reader that can be registered with SdkMeterProviderBuilder::with_reader(). SdkMeterProvider::manual_reader() remains as a convenience for creating a reader directly from an existing provider.

ManualReader::collect_result() is the lifecycle-aware pull API. It returns an error after shutdown and also reports detached readers that were never registered with a provider.

ManualReader::collect() remains the convenience wrapper. It returns [] when collection is unavailable, including after shutdown.

ManualReader::force_flush() is a no-op and always succeeds because the reader does not own exporters or background work.

PeriodicMetricReader::builder(exporter) creates a detached push reader that can be registered with SdkMeterProviderBuilder::with_periodic_reader(). with_periodic_exporter() remains as the convenience shortcut.

Both reader builders support with_temporality():

  • Temporality::Cumulative
  • Temporality::Delta
  • Temporality::LowMemory

SdkMeterProvider::force_flush() collects a fresh snapshot, exports it through every registered exporter, and then asks each exporter to flush.

PeriodicMetricReader::run() performs the same collection/export cycle on a timer. Like the trace and log batch processors, it must be spawned explicitly.

When with_periodic_exporter() is used without an explicit interval, the reader defaults from OTEL_METRIC_EXPORT_INTERVAL.

Delta temporality currently applies to sum-like streams and the simplified histogram summary model used in this package. Histogram deltas reuse the current cycle's min/max because the implementation does not yet store full bucket state.

Counter::add() now ignores negative deltas so the instrument remains monotonic.

Observable callbacks run during each collect() / periodic export cycle. Their last values are cleared before each run so gauges and counters report the current callback result instead of accumulating stale points forever.

with_view() currently supports per-instrument stream renaming, aggregation override, attribute allow-lists, and cardinality limits.

StreamBuilder::with_aggregation() supports these modes:

  • StreamAggregation::Default
  • StreamAggregation::Drop
  • StreamAggregation::Sum
  • StreamAggregation::LastValue
  • StreamAggregation::Histogram

Drop suppresses the matching stream entirely. Sum, LastValue, and Histogram remap the recorded measurements into the selected aggregation without changing the instrument name or scope unless the view also overrides those fields.

View

type View = (Instrument) -> Stream?

View callback used to transform metric streams during instrument creation. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#view

Aggregation

pub(all) enum Aggregation {
Sum(Number)
Gauge(Number)
Histogram(HistogramSummary)
} derive(Eq, ToJson,
Debug
)

Aggregated metric payload for one attribute set. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#aggregation

Counter

pub struct Counter {
state :
Ref
[SyncInstrumentState]
}

Counter instrument handle. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#counter

Counter::add

Adds a delta to the counter for one attribute set.

Negative values are ignored because counters are monotonic. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#measurement

CounterBuilder

pub struct CounterBuilder {
meter : SdkMeter
name : String
description : String?
unit : String?
}

Builder for a monotonic counter instrument. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

CounterBuilder::build

Builds the counter instrument and registers it with the provider. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

CounterBuilder::with_description

fn CounterBuilder::with_description(self : CounterBuilder, description : StringView) -> CounterBuilder

Sets the instrument description. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-description

CounterBuilder::with_unit

fn CounterBuilder::with_unit(self : CounterBuilder, unit : StringView) -> CounterBuilder

Sets the instrument unit. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-unit

DoubleCounter

pub struct DoubleCounter {
state :
Ref
[SyncInstrumentState]
}

Floating-point counter instrument handle. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#counter

DoubleCounter::add

Adds a floating-point delta to the counter for one attribute set. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#measurement

DoubleCounterBuilder

pub struct DoubleCounterBuilder {
meter : SdkMeter
name : String
description : String?
unit : String?
}

Builder for a monotonic floating-point counter instrument. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

DoubleCounterBuilder::build

Builds the floating-point counter instrument and registers it with the provider. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

DoubleCounterBuilder::with_description

fn DoubleCounterBuilder::with_description(self : DoubleCounterBuilder, description : StringView) -> DoubleCounterBuilder

Sets the instrument description. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-description

DoubleCounterBuilder::with_unit

fn DoubleCounterBuilder::with_unit(self : DoubleCounterBuilder, unit : StringView) -> DoubleCounterBuilder

Sets the instrument unit. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-unit

DoubleUpDownCounter

pub struct DoubleUpDownCounter {
state :
Ref
[SyncInstrumentState]
}

Floating-point up-down counter instrument handle. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#updowncounter

DoubleUpDownCounter::add

Adds a floating-point delta to the up-down counter for one attribute set. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#measurement

DoubleUpDownCounterBuilder

pub struct DoubleUpDownCounterBuilder {
meter : SdkMeter
name : String
description : String?
unit : String?
}

Builder for a signed floating-point counter instrument. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

DoubleUpDownCounterBuilder::build

Builds the floating-point up-down counter instrument and registers it with the provider. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

DoubleUpDownCounterBuilder::with_description

fn DoubleUpDownCounterBuilder::with_description(self : DoubleUpDownCounterBuilder, description : StringView) -> DoubleUpDownCounterBuilder

Sets the instrument description. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-description

DoubleUpDownCounterBuilder::with_unit

Sets the instrument unit. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-unit

Gauge

Gauge instrument handle. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#gauge

Gauge::record

fn Gauge::record(self : Gauge, value : Double, attributes? : ArrayView[
KeyValue
]) -> Unit

Records the latest gauge value for an attribute set. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#measurement

GaugeBuilder

pub struct GaugeBuilder {
meter : SdkMeter
name : String
description : String?
unit : String?
}

Builder for a gauge instrument. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

GaugeBuilder::build

fn GaugeBuilder::build(self : GaugeBuilder) -> Gauge

Builds the gauge instrument and registers it with the provider. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

GaugeBuilder::with_description

fn GaugeBuilder::with_description(self : GaugeBuilder, description : StringView) -> GaugeBuilder

Sets the instrument description. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-description

GaugeBuilder::with_unit

fn GaugeBuilder::with_unit(self : GaugeBuilder, unit : StringView) -> GaugeBuilder

Sets the instrument unit. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-unit

Histogram

pub struct Histogram {
state :
Ref
[SyncInstrumentState]
}

Histogram instrument handle. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#histogram

Histogram::record

fn Histogram::record(self : Histogram, value : Double, attributes? : ArrayView[
KeyValue
]) -> Unit

Records one histogram sample for an attribute set. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#measurement

HistogramBuilder

pub struct HistogramBuilder {
meter : SdkMeter
name : String
description : String?
unit : String?
}

Builder for a histogram instrument. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

HistogramBuilder::build

Builds the histogram instrument and registers it with the provider. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

HistogramBuilder::with_description

fn HistogramBuilder::with_description(self : HistogramBuilder, description : StringView) -> HistogramBuilder

Sets the instrument description. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-description

HistogramBuilder::with_unit

fn HistogramBuilder::with_unit(self : HistogramBuilder, unit : StringView) -> HistogramBuilder

Sets the instrument unit. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-unit

HistogramSummary

pub struct HistogramSummary {
count : Int64
sum : Number
min : Number?
max : Number?
} derive(Eq, ToJson,
Debug
)

Compact histogram summary emitted by the current implementation. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#aggregation

InMemoryMetricExporter

pub struct InMemoryMetricExporter {
state :
Ref
[InMemoryMetricExporterState]
}

Test exporter that keeps finished metrics in memory. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk_exporters/in-memory/#metrics-exporter---in-memory

InMemoryMetricExporter::finished_metrics

Returns the finished metrics accumulated so far. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk_exporters/in-memory/#metrics-exporter---in-memory

InMemoryMetricExporter::into_metric_exporter

Erases the concrete in-memory exporter type into MetricExporter. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk_exporters/in-memory/#metrics-exporter---in-memory

InMemoryMetricExporter::new

Creates an empty in-memory metric exporter. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk_exporters/in-memory/#metrics-exporter---in-memory

InMemoryMetricExporter::reset

Clears the in-memory metric buffer. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk_exporters/in-memory/#metrics-exporter---in-memory

InMemoryMetricExporterState

type InMemoryMetricExporterState

Instrument

pub struct Instrument {
name : String
description : String?
unit : String?
kind : InstrumentKind
instrumentation_scope :
InstrumentationScope

} derive(Eq, ToJson,
Debug
)

Instrument metadata used by views to match and transform streams. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#view

InstrumentKind

pub(all) enum InstrumentKind {
Counter
UpDownCounter
Histogram
Gauge
ObservableCounter
ObservableUpDownCounter
ObservableGauge
} derive(Compare, Eq, Hash, ToJson,
Debug
)

Supported metric instrument kinds.

Instrument kind is part of stream identity and controls the default aggregation selected by the SDK. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

ManualReader

pub struct ManualReader {
state :
Ref
[ManualReaderState]
}

Pull-based metric reader that snapshots the provider on demand.

Use this in tests or integrations that want explicit collection instead of a background export loop. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#metricreader

ManualReader::builder

Creates a detached manual reader that can later be registered with a provider using SdkMeterProviderBuilder::with_reader(). Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#metricreader

ManualReader::collect

fn ManualReader::collect(self : ManualReader) -> Array[MetricData]

Pulls a metric snapshot from the provider. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#metricreader

ManualReader::collect_result

Pulls a metric snapshot from the provider and returns lifecycle failures. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#metricreader

ManualReader::force_flush

Manual readers do not own exporters, so force_flush is a no-op.

ManualReader::shutdown

Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#shutdown

ManualReader::shutdown_with_timeout

async fn ManualReader::shutdown_with_timeout(self : ManualReader, timeout_millis : Int) -> Result[Unit,
OTelSdkError
]

Detaches the reader from the provider.

ManualReaderBuilder

pub struct ManualReaderBuilder {
temporality : Temporality
}

Builder for ManualReader. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#metricreader

ManualReaderBuilder::build

Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#metricreader

ManualReaderBuilder::with_temporality

fn ManualReaderBuilder::with_temporality(self : ManualReaderBuilder, temporality : Temporality) -> ManualReaderBuilder

Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#metricreader

ManualReaderState

type ManualReaderState

MeterProviderState

type MeterProviderState

MetricData

Immutable metric data item exported from a meter provider. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#metricreader

MetricExporter

pub struct MetricExporter {
export_fn : async (ArrayView[MetricData]) -> Result[Unit,
OTelSdkError
]
force_flush_fn : async () -> Result[Unit,
OTelSdkError
]
shutdown_fn : async () -> Result[Unit,
OTelSdkError
]
name_fn : () -> String
}

Exporter callback wrapper for metric batches. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#metricexporter

MetricExporter::export_batch

Exports one batch of metrics. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#exportbatch

MetricExporter::force_flush

Requests exporter flush. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#forceflush

MetricExporter::name

fn MetricExporter::name(self : MetricExporter) -> String

Returns a human-readable exporter name. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#metricexporter

MetricExporter::new

fn MetricExporter::new(export_fn : async (ArrayView[MetricData]) -> Result[Unit,
OTelSdkError
], force_flush_fn? : async () -> Result[Unit,
OTelSdkError
], shutdown_fn? : async () -> Result[Unit,
OTelSdkError
], name_fn? : () -> String) -> MetricExporter

Builds a metric exporter from callbacks. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#metricexporter

MetricExporter::shutdown

Requests exporter shutdown. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#shutdown

MetricExporter::shutdown_with_timeout

async fn MetricExporter::shutdown_with_timeout(self : MetricExporter, timeout_millis : Int) -> Result[Unit,
OTelSdkError
]

Requests exporter shutdown with an optional timeout budget in milliseconds. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#shutdown

Number

pub(all) enum Number {
Int64(Int64)
UInt64(UInt64)
Double(Double)
} derive(Eq, ToJson,
Debug
)

Numeric value stored inside metric aggregations. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#aggregation

ObservableCounter

pub struct ObservableCounter {
state :
Ref
[SyncInstrumentState]
}

Observable counter instrument handle passed to callbacks. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#asynchronous-counter

ObservableCounter::observe

Observes one value for an observable counter during callback execution. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#measurement

ObservableCounterBuilder

pub struct ObservableCounterBuilder {
meter : SdkMeter
name : String
description : String?
unit : String?
callbacks : Array[(ObservableCounter) -> Unit]
}

Builder for an observable monotonic counter instrument. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

ObservableCounterBuilder::build

Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

ObservableCounterBuilder::with_callback

Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

ObservableCounterBuilder::with_description

fn ObservableCounterBuilder::with_description(self : ObservableCounterBuilder, description : StringView) -> ObservableCounterBuilder

Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-description

ObservableCounterBuilder::with_unit

Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-unit

ObservableDoubleCounter

pub struct ObservableDoubleCounter {
state :
Ref
[SyncInstrumentState]
}

Observable floating-point counter instrument handle passed to callbacks. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#asynchronous-counter

ObservableDoubleCounter::observe

Observes one floating-point value for an observable counter during callback execution. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#measurement

ObservableDoubleCounterBuilder

pub struct ObservableDoubleCounterBuilder {
meter : SdkMeter
name : String
description : String?
unit : String?
callbacks : Array[(ObservableDoubleCounter) -> Unit]
}

Builder for an observable monotonic floating-point counter instrument. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

ObservableDoubleCounterBuilder::build

Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

ObservableDoubleCounterBuilder::with_callback

Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

ObservableDoubleCounterBuilder::with_description

fn ObservableDoubleCounterBuilder::with_description(self : ObservableDoubleCounterBuilder, description : StringView) -> ObservableDoubleCounterBuilder

Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-description

ObservableDoubleCounterBuilder::with_unit

Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-unit

ObservableDoubleUpDownCounter

pub struct ObservableDoubleUpDownCounter {
state :
Ref
[SyncInstrumentState]
}

Observable floating-point up-down counter instrument handle passed to callbacks. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#asynchronous-updowncounter

ObservableDoubleUpDownCounter::observe

Observes one floating-point value for an observable up-down counter during callback execution. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#measurement

ObservableDoubleUpDownCounterBuilder

pub struct ObservableDoubleUpDownCounterBuilder {
meter : SdkMeter
name : String
description : String?
unit : String?
callbacks : Array[(ObservableDoubleUpDownCounter) -> Unit]
}

Builder for an observable signed floating-point counter instrument. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

ObservableDoubleUpDownCounterBuilder::build

Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

ObservableDoubleUpDownCounterBuilder::with_callback

Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

ObservableDoubleUpDownCounterBuilder::with_description

Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-description

ObservableDoubleUpDownCounterBuilder::with_unit

Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-unit

ObservableGauge

pub struct ObservableGauge {
state :
Ref
[SyncInstrumentState]
}

Observable gauge instrument handle passed to callbacks. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#asynchronous-gauge

ObservableGauge::observe

Observes one value for an observable gauge during callback execution. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#measurement

ObservableGaugeBuilder

pub struct ObservableGaugeBuilder {
meter : SdkMeter
name : String
description : String?
unit : String?
callbacks : Array[(ObservableGauge) -> Unit]
}

Builder for an observable gauge instrument. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

ObservableGaugeBuilder::build

Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

ObservableGaugeBuilder::with_callback

fn ObservableGaugeBuilder::with_callback(self : ObservableGaugeBuilder, callback : (ObservableGauge) -> Unit) -> ObservableGaugeBuilder

Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

ObservableGaugeBuilder::with_description

fn ObservableGaugeBuilder::with_description(self : ObservableGaugeBuilder, description : StringView) -> ObservableGaugeBuilder

Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-description

ObservableGaugeBuilder::with_unit

fn ObservableGaugeBuilder::with_unit(self : ObservableGaugeBuilder, unit : StringView) -> ObservableGaugeBuilder

Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-unit

ObservableUInt64Counter

pub struct ObservableUInt64Counter {
state :
Ref
[SyncInstrumentState]
}

Unsigned observable counter instrument handle passed to callbacks. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#asynchronous-counter

ObservableUInt64Counter::observe

Observes one unsigned value for an observable counter during callback execution. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#measurement

ObservableUInt64CounterBuilder

pub struct ObservableUInt64CounterBuilder {
meter : SdkMeter
name : String
description : String?
unit : String?
callbacks : Array[(ObservableUInt64Counter) -> Unit]
}

Builder for an unsigned observable monotonic counter instrument. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

ObservableUInt64CounterBuilder::build

Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

ObservableUInt64CounterBuilder::with_callback

Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

ObservableUInt64CounterBuilder::with_description

fn ObservableUInt64CounterBuilder::with_description(self : ObservableUInt64CounterBuilder, description : StringView) -> ObservableUInt64CounterBuilder

Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-description

ObservableUInt64CounterBuilder::with_unit

Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-unit

ObservableUInt64Gauge

pub struct ObservableUInt64Gauge {
state :
Ref
[SyncInstrumentState]
}

Unsigned observable gauge instrument handle passed to callbacks. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#asynchronous-gauge

ObservableUInt64Gauge::observe

Observes one unsigned value for an observable gauge during callback execution. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#measurement

ObservableUInt64GaugeBuilder

pub struct ObservableUInt64GaugeBuilder {
meter : SdkMeter
name : String
description : String?
unit : String?
callbacks : Array[(ObservableUInt64Gauge) -> Unit]
}

Builder for an unsigned observable gauge instrument. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

ObservableUInt64GaugeBuilder::build

Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

ObservableUInt64GaugeBuilder::with_callback

Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

ObservableUInt64GaugeBuilder::with_description

fn ObservableUInt64GaugeBuilder::with_description(self : ObservableUInt64GaugeBuilder, description : StringView) -> ObservableUInt64GaugeBuilder

Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-description

ObservableUInt64GaugeBuilder::with_unit

Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-unit

ObservableUpDownCounter

pub struct ObservableUpDownCounter {
state :
Ref
[SyncInstrumentState]
}

Observable up-down counter instrument handle passed to callbacks. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#asynchronous-updowncounter

ObservableUpDownCounter::observe

Observes one value for an observable up-down counter during callback execution. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#measurement

ObservableUpDownCounterBuilder

pub struct ObservableUpDownCounterBuilder {
meter : SdkMeter
name : String
description : String?
unit : String?
callbacks : Array[(ObservableUpDownCounter) -> Unit]
}

Builder for an observable signed counter instrument. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

ObservableUpDownCounterBuilder::build

Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

ObservableUpDownCounterBuilder::with_callback

Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

ObservableUpDownCounterBuilder::with_description

fn ObservableUpDownCounterBuilder::with_description(self : ObservableUpDownCounterBuilder, description : StringView) -> ObservableUpDownCounterBuilder

Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-description

ObservableUpDownCounterBuilder::with_unit

Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-unit

PeriodicMetricReader

pub struct PeriodicMetricReader {
state :
Ref
[PeriodicMetricReaderState]
}

Push-style metric reader that exports snapshots on an interval.

The interval loop is not started automatically. Register the provider and call spawn_periodic_readers() or the facade/global equivalent. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#periodic-exporting-metricreader

PeriodicMetricReader::builder

Creates a detached periodic reader around the supplied exporter. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#periodic-exporting-metricreader

PeriodicMetricReader::collect

Collects one snapshot for this reader and applies its temporality policy. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#periodic-exporting-metricreader

PeriodicMetricReader::force_flush

Exports one temporality-adjusted snapshot immediately. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#forceflush

PeriodicMetricReader::run

async fn PeriodicMetricReader::run(self : PeriodicMetricReader) -> Unit

Background loop for periodic metric collection and export. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#periodic-exporting-metricreader

PeriodicMetricReader::shutdown

Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#shutdown

PeriodicMetricReader::shutdown_with_timeout

async fn PeriodicMetricReader::shutdown_with_timeout(self : PeriodicMetricReader, timeout_millis : Int) -> Result[Unit,
OTelSdkError
]

Shuts down the periodic reader and its exporter. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#shutdown

PeriodicMetricReaderBuilder

pub struct PeriodicMetricReaderBuilder {
exporter : MetricExporter
interval_millis : Int
temporality : Temporality
}

Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#periodic-exporting-metricreader

PeriodicMetricReaderBuilder::build

Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#periodic-exporting-metricreader

PeriodicMetricReaderBuilder::with_interval

fn PeriodicMetricReaderBuilder::with_interval(self : PeriodicMetricReaderBuilder, interval_millis : Int) -> PeriodicMetricReaderBuilder

Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#periodic-exporting-metricreader

PeriodicMetricReaderBuilder::with_temporality

Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#periodic-exporting-metricreader

PeriodicMetricReaderState

type PeriodicMetricReaderState

SdkMeter

Meter scoped to one instrumentation library.

Meters create instruments. Instruments should usually be built once and reused on hot paths. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#meter

SdkMeter::counter

fn SdkMeter::counter(self : SdkMeter, name : StringView) -> CounterBuilder

Starts building a counter instrument. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#counter-creation

SdkMeter::f64_counter

fn SdkMeter::f64_counter(self : SdkMeter, name : StringView) -> DoubleCounterBuilder

Starts building a floating-point counter instrument. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#counter-creation

SdkMeter::f64_observable_counter

fn SdkMeter::f64_observable_counter(self : SdkMeter, name : StringView) -> ObservableDoubleCounterBuilder

Starts building an observable floating-point counter instrument. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#asynchronous-counter-creation

SdkMeter::f64_observable_up_down_counter

fn SdkMeter::f64_observable_up_down_counter(self : SdkMeter, name : StringView) -> ObservableDoubleUpDownCounterBuilder

Starts building an observable floating-point up-down counter instrument. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#asynchronous-updowncounter-creation

SdkMeter::f64_up_down_counter

fn SdkMeter::f64_up_down_counter(self : SdkMeter, name : StringView) -> DoubleUpDownCounterBuilder

Starts building a floating-point up-down counter instrument. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#updowncounter-creation

SdkMeter::gauge

fn SdkMeter::gauge(self : SdkMeter, name : StringView) -> GaugeBuilder

Starts building a gauge instrument. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#gauge-creation

SdkMeter::histogram

fn SdkMeter::histogram(self : SdkMeter, name : StringView) -> HistogramBuilder

Starts building a histogram instrument. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#histogram-creation

SdkMeter::observable_counter

fn SdkMeter::observable_counter(self : SdkMeter, name : StringView) -> ObservableCounterBuilder

Starts building an observable counter instrument. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#asynchronous-counter-creation

SdkMeter::observable_gauge

fn SdkMeter::observable_gauge(self : SdkMeter, name : StringView) -> ObservableGaugeBuilder

Starts building an observable gauge instrument. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#asynchronous-gauge-creation

SdkMeter::observable_up_down_counter

fn SdkMeter::observable_up_down_counter(self : SdkMeter, name : StringView) -> ObservableUpDownCounterBuilder

Starts building an observable up-down counter instrument. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#asynchronous-updowncounter-creation

SdkMeter::u64_counter

fn SdkMeter::u64_counter(self : SdkMeter, name : StringView) -> UInt64CounterBuilder

Starts building an unsigned counter instrument. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#counter-creation

SdkMeter::u64_gauge

fn SdkMeter::u64_gauge(self : SdkMeter, name : StringView) -> UInt64GaugeBuilder

Starts building an unsigned gauge instrument. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#gauge-creation

SdkMeter::u64_histogram

fn SdkMeter::u64_histogram(self : SdkMeter, name : StringView) -> UInt64HistogramBuilder

Starts building an unsigned histogram instrument. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#histogram-creation

SdkMeter::u64_observable_counter

fn SdkMeter::u64_observable_counter(self : SdkMeter, name : StringView) -> ObservableUInt64CounterBuilder

Starts building an unsigned observable counter instrument. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#asynchronous-counter-creation

SdkMeter::u64_observable_gauge

fn SdkMeter::u64_observable_gauge(self : SdkMeter, name : StringView) -> ObservableUInt64GaugeBuilder

Starts building an unsigned observable gauge instrument. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#asynchronous-gauge-creation

SdkMeter::up_down_counter

fn SdkMeter::up_down_counter(self : SdkMeter, name : StringView) -> UpDownCounterBuilder

Starts building an up-down counter instrument. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#updowncounter-creation

SdkMeterProvider

pub struct SdkMeterProvider {
state :
Ref
[MeterProviderState]
}

Owns resource metadata, registered instruments, exporters, and readers.

Applications create one provider, configure readers/exporters/views, and shut it down during application teardown. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#meterprovider

SdkMeterProvider::builder

Starts building a meter provider with the default resource.

Add readers, exporters, or views before build(). A provider without readers/exporters still aggregates local measurements but exports nothing. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#meterprovider

SdkMeterProvider::collect

Collects a fresh snapshot from every registered synchronous instrument. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#meterprovider

SdkMeterProvider::force_flush

Collects and exports a fresh metric snapshot through every exporter. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#forceflush

SdkMeterProvider::into_meter_provider

Erases this SDK provider into the public metrics API provider. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#meterprovider

SdkMeterProvider::manual_reader

fn SdkMeterProvider::manual_reader(self : SdkMeterProvider) -> ManualReader

Creates a pull-based reader over this provider. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#metricreader

SdkMeterProvider::meter

fn SdkMeterProvider::meter(self : SdkMeterProvider, name : StringView, version? : String?, schema_url? : String?, attributes? : ArrayView[
KeyValue
]) -> SdkMeter

Creates a meter scoped to the supplied instrumentation library metadata.

The instrumentation scope is attached to metric data produced by instruments created from the meter. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#meter

SdkMeterProvider::resource

Returns the provider resource. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#meterprovider

SdkMeterProvider::shutdown

Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#shutdown

SdkMeterProvider::shutdown_with_timeout

async fn SdkMeterProvider::shutdown_with_timeout(self : SdkMeterProvider, timeout_millis : Int) -> Result[Unit,
OTelSdkError
]

Flushes exporters, then shuts them down and marks the provider unusable. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#shutdown

SdkMeterProvider::spawn_periodic_readers

fn SdkMeterProvider::spawn_periodic_readers(self : SdkMeterProvider, group :
TaskGroup
[Unit], allow_failure? : Bool) -> Unit

Spawns all configured periodic readers into the provided task group. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#metricreader

SdkMeterProviderBuilder

pub struct SdkMeterProviderBuilder {
resource :
Resource

exporters : Array[MetricExporter]
manual_readers : Array[ManualReader]
periodic_readers : Array[PeriodicMetricReader]
views : Array[(Instrument) -> Stream?]
}

Builder for SdkMeterProvider. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#meterprovider

SdkMeterProviderBuilder::build

Builds the meter provider and wires up periodic readers. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#meterprovider

SdkMeterProviderBuilder::with_exporter

Registers an exporter used during force_flush() and shutdown().

For periodic background export, use with_periodic_exporter() or register a PeriodicMetricReader. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#metricexporter

SdkMeterProviderBuilder::with_periodic_exporter

fn SdkMeterProviderBuilder::with_periodic_exporter(self : SdkMeterProviderBuilder, exporter : MetricExporter, interval_millis? : Int) -> SdkMeterProviderBuilder

Registers an exporter and a periodic reader for background exports.

A negative interval uses the SDK default. Zero is normalized to one millisecond. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#metricexporter

SdkMeterProviderBuilder::with_periodic_reader

Registers a periodic reader with the provider.

The reader's background loop starts only after spawn_periodic_readers() or the facade/global equivalent is called. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#metricreader

SdkMeterProviderBuilder::with_reader

Registers a manual reader with the provider.

Manual readers are useful for tests and pull-style integrations. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#metricreader

SdkMeterProviderBuilder::with_resource

Replaces the provider resource. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#meterprovider

SdkMeterProviderBuilder::with_view

Adds a view that can rename or reshape future metric streams.

Views apply when instruments are registered. Use them to select aggregation, filter attributes, rename streams, or set cardinality limits. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#view

Stream

pub struct Stream {
name : String?
description : String?
unit : String?
aggregation : StreamAggregation?
allowed_attribute_keys : Array[String]?
cardinality_limit : Int?
} derive(Eq, ToJson,
Debug
)

Stream configuration returned by a view. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#view

Stream::builder

fn Stream::builder() -> StreamBuilder

Creates an empty stream builder. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#stream-configuration

StreamAggregation

pub(all) enum StreamAggregation {
Default
Drop
Sum
LastValue
Histogram
} derive(Eq, ToJson,
Debug
)

Aggregation selection used by metric views.

Views can keep the default, drop a stream, or force a supported aggregation. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#aggregation

StreamBuilder

pub struct StreamBuilder {
name : String?
description : String?
unit : String?
aggregation : StreamAggregation?
allowed_attribute_keys : Array[String]?
cardinality_limit : Int?
}

Builder for stream transformations. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#view

StreamBuilder::build

fn StreamBuilder::build(self : StreamBuilder) -> Stream

Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#stream-configuration

StreamBuilder::with_aggregation

fn StreamBuilder::with_aggregation(self : StreamBuilder, aggregation : StreamAggregation) -> StreamBuilder

Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#stream-configuration

StreamBuilder::with_allowed_attribute_keys

fn StreamBuilder::with_allowed_attribute_keys(self : StreamBuilder, keys : ArrayView[StringView]) -> StreamBuilder

Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#stream-configuration

StreamBuilder::with_cardinality_limit

fn StreamBuilder::with_cardinality_limit(self : StreamBuilder, limit : Int) -> StreamBuilder

Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#stream-configuration

StreamBuilder::with_description

fn StreamBuilder::with_description(self : StreamBuilder, description : StringView) -> StreamBuilder

Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#stream-configuration

StreamBuilder::with_name

fn StreamBuilder::with_name(self : StreamBuilder, name : StringView) -> StreamBuilder

Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#stream-configuration

StreamBuilder::with_unit

fn StreamBuilder::with_unit(self : StreamBuilder, unit : StringView) -> StreamBuilder

Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#stream-configuration

SyncInstrumentState

type SyncInstrumentState

Temporality

pub(all) enum Temporality {
Cumulative
Delta
LowMemory
} derive(Compare, Eq, Hash, ToJson,
Debug
)

Defines the time window used when readers report aggregated measurements. Spec: https://opentelemetry.io/docs/specs/otel/metrics/sdk/#metricreader

UInt64Counter

pub struct UInt64Counter {
state :
Ref
[SyncInstrumentState]
}

Unsigned counter instrument handle. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#counter

UInt64Counter::add

Adds a delta to the unsigned counter for one attribute set. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#measurement

UInt64CounterBuilder

pub struct UInt64CounterBuilder {
meter : SdkMeter
name : String
description : String?
unit : String?
}

Builder for an unsigned monotonic counter instrument. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

UInt64CounterBuilder::build

Builds the unsigned counter instrument and registers it with the provider. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

UInt64CounterBuilder::with_description

fn UInt64CounterBuilder::with_description(self : UInt64CounterBuilder, description : StringView) -> UInt64CounterBuilder

Sets the instrument description. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-description

UInt64CounterBuilder::with_unit

fn UInt64CounterBuilder::with_unit(self : UInt64CounterBuilder, unit : StringView) -> UInt64CounterBuilder

Sets the instrument unit. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-unit

UInt64Gauge

pub struct UInt64Gauge {
state :
Ref
[SyncInstrumentState]
}

Unsigned gauge instrument handle. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#gauge

UInt64Gauge::record

Records the latest unsigned gauge value for an attribute set. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#measurement

UInt64GaugeBuilder

pub struct UInt64GaugeBuilder {
meter : SdkMeter
name : String
description : String?
unit : String?
}

Builder for an unsigned gauge instrument. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

UInt64GaugeBuilder::build

Builds the unsigned gauge instrument and registers it with the provider. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

UInt64GaugeBuilder::with_description

fn UInt64GaugeBuilder::with_description(self : UInt64GaugeBuilder, description : StringView) -> UInt64GaugeBuilder

Sets the instrument description. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-description

UInt64GaugeBuilder::with_unit

fn UInt64GaugeBuilder::with_unit(self : UInt64GaugeBuilder, unit : StringView) -> UInt64GaugeBuilder

Sets the instrument unit. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-unit

UInt64Histogram

pub struct UInt64Histogram {
state :
Ref
[SyncInstrumentState]
}

Unsigned histogram instrument handle. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#histogram

UInt64Histogram::record

Records one unsigned histogram sample for an attribute set. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#measurement

UInt64HistogramBuilder

pub struct UInt64HistogramBuilder {
meter : SdkMeter
name : String
description : String?
unit : String?
}

Builder for an unsigned histogram instrument. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

UInt64HistogramBuilder::build

Builds the unsigned histogram instrument and registers it with the provider. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

UInt64HistogramBuilder::with_description

fn UInt64HistogramBuilder::with_description(self : UInt64HistogramBuilder, description : StringView) -> UInt64HistogramBuilder

Sets the instrument description. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-description

UInt64HistogramBuilder::with_unit

fn UInt64HistogramBuilder::with_unit(self : UInt64HistogramBuilder, unit : StringView) -> UInt64HistogramBuilder

Sets the instrument unit. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-unit

UpDownCounter

pub struct UpDownCounter {
state :
Ref
[SyncInstrumentState]
}

Up-down counter instrument handle. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#updowncounter

UpDownCounter::add

Adds a delta to the up-down counter for one attribute set. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#measurement

UpDownCounterBuilder

pub struct UpDownCounterBuilder {
meter : SdkMeter
name : String
description : String?
unit : String?
}

Builder for a signed counter instrument. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

UpDownCounterBuilder::build

Builds the up-down counter instrument and registers it with the provider. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

UpDownCounterBuilder::with_description

fn UpDownCounterBuilder::with_description(self : UpDownCounterBuilder, description : StringView) -> UpDownCounterBuilder

Sets the instrument description. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-description

UpDownCounterBuilder::with_unit

fn UpDownCounterBuilder::with_unit(self : UpDownCounterBuilder, unit : StringView) -> UpDownCounterBuilder

Sets the instrument unit. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-unit

Source Files