Struct opentelemetry::metrics::Meter [−][src]
pub struct Meter { /* fields omitted */ }
metrics
only.Expand description
Meter is the OpenTelemetry metric API, based on a sdk-defined MeterCore
implementation and the Meter
library name.
Instruments
Name | Instrument kind | Function(argument) | Default aggregation | Notes |
---|---|---|---|---|
Counter | Synchronous adding monotonic | Add(increment) | Sum | Per-request, part of a monotonic sum |
UpDownCounter | Synchronous adding | Add(increment) | Sum | Per-request, part of a non-monotonic sum |
ValueRecorder | Synchronous | Record(value) | TBD issue 636 | Per-request, any grouping measurement |
SumObserver | Asynchronous adding monotonic | Observe(sum) | Sum | Per-interval, reporting a monotonic sum |
UpDownSumObserver | Asynchronous adding | Observe(sum) | Sum | Per-interval, reporting a non-monotonic sum |
ValueObserver | Asynchronous | Observe(value) | LastValue | Per-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.
pub fn i64_up_down_counter<T>(&self, name: T) -> UpDownCounterBuilder<'_, i64> where
T: Into<String>,
pub fn i64_up_down_counter<T>(&self, name: T) -> UpDownCounterBuilder<'_, i64> where
T: Into<String>,
Creates a new integer UpDownCounterBuilder
for an i64
up down counter with the given name.
pub fn f64_up_down_counter<T>(&self, name: T) -> UpDownCounterBuilder<'_, f64> where
T: Into<String>,
pub fn f64_up_down_counter<T>(&self, name: T) -> UpDownCounterBuilder<'_, f64> where
T: Into<String>,
Creates a new floating point UpDownCounterBuilder
for an f64
up down counter with the given name.
pub fn i64_value_recorder<T>(&self, name: T) -> ValueRecorderBuilder<'_, i64> where
T: Into<String>,
pub fn i64_value_recorder<T>(&self, name: T) -> ValueRecorderBuilder<'_, i64> where
T: Into<String>,
Creates a new ValueRecorderBuilder
for i64
values with the given name.
pub fn u64_value_recorder<T>(&self, name: T) -> ValueRecorderBuilder<'_, u64> where
T: Into<String>,
pub fn u64_value_recorder<T>(&self, name: T) -> ValueRecorderBuilder<'_, u64> where
T: Into<String>,
Creates a new ValueRecorderBuilder
for u64
values with the given name.
pub fn f64_value_recorder<T>(&self, name: T) -> ValueRecorderBuilder<'_, f64> where
T: Into<String>,
pub fn f64_value_recorder<T>(&self, name: T) -> ValueRecorderBuilder<'_, f64> where
T: Into<String>,
Creates a new ValueRecorderBuilder
for f64
values with the given name.
pub fn u64_sum_observer<T, F>(
&self,
name: T,
callback: F
) -> SumObserverBuilder<'_, u64> where
T: Into<String>,
F: Fn(ObserverResult<u64>) + Send + Sync + 'static,
pub fn u64_sum_observer<T, F>(
&self,
name: T,
callback: F
) -> SumObserverBuilder<'_, u64> where
T: Into<String>,
F: Fn(ObserverResult<u64>) + Send + Sync + 'static,
Creates a new integer SumObserverBuilder
for u64
values with the given
name and callback
pub fn f64_sum_observer<T, F>(
&self,
name: T,
callback: F
) -> SumObserverBuilder<'_, f64> where
T: Into<String>,
F: Fn(ObserverResult<f64>) + Send + Sync + 'static,
pub fn f64_sum_observer<T, F>(
&self,
name: T,
callback: F
) -> SumObserverBuilder<'_, f64> where
T: Into<String>,
F: Fn(ObserverResult<f64>) + Send + Sync + 'static,
Creates a new floating point SumObserverBuilder
for f64
values with the
given name and callback
pub fn i64_up_down_sum_observer<T, F>(
&self,
name: T,
callback: F
) -> UpDownSumObserverBuilder<'_, i64> where
T: Into<String>,
F: Fn(ObserverResult<i64>) + Send + Sync + 'static,
pub fn i64_up_down_sum_observer<T, F>(
&self,
name: T,
callback: F
) -> UpDownSumObserverBuilder<'_, i64> where
T: Into<String>,
F: Fn(ObserverResult<i64>) + Send + Sync + 'static,
Creates a new integer UpDownSumObserverBuilder
for i64
values with the
given name and callback.
pub fn f64_up_down_sum_observer<T, F>(
&self,
name: T,
callback: F
) -> UpDownSumObserverBuilder<'_, f64> where
T: Into<String>,
F: Fn(ObserverResult<f64>) + Send + Sync + 'static,
pub fn f64_up_down_sum_observer<T, F>(
&self,
name: T,
callback: F
) -> UpDownSumObserverBuilder<'_, f64> where
T: Into<String>,
F: Fn(ObserverResult<f64>) + Send + Sync + 'static,
Creates a new floating point UpDownSumObserverBuilder
for f64
values
with the given name and callback
pub fn u64_value_observer<T, F>(
&self,
name: T,
callback: F
) -> ValueObserverBuilder<'_, u64> where
T: Into<String>,
F: Fn(ObserverResult<u64>) + Send + Sync + 'static,
pub fn u64_value_observer<T, F>(
&self,
name: T,
callback: F
) -> ValueObserverBuilder<'_, u64> where
T: Into<String>,
F: Fn(ObserverResult<u64>) + Send + Sync + 'static,
Creates a new integer ValueObserverBuilder
for u64
values with the given
name and callback
pub fn i64_value_observer<T, F>(
&self,
name: T,
callback: F
) -> ValueObserverBuilder<'_, i64> where
T: Into<String>,
F: Fn(ObserverResult<i64>) + Send + Sync + 'static,
pub fn i64_value_observer<T, F>(
&self,
name: T,
callback: F
) -> ValueObserverBuilder<'_, i64> where
T: Into<String>,
F: Fn(ObserverResult<i64>) + Send + Sync + 'static,
Creates a new integer ValueObserverBuilder
for i64
values with the given
name and callback
pub fn f64_value_observer<T, F>(
&self,
name: T,
callback: F
) -> ValueObserverBuilder<'_, f64> where
T: Into<String>,
F: Fn(ObserverResult<f64>) + Send + Sync + 'static,
pub fn f64_value_observer<T, F>(
&self,
name: T,
callback: F
) -> ValueObserverBuilder<'_, f64> where
T: Into<String>,
F: Fn(ObserverResult<f64>) + Send + Sync + 'static,
Creates a new floating point ValueObserverBuilder
for f64
values with
the given name and callback
pub fn build_batch_observer<B, F>(&self, builder: B) -> Result<()> where
B: Fn(BatchObserver<'_>) -> Result<F>,
F: Fn(BatchObserverResult) + Send + Sync + 'static,
pub fn build_batch_observer<B, F>(&self, builder: B) -> Result<()> where
B: Fn(BatchObserver<'_>) -> Result<F>,
F: Fn(BatchObserverResult) + Send + Sync + 'static,
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)]); }) })?;
pub fn batch_observer<B, F>(&self, builder: B) where
B: Fn(BatchObserver<'_>) -> F,
F: Fn(BatchObserverResult) + Send + Sync + 'static,
pub fn batch_observer<B, F>(&self, builder: B) where
B: Fn(BatchObserver<'_>) -> F,
F: Fn(BatchObserverResult) + Send + Sync + 'static,
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)]); } });
pub fn record_batch<T: IntoIterator<Item = Measurement>>(
&self,
attributes: &[KeyValue],
measurements: T
)
pub fn record_batch<T: IntoIterator<Item = Measurement>>(
&self,
attributes: &[KeyValue],
measurements: T
)
Atomically record a batch of measurements.
pub fn record_batch_with_context<T: IntoIterator<Item = Measurement>>(
&self,
cx: &Context,
attributes: &[KeyValue],
measurements: T
)
pub fn record_batch_with_context<T: IntoIterator<Item = Measurement>>(
&self,
cx: &Context,
attributes: &[KeyValue],
measurements: T
)
Atomically record a batch of measurements with a given context