Rust

Crate root

Module
What utopia_telemetry defines at its root.

Modules

Contents

use utopia_telemetry::ObservableGauge;
Rust
pub struct ObservableGauge(Arc<dyn Observe>)

A gauge read when the backend collects, by callbacks that report the current values (pool sizes, queue depths), instead of being recorded on every change.

Backends share one instrument per name, so several sources (one per connection pool) can each add a callback and report their own series.

Also implements Debug.
use utopia_telemetry::Observation;
Rust
pub struct Observation

One measurement an ObservableGauge callback reported.

use utopia_telemetry::Number;
Rust
pub enum Number

A measurement: an integer or a float. Integers stay integers through sums, so a counter that only ever adds integers reports an integer.

Also implements Add, From, Display.
use utopia_telemetry::Value;
Rust
pub enum Value<'a>

The value of an attribute.

Also implements From.
use utopia_telemetry::Observe;
Rust
pub trait Observe: Send + Sync

What a backend does with the callbacks of an observable gauge. Implement it, with Record, to add a backend.

Implemented byGaugedNothingLazy
use utopia_telemetry::Observer;
Rust
pub trait Observer

Receives the measurements of an ObservableGauge callback.

Implemented byVec
use utopia_telemetry::Record;
Rust
pub trait Record: Send + Sync

What a backend does with a measurement of one synchronous instrument. Implement it, with Observe, to add a backend.

Implemented byRecorderNothingLazy
use utopia_telemetry::Telemetry;
Rust
pub trait Telemetry: Send + Sync

Creates instruments and exports what they recorded. Implement it to add a backend.

Creating an instrument is cheap and records nothing: backends register an instrument on its first measurement, so one that never records is never exported.

use utopia_telemetry::to_owned;
Rust
pub fn to_owned(attributes: Attributes<'_>) -> OwnedAttributes

Copies borrowed attributes into owned ones.

Rust
pub type Attributes<'a> = &'a [(&'a str, Value<'a>)]

The attributes of one measurement: (name, value) pairs, in order.

Rust
pub type BoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + Send + 'a>>

A boxed future, as Telemetry::collect and transports return.

Rust
pub type Callback = Arc<dyn Fn() -> BoxFuture<'static, Vec<Observation>> + Send + Sync>

A callback an ObservableGauge runs when the backend collects: it returns the measurements to report, and may wait (on a shared store, say) before it does.

Rust
pub type OwnedAttributes = Vec<(String, Value<'static>)>

Owned attributes, as backends keep them.