1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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;
}