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