Struct opentelemetry::metrics::Meter[][src]

pub struct Meter { /* fields omitted */ }
This is supported on crate feature metrics only.
Expand description

Meter is the OpenTelemetry metric API, based on a sdk-defined MeterCore implementation and the Meter library name.

Instruments

NameInstrument kindFunction(argument)Default aggregationNotes
CounterSynchronous adding monotonicAdd(increment)SumPer-request, part of a monotonic sum
UpDownCounterSynchronous addingAdd(increment)SumPer-request, part of a non-monotonic sum
ValueRecorderSynchronousRecord(value)TBD issue 636Per-request, any grouping measurement
SumObserverAsynchronous adding monotonicObserve(sum)SumPer-interval, reporting a monotonic sum
UpDownSumObserverAsynchronous addingObserve(sum)SumPer-interval, reporting a non-monotonic sum
ValueObserverAsynchronousObserve(value)LastValuePer-interval, any grouping measurement

Implementations

Create a new named meter from a sdk implemented core

Creates a new integer CounterBuilder for u64 values with the given name.

Creates a new floating point CounterBuilder for f64 values with the given name.

Creates a new integer UpDownCounterBuilder for an i64 up down counter with the given name.

Creates a new floating point UpDownCounterBuilder for an f64 up down counter with the given name.

Creates a new ValueRecorderBuilder for i64 values with the given name.

Creates a new ValueRecorderBuilder for u64 values with the given name.

Creates a new ValueRecorderBuilder for f64 values with the given name.

Creates a new integer SumObserverBuilder for u64 values with the given name and callback

Creates a new floating point SumObserverBuilder for f64 values with the given name and callback

Creates a new integer UpDownSumObserverBuilder for i64 values with the given name and callback.

Creates a new floating point UpDownSumObserverBuilder for f64 values with the given name and callback

Creates a new integer ValueObserverBuilder for u64 values with the given name and callback

Creates a new integer ValueObserverBuilder for i64 values with the given name and callback

Creates a new floating point ValueObserverBuilder for f64 values with the given name and callback

Creates a new BatchObserver that supports making batches of observations for multiple instruments or returns an error if instrument initialization fails.

Examples

use opentelemetry::{global, metrics::BatchObserverResult, KeyValue};

let meter = global::meter("test");

meter.build_batch_observer(|batch| {
  let instrument = batch.u64_value_observer("test_instrument").try_init()?;

  Ok(move |result: BatchObserverResult| {
    result.observe(&[KeyValue::new("my-key", "my-value")], &[instrument.observation(1)]);
  })
})?;

Creates a new BatchObserver that supports making batches of observations for multiple instruments.

Panics

Panics if instrument initialization or observer registration returns an error.

Examples

use opentelemetry::{global, metrics::BatchObserverResult, KeyValue};

let meter = global::meter("test");

meter.batch_observer(|batch| {
  let instrument = batch.u64_value_observer("test_instrument").init();

  move |result: BatchObserverResult| {
    result.observe(&[KeyValue::new("my-key", "my-value")], &[instrument.observation(1)]);
  }
});

Atomically record a batch of measurements.

Atomically record a batch of measurements with a given context

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.