@@ -22,32 +22,51 @@ lazy_static::lazy_static! {
22
22
}
23
23
24
24
/// A no-op instance of a `MetricProvider`
25
- #[ derive( Debug ) ]
26
- pub struct NoopMeterProvider ;
25
+ #[ derive( Debug , Default ) ]
26
+ pub struct NoopMeterProvider {
27
+ _private : ( ) ,
28
+ }
29
+
30
+ impl NoopMeterProvider {
31
+ /// Create a new no-op meter provider.
32
+ pub fn new ( ) -> Self {
33
+ NoopMeterProvider { _private : ( ) }
34
+ }
35
+ }
36
+
27
37
impl MeterProvider for NoopMeterProvider {
28
38
fn meter ( & self , name : & str ) -> Meter {
29
- Meter :: new ( name, Arc :: new ( NoopMeterCore ) )
39
+ Meter :: new ( name, Arc :: new ( NoopMeterCore :: new ( ) ) )
30
40
}
31
41
}
32
42
33
43
/// A no-op instance of a `Meter`
34
- #[ derive( Debug ) ]
35
- pub struct NoopMeterCore ;
44
+ #[ derive( Debug , Default ) ]
45
+ pub struct NoopMeterCore {
46
+ _private : ( ) ,
47
+ }
48
+
49
+ impl NoopMeterCore {
50
+ /// Create a new no-op meter core.
51
+ pub fn new ( ) -> Self {
52
+ NoopMeterCore { _private : ( ) }
53
+ }
54
+ }
36
55
37
56
impl MeterCore for NoopMeterCore {
38
57
fn new_sync_instrument (
39
58
& self ,
40
59
_descriptor : Descriptor ,
41
60
) -> Result < Arc < dyn SyncInstrumentCore + Send + Sync > > {
42
- Ok ( Arc :: new ( NoopSyncInstrument ) )
61
+ Ok ( Arc :: new ( NoopSyncInstrument :: new ( ) ) )
43
62
}
44
63
45
64
fn new_async_instrument (
46
65
& self ,
47
66
_descriptor : Descriptor ,
48
67
_runner : AsyncRunner ,
49
68
) -> Result < Arc < dyn AsyncInstrumentCore + Send + Sync > > {
50
- Ok ( Arc :: new ( NoopAsyncInstrument ) )
69
+ Ok ( Arc :: new ( NoopAsyncInstrument :: new ( ) ) )
51
70
}
52
71
53
72
fn record_batch_with_context (
@@ -61,8 +80,17 @@ impl MeterCore for NoopMeterCore {
61
80
}
62
81
63
82
/// A no-op sync instrument
64
- #[ derive( Debug ) ]
65
- pub struct NoopSyncInstrument ;
83
+ #[ derive( Debug , Default ) ]
84
+ pub struct NoopSyncInstrument {
85
+ _private : ( ) ,
86
+ }
87
+
88
+ impl NoopSyncInstrument {
89
+ /// Create a new no-op sync instrument
90
+ pub fn new ( ) -> Self {
91
+ NoopSyncInstrument { _private : ( ) }
92
+ }
93
+ }
66
94
67
95
impl InstrumentCore for NoopSyncInstrument {
68
96
fn descriptor ( & self ) -> & Descriptor {
@@ -72,7 +100,7 @@ impl InstrumentCore for NoopSyncInstrument {
72
100
73
101
impl SyncInstrumentCore for NoopSyncInstrument {
74
102
fn bind ( & self , _labels : & ' _ [ KeyValue ] ) -> Arc < dyn SyncBoundInstrumentCore + Send + Sync > {
75
- Arc :: new ( NoopBoundSyncInstrument )
103
+ Arc :: new ( NoopBoundSyncInstrument :: new ( ) )
76
104
}
77
105
fn record_one ( & self , _number : Number , _labels : & ' _ [ KeyValue ] ) {
78
106
// Ignored
@@ -83,8 +111,17 @@ impl SyncInstrumentCore for NoopSyncInstrument {
83
111
}
84
112
85
113
/// A no-op bound sync instrument
86
- #[ derive( Debug ) ]
87
- pub struct NoopBoundSyncInstrument ;
114
+ #[ derive( Debug , Default ) ]
115
+ pub struct NoopBoundSyncInstrument {
116
+ _private : ( ) ,
117
+ }
118
+
119
+ impl NoopBoundSyncInstrument {
120
+ /// Create a new no-op bound sync instrument
121
+ pub fn new ( ) -> Self {
122
+ NoopBoundSyncInstrument { _private : ( ) }
123
+ }
124
+ }
88
125
89
126
impl SyncBoundInstrumentCore for NoopBoundSyncInstrument {
90
127
fn record_one ( & self , _number : Number ) {
@@ -93,8 +130,17 @@ impl SyncBoundInstrumentCore for NoopBoundSyncInstrument {
93
130
}
94
131
95
132
/// A no-op async instrument.
96
- #[ derive( Debug ) ]
97
- pub struct NoopAsyncInstrument ;
133
+ #[ derive( Debug , Default ) ]
134
+ pub struct NoopAsyncInstrument {
135
+ _private : ( ) ,
136
+ }
137
+
138
+ impl NoopAsyncInstrument {
139
+ /// Create a new no-op async instrument
140
+ pub fn new ( ) -> Self {
141
+ NoopAsyncInstrument { _private : ( ) }
142
+ }
143
+ }
98
144
99
145
impl InstrumentCore for NoopAsyncInstrument {
100
146
fn descriptor ( & self ) -> & Descriptor {
0 commit comments