use crate::KeyValue;
use core::fmt;
use std::sync::Arc;
use super::SyncInstrument;
#[derive(Clone)]
#[non_exhaustive]
pub struct Histogram<T>(Arc<dyn SyncInstrument<T> + Send + Sync>);
impl<T> fmt::Debug for Histogram<T>
where
T: fmt::Debug,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_fmt(format_args!("Histogram<{}>", std::any::type_name::<T>()))
}
}
impl<T> Histogram<T> {
pub fn new(inner: Arc<dyn SyncInstrument<T> + Send + Sync>) -> Self {
Histogram(inner)
}
pub fn record(&self, value: T, attributes: &[KeyValue]) {
self.0.measure(value, attributes)
}
}