README

#OpenTelemetry Metrics API

This package is the public metrics API. It lets instrumentation code describe measurements without depending on a concrete SDK, reader, or exporter.

Metrics are not exported one measurement at a time. Instruments record raw measurements into in-memory aggregation state. SDK readers later collect the aggregated metric points and exporters send those points to a backend.

#Main Types

  • MeterProvider: entry point that creates meters
  • Meter: creates instruments for one instrumentation scope
  • Counter, UpDownCounter, Histogram, Gauge: synchronous instruments
  • ObservableCounter, ObservableUpDownCounter, ObservableGauge: callback instruments observed during collection
  • builder types for every instrument kind

#Choosing Instruments

Choose the instrument based on the meaning of the value, not only its type:

Use caseInstrument
Count requests, errors, bytes sent, or other monotonic totalsCounter
Track active requests, queue depth, or connections that go up and downUpDownCounter
Record latency, payload size, or other distributionsHistogram
Record latest temperature, memory use, or other current stateGauge
Read a value owned elsewhere only when metrics are collectedObservable instrument

Prefer low-cardinality attributes. Values such as user IDs, raw URLs, UUIDs, or unbounded error strings can create too many time series.

#Recording Measurements

Create instruments once and reuse them. Instrument creation may register SDK state; recording is the hot path.

///|
fn _metrics_readme_record() -> Unit {
let meter = MeterProvider::noop().meter("example")
let counter = meter
.u64_counter("request.count")
.with_description("Total handled requests")
.build()
let latency = meter.f64_histogram("request.duration").with_unit("ms").build()

counter.add(1UL, attributes=[
@common.KeyValue::new("http.request.method", String("GET")),
])
latency.record(12.5, attributes=[
@common.KeyValue::new("http.route", String("/health")),
])
}

The SDK ignores negative deltas for monotonic counters. Use an up-down counter when the value can decrease.

#Observable Instruments

Observable instruments are callbacks. Use them when the measurement already lives somewhere else and should be read during collection, for example process memory, queue length, connection pool size, or OS counters.

///|
fn _metrics_readme_observable() -> Unit {
let meter = MeterProvider::noop().meter("example")
let observable = meter
.i64_observable_up_down_counter("queue.depth")
.with_callback(observer => observer.observe(42L))
.build()
ignore(observable)
}

Callbacks are frozen when build() is called. If a no-op meter is used, callbacks are accepted but never collected by an SDK reader.

#Provider Reference

  • MeterProvider::noop() creates no-op instruments.
  • meter(name) creates a meter for one instrumentation name.
  • meter_with_scope(scope) creates a meter from a full instrumentation scope.

Applications register SDK providers through sdk.set_meter_provider(provider); the SDK facade updates interface/global for API callers.

#Instrument Reference

  • Counter::add(value, attributes?) records a monotonic delta.
  • UpDownCounter::add(value, attributes?) records a signed delta.
  • Histogram::record(value, attributes?) records one sample.
  • Gauge::record(value, attributes?) records the latest value.
  • ObservableCounter::observe(value, attributes?) reports a callback value for a monotonic observable counter.
  • ObservableUpDownCounter::observe(value, attributes?) reports a callback value for an additive observable counter.
  • ObservableGauge::observe(value, attributes?) reports a callback value for a gauge.

#Builder Reference

All builders expose:

  • with_description(description): human-readable explanation of the instrument
  • with_unit(unit): UCUM-style unit such as ms, By, or 1
  • build(): creates the instrument

Observable builders also expose with_callback(callback).

#Meter Factory Reference

Counters:

  • u64_counter(name)
  • f64_counter(name)

Up-down counters:

  • i64_up_down_counter(name)
  • f64_up_down_counter(name)

Histograms:

  • u64_histogram(name)
  • f64_histogram(name)

Gauges:

  • u64_gauge(name)
  • i64_gauge(name), converted to the SDK's floating-point representation
  • f64_gauge(name)

Observable counters:

  • u64_observable_counter(name)
  • f64_observable_counter(name)

Observable up-down counters:

  • i64_observable_up_down_counter(name)
  • f64_observable_up_down_counter(name)

Observable gauges:

  • u64_observable_gauge(name)
  • i64_observable_gauge(name), callback values converted to floating point
  • f64_observable_gauge(name)

#No-Op Behavior

No-op meters return builders whose built instruments silently discard measurements. This lets libraries record metrics unconditionally while the final application decides whether a real SDK provider and reader are installed.

#
Counter

Monotonic synchronous counter handle.

Use counters for values that only increase, such as requests served, errors observed, or bytes sent. Negative deltas are ignored by the SDK. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#counter

#
Counter::add

fn[T] Counter::add(self : Counter[T], value : T, attributes? : ArrayView[
KeyValue
]) -> Unit

Adds one measurement to a monotonic counter.

The underlying SDK ignores negative deltas. Attributes should be low-cardinality because they form metric series identity. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#counter

#
Counter::from_functions

Builds a counter handle from an add callback. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#counter

#
CounterBuilder

pub struct CounterBuilder[T] {
description : String?
unit : String?
create_fn : (String?, String?) -> Counter[T]
}

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

#
CounterBuilder::build

fn[T] CounterBuilder::build(self : CounterBuilder[T]) -> Counter[T]

Builds the counter with the current builder options. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

#
CounterBuilder::from_functions

fn[T] CounterBuilder::from_functions(create_fn : (String?, String?) -> Counter[T]) -> CounterBuilder[T]

Builds a counter builder from a creation callback. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

#
CounterBuilder::with_description

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

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

#
CounterBuilder::with_unit

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

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

#
Gauge

pub struct Gauge[T] {
record_fn : (T, ArrayView[
KeyValue
]) -> Unit
}

Synchronous gauge handle recording the latest value for one attribute set.

Use gauges for current-state measurements such as memory usage or temperature. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#gauge

#
Gauge::from_functions

fn[T] Gauge::from_functions(record_fn : (T, ArrayView[
KeyValue
]) -> Unit) -> Gauge[T]

Builds a gauge handle from a record callback. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#gauge

#
Gauge::record

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

Records the latest gauge value for one attribute set.

The latest value replaces the previous value for the same attribute set. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#gauge

#
GaugeBuilder

pub struct GaugeBuilder[T] {
description : String?
unit : String?
create_fn : (String?, String?) -> Gauge[T]
}

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

#
GaugeBuilder::build

fn[T] GaugeBuilder::build(self : GaugeBuilder[T]) -> Gauge[T]

Builds the gauge with the current builder options. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

#
GaugeBuilder::from_functions

fn[T] GaugeBuilder::from_functions(create_fn : (String?, String?) -> Gauge[T]) -> GaugeBuilder[T]

Builds a gauge builder from a creation callback. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

#
GaugeBuilder::with_description

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

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

#
GaugeBuilder::with_unit

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

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

#
Histogram

pub struct Histogram[T] {
record_fn : (T, ArrayView[
KeyValue
]) -> Unit
}

Synchronous histogram handle.

Use histograms for distributions such as request latency, payload size, or retry count. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#histogram

#
Histogram::from_functions

Builds a histogram handle from a record callback. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#histogram

#
Histogram::record

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

Records one histogram sample.

Histograms aggregate distributions and are usually the right choice for latency and size measurements. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#histogram

#
HistogramBuilder

pub struct HistogramBuilder[T] {
description : String?
unit : String?
create_fn : (String?, String?) -> Histogram[T]
}

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

#
HistogramBuilder::build

fn[T] HistogramBuilder::build(self : HistogramBuilder[T]) -> Histogram[T]

Builds the histogram with the current builder options. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

#
HistogramBuilder::from_functions

fn[T] HistogramBuilder::from_functions(create_fn : (String?, String?) -> Histogram[T]) -> HistogramBuilder[T]

Builds a histogram builder from a creation callback. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

#
HistogramBuilder::with_description

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

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

#
HistogramBuilder::with_unit

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

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

#
Meter

pub struct Meter {
u64_counter_fn : (String) -> CounterBuilder[UInt64]
f64_counter_fn : (String) -> CounterBuilder[Double]
i64_up_down_counter_fn : (String) -> UpDownCounterBuilder[Int64]
f64_up_down_counter_fn : (String) -> UpDownCounterBuilder[Double]
u64_histogram_fn : (String) -> HistogramBuilder[UInt64]
f64_histogram_fn : (String) -> HistogramBuilder[Double]
u64_gauge_fn : (String) -> GaugeBuilder[UInt64]
i64_gauge_fn : (String) -> GaugeBuilder[Int64]
f64_gauge_fn : (String) -> GaugeBuilder[Double]
u64_observable_counter_fn : (String) -> ObservableCounterBuilder[UInt64]
f64_observable_counter_fn : (String) -> ObservableCounterBuilder[Double]
i64_observable_up_down_counter_fn : (String) -> ObservableUpDownCounterBuilder[Int64]
f64_observable_up_down_counter_fn : (String) -> ObservableUpDownCounterBuilder[Double]
u64_observable_gauge_fn : (String) -> ObservableGaugeBuilder[UInt64]
i64_observable_gauge_fn : (String) -> ObservableGaugeBuilder[Int64]
f64_observable_gauge_fn : (String) -> ObservableGaugeBuilder[Double]
}

Public meter handle.

A meter creates reusable instruments for one instrumentation scope. Create instruments once and reuse them on hot paths. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#meter

#
Meter::f64_counter

fn Meter::f64_counter(self : Meter, name : StringView) -> CounterBuilder[Double]

Starts building a Double monotonic counter.

The underlying SDK ignores negative deltas. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#counter-creation

#
Meter::f64_gauge

fn Meter::f64_gauge(self : Meter, name : StringView) -> GaugeBuilder[Double]

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

#
Meter::f64_histogram

fn Meter::f64_histogram(self : Meter, name : StringView) -> HistogramBuilder[Double]

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

#
Meter::f64_observable_counter

fn Meter::f64_observable_counter(self : Meter, name : StringView) -> ObservableCounterBuilder[Double]

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

#
Meter::f64_observable_gauge

fn Meter::f64_observable_gauge(self : Meter, name : StringView) -> ObservableGaugeBuilder[Double]

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

#
Meter::f64_observable_up_down_counter

fn Meter::f64_observable_up_down_counter(self : Meter, name : StringView) -> ObservableUpDownCounterBuilder[Double]

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

#
Meter::f64_up_down_counter

fn Meter::f64_up_down_counter(self : Meter, name : StringView) -> UpDownCounterBuilder[Double]

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

#
Meter::from_functions

fn Meter::from_functions(u64_counter_fn : (String) -> CounterBuilder[UInt64], f64_counter_fn : (String) -> CounterBuilder[Double], i64_up_down_counter_fn : (String) -> UpDownCounterBuilder[Int64], f64_up_down_counter_fn : (String) -> UpDownCounterBuilder[Double], u64_histogram_fn : (String) -> HistogramBuilder[UInt64], f64_histogram_fn : (String) -> HistogramBuilder[Double], u64_gauge_fn : (String) -> GaugeBuilder[UInt64], i64_gauge_fn : (String) -> GaugeBuilder[Int64], f64_gauge_fn : (String) -> GaugeBuilder[Double], u64_observable_counter_fn : (String) -> ObservableCounterBuilder[UInt64], f64_observable_counter_fn : (String) -> ObservableCounterBuilder[Double], i64_observable_up_down_counter_fn : (String) -> ObservableUpDownCounterBuilder[Int64], f64_observable_up_down_counter_fn : (String) -> ObservableUpDownCounterBuilder[Double], u64_observable_gauge_fn : (String) -> ObservableGaugeBuilder[UInt64], i64_observable_gauge_fn : (String) -> ObservableGaugeBuilder[Int64], f64_observable_gauge_fn : (String) -> ObservableGaugeBuilder[Double]) -> Meter

Builds a meter from instrument-builder callbacks.

SDK implementations use this to erase concrete meter types into the public API without making the API package depend on the SDK. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#meter

#
Meter::i64_gauge

fn Meter::i64_gauge(self : Meter, name : StringView) -> GaugeBuilder[Int64]

Starts building an Int64 gauge.

Values are converted to Double before they are forwarded to the SDK. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#gauge-creation

#
Meter::i64_observable_gauge

fn Meter::i64_observable_gauge(self : Meter, name : StringView) -> ObservableGaugeBuilder[Int64]

Starts building an Int64 observable gauge.

Callback observations are converted to Double before they are forwarded to the SDK. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#asynchronous-gauge-creation

#
Meter::i64_observable_up_down_counter

fn Meter::i64_observable_up_down_counter(self : Meter, name : StringView) -> ObservableUpDownCounterBuilder[Int64]

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

#
Meter::i64_up_down_counter

fn Meter::i64_up_down_counter(self : Meter, name : StringView) -> UpDownCounterBuilder[Int64]

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

#
Meter::u64_counter

fn Meter::u64_counter(self : Meter, name : StringView) -> CounterBuilder[UInt64]

Starts building a UInt64 monotonic counter.

Instrument names should be stable and low-cardinality. The same named instrument should be built once and reused. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#counter-creation

#
Meter::u64_gauge

fn Meter::u64_gauge(self : Meter, name : StringView) -> GaugeBuilder[UInt64]

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

#
Meter::u64_histogram

fn Meter::u64_histogram(self : Meter, name : StringView) -> HistogramBuilder[UInt64]

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

#
Meter::u64_observable_counter

fn Meter::u64_observable_counter(self : Meter, name : StringView) -> ObservableCounterBuilder[UInt64]

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

#
Meter::u64_observable_gauge

fn Meter::u64_observable_gauge(self : Meter, name : StringView) -> ObservableGaugeBuilder[UInt64]

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

#
MeterProvider

Public meter provider.

The default provider is no-op. Applications install SDK-backed providers through the SDK facade while library code depends only on this API type. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#meterprovider

#
MeterProvider::from_functions

Builds a meter provider from a scope-to-meter callback. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#meterprovider

#
MeterProvider::meter

fn MeterProvider::meter(self : MeterProvider, name : StringView) -> Meter

Returns a meter for one instrumentation name.

If the provider is no-op, the returned meter creates no-op instruments. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#get-a-meter

#
MeterProvider::meter_with_scope

Returns a meter for a fully constructed instrumentation scope. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#get-a-meter

#
MeterProvider::noop

Returns a no-op meter provider.

Meters from this provider create instruments that silently discard all measurements and never run observable callbacks. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#meterprovider

#
ObservableCounter

pub struct ObservableCounter[T] {
observe_fn : (T, ArrayView[
KeyValue
]) -> Unit
}

Observable monotonic counter handle used inside callbacks.

Observable instruments report values during SDK collection instead of at the point where application work happens. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#asynchronous-counter

#
ObservableCounter::from_functions

Builds an observable counter handle from an observe callback. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#asynchronous-counter

#
ObservableCounter::observe

Reports one observable counter value from a callback. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#asynchronous-counter

#
ObservableCounterBuilder

pub struct ObservableCounterBuilder[T] {
description : String?
unit : String?
callbacks : Array[(ObservableCounter[T]) -> Unit]
create_fn : (String?, String?, Array[(ObservableCounter[T]) -> Unit]) -> ObservableCounter[T]
}

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

#
ObservableCounterBuilder::build

Builds the observable counter and freezes the currently registered callbacks. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

#
ObservableCounterBuilder::from_functions

fn[T] ObservableCounterBuilder::from_functions(create_fn : (String?, String?, Array[(ObservableCounter[T]) -> Unit]) -> ObservableCounter[T]) -> ObservableCounterBuilder[T]

Builds an observable counter builder from a creation callback. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

#
ObservableCounterBuilder::with_callback

fn[T] ObservableCounterBuilder::with_callback(self : ObservableCounterBuilder[T], callback : (ObservableCounter[T]) -> Unit) -> ObservableCounterBuilder[T]

Registers one callback to run during metric collection.

Keep callbacks fast and side-effect-light. They run on collection/export paths, not when the observable instrument is created. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

#
ObservableCounterBuilder::with_description

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

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

#
ObservableCounterBuilder::with_unit

fn[T] ObservableCounterBuilder::with_unit(self : ObservableCounterBuilder[T], unit : StringView) -> ObservableCounterBuilder[T]

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

#
ObservableGauge

pub struct ObservableGauge[T] {
observe_fn : (T, ArrayView[
KeyValue
]) -> Unit
}

Observable gauge handle used inside callbacks. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#asynchronous-gauge

#
ObservableGauge::from_functions

Builds an observable gauge handle from an observe callback. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#asynchronous-gauge

#
ObservableGauge::observe

Reports one observable gauge value from a callback. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#asynchronous-gauge

#
ObservableGaugeBuilder

pub struct ObservableGaugeBuilder[T] {
description : String?
unit : String?
callbacks : Array[(ObservableGauge[T]) -> Unit]
create_fn : (String?, String?, Array[(ObservableGauge[T]) -> Unit]) -> ObservableGauge[T]
}

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

#
ObservableGaugeBuilder::build

Builds the observable gauge and freezes the currently registered callbacks. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

#
ObservableGaugeBuilder::from_functions

fn[T] ObservableGaugeBuilder::from_functions(create_fn : (String?, String?, Array[(ObservableGauge[T]) -> Unit]) -> ObservableGauge[T]) -> ObservableGaugeBuilder[T]

Builds an observable gauge builder from a creation callback. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

#
ObservableGaugeBuilder::with_callback

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

Registers one callback to run during metric collection.

Keep callbacks fast and side-effect-light. They run on collection/export paths, not when the observable instrument is created. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

#
ObservableGaugeBuilder::with_description

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

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

#
ObservableGaugeBuilder::with_unit

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

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

#
ObservableUpDownCounter

pub struct ObservableUpDownCounter[T] {
observe_fn : (T, ArrayView[
KeyValue
]) -> Unit
}

Observable additive counter handle used inside callbacks. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#asynchronous-updowncounter

#
ObservableUpDownCounter::from_functions

Builds an observable up-down counter handle from an observe callback. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#asynchronous-updowncounter

#
ObservableUpDownCounter::observe

Reports one observable up-down counter value from a callback. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#asynchronous-updowncounter

#
ObservableUpDownCounterBuilder

pub struct ObservableUpDownCounterBuilder[T] {
description : String?
unit : String?
callbacks : Array[(ObservableUpDownCounter[T]) -> Unit]
create_fn : (String?, String?, Array[(ObservableUpDownCounter[T]) -> Unit]) -> ObservableUpDownCounter[T]
}

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

#
ObservableUpDownCounterBuilder::build

Builds the observable up-down counter and freezes the currently registered callbacks. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

#
ObservableUpDownCounterBuilder::from_functions

fn[T] ObservableUpDownCounterBuilder::from_functions(create_fn : (String?, String?, Array[(ObservableUpDownCounter[T]) -> Unit]) -> ObservableUpDownCounter[T]) -> ObservableUpDownCounterBuilder[T]

Builds an observable up-down counter builder from a creation callback. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

#
ObservableUpDownCounterBuilder::with_callback

Registers one callback to run during metric collection.

Keep callbacks fast and side-effect-light. They run on collection/export paths, not when the observable instrument is created. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

#
ObservableUpDownCounterBuilder::with_description

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

Sets the instrument description on the observable up-down counter builder. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-description

#
ObservableUpDownCounterBuilder::with_unit

Sets the instrument unit on the observable up-down counter builder. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-unit

#
UpDownCounter

pub struct UpDownCounter[T] {
add_fn : (T, ArrayView[
KeyValue
]) -> Unit
}

Additive synchronous counter that accepts positive and negative deltas.

Use up-down counters for state that can increase and decrease, such as active requests, queue depth, or open connections. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#updowncounter

#
UpDownCounter::add

Adds one measurement to an up-down counter.

Use this for state that can go up and down. For monotonically increasing totals, prefer Counter. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#updowncounter

#
UpDownCounter::from_functions

Builds an up-down counter handle from an add callback. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#updowncounter

#
UpDownCounterBuilder

pub struct UpDownCounterBuilder[T] {
description : String?
unit : String?
create_fn : (String?, String?) -> UpDownCounter[T]
}

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

#
UpDownCounterBuilder::build

Builds the up-down counter with the current builder options. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

#
UpDownCounterBuilder::from_functions

fn[T] UpDownCounterBuilder::from_functions(create_fn : (String?, String?) -> UpDownCounter[T]) -> UpDownCounterBuilder[T]

Builds an up-down counter builder from a creation callback. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument

#
UpDownCounterBuilder::with_description

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

Sets the instrument description on the up-down counter builder. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-description

#
UpDownCounterBuilder::with_unit

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

Sets the instrument unit on the up-down counter builder. Spec: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-unit

Source Files