use crate::metrics::{AsyncRunner, Descriptor, Measurement, Number, Result};
use crate::{Context, KeyValue};
use std::any::Any;
use std::fmt;
use std::sync::Arc;
pub trait MeterCore: fmt::Debug {
fn record_batch_with_context(
&self,
cx: &Context,
attributes: &[KeyValue],
measurements: Vec<Measurement>,
);
fn new_sync_instrument(&self, descriptor: Descriptor) -> Result<Arc<dyn SyncInstrumentCore>>;
fn new_async_instrument(
&self,
descriptor: Descriptor,
runner: Option<AsyncRunner>,
) -> Result<Arc<dyn AsyncInstrumentCore>>;
fn new_batch_observer(&self, runner: AsyncRunner) -> Result<()>;
}
pub trait InstrumentCore: fmt::Debug + Send + Sync {
fn descriptor(&self) -> &Descriptor;
}
pub trait SyncInstrumentCore: InstrumentCore {
fn bind(&self, attributes: &'_ [KeyValue]) -> Arc<dyn SyncBoundInstrumentCore>;
fn record_one(&self, number: Number, attributes: &'_ [KeyValue]);
fn as_any(&self) -> &dyn Any;
}
pub trait SyncBoundInstrumentCore: fmt::Debug + Send + Sync {
fn record_one(&self, number: Number);
}
pub trait AsyncInstrumentCore: InstrumentCore {
fn as_any(&self) -> &dyn Any;
}