use crate::attributes::{Attributes, Context};
pub trait MeterProvider {
fn get_meter(&self, scope: &'static str, attributes: Option<&Attributes>) -> Box<dyn Meter>;
fn as_any(&self) -> &dyn std::any::Any;
}
pub trait Meter {
#[allow(clippy::type_complexity)]
fn create_gauge(
&self,
name: String,
callback: Box<dyn Fn(&dyn AsyncMeasurement<Value = f64>) + Send + Sync>,
units: Option<String>,
description: Option<String>,
) -> Box<dyn AsyncMeasurement<Value = f64>>;
fn create_up_down_counter(
&self,
name: String,
units: Option<String>,
description: Option<String>,
) -> Box<dyn UpDownCounter>;
#[allow(clippy::type_complexity)]
fn create_async_up_down_counter(
&self,
name: String,
callback: Box<dyn Fn(&dyn AsyncMeasurement<Value = i64>) + Send + Sync>,
units: Option<String>,
description: Option<String>,
) -> Box<dyn AsyncMeasurement<Value = i64>>;
fn create_monotonic_counter(
&self,
name: String,
units: Option<String>,
description: Option<String>,
) -> Box<dyn MonotonicCounter>;
#[allow(clippy::type_complexity)]
fn create_async_monotonic_counter(
&self,
name: String,
callback: Box<dyn Fn(&dyn AsyncMeasurement<Value = u64>) + Send + Sync>,
units: Option<String>,
description: Option<String>,
) -> Box<dyn AsyncMeasurement<Value = u64>>;
fn create_histogram(
&self,
name: String,
units: Option<String>,
description: Option<String>,
) -> Box<dyn Histogram>;
}
pub trait Histogram {
fn record(&self, value: f64, attributes: Option<&Attributes>, context: Option<&dyn Context>);
}
pub trait MonotonicCounter {
fn add(&self, value: u64, attributes: Option<&Attributes>, context: Option<&dyn Context>);
}
pub trait UpDownCounter {
fn add(&self, value: i64, attributes: Option<&Attributes>, context: Option<&dyn Context>);
}
pub trait AsyncMeasurement {
type Value;
fn record(
&self,
value: Self::Value,
attributes: Option<&Attributes>,
context: Option<&dyn Context>,
);
fn stop(&self);
}