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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
use crate::{
metrics::{
AsyncCounter, AsyncGauge, AsyncUpDownCounter, InstrumentProvider, Meter, MeterProvider,
Result, SyncCounter, SyncHistogram, SyncUpDownCounter,
},
Context, InstrumentationLibrary, KeyValue,
};
use std::sync::Arc;
#[derive(Debug, Default)]
pub struct NoopMeterProvider {
_private: (),
}
impl NoopMeterProvider {
pub fn new() -> Self {
NoopMeterProvider { _private: () }
}
}
impl MeterProvider for NoopMeterProvider {
fn versioned_meter(
&self,
name: &'static str,
version: Option<&'static str>,
schema_url: Option<&'static str>,
) -> Meter {
let library = InstrumentationLibrary::new(name, version, schema_url);
Meter::new(library, Arc::new(NoopMeterCore::new()))
}
}
#[derive(Debug, Default)]
pub struct NoopMeterCore {
_private: (),
}
impl NoopMeterCore {
pub fn new() -> Self {
NoopMeterCore { _private: () }
}
}
impl InstrumentProvider for NoopMeterCore {
fn register_callback(&self, _callback: Box<dyn Fn(&Context) + Send + Sync>) -> Result<()> {
Ok(())
}
}
#[derive(Debug, Default)]
pub struct NoopSyncInstrument {
_private: (),
}
impl NoopSyncInstrument {
pub fn new() -> Self {
NoopSyncInstrument { _private: () }
}
}
impl<T> SyncCounter<T> for NoopSyncInstrument {
fn add(&self, _cx: &Context, _value: T, _attributes: &[KeyValue]) {
}
}
impl<T> SyncUpDownCounter<T> for NoopSyncInstrument {
fn add(&self, _cx: &Context, _value: T, _attributes: &[KeyValue]) {
}
}
impl<T> SyncHistogram<T> for NoopSyncInstrument {
fn record(&self, _cx: &Context, _value: T, _attributes: &[KeyValue]) {
}
}
#[derive(Debug, Default)]
pub struct NoopAsyncInstrument {
_private: (),
}
impl NoopAsyncInstrument {
pub fn new() -> Self {
NoopAsyncInstrument { _private: () }
}
}
impl<T> AsyncGauge<T> for NoopAsyncInstrument {
fn observe(&self, _cx: &Context, _value: T, _attributes: &[KeyValue]) {
}
}
impl<T> AsyncCounter<T> for NoopAsyncInstrument {
fn observe(&self, _cx: &Context, _value: T, _attributes: &[KeyValue]) {
}
}
impl<T> AsyncUpDownCounter<T> for NoopAsyncInstrument {
fn observe(&self, _cx: &Context, _value: T, _attributes: &[KeyValue]) {
}
}