opentelemetry_sdk/metrics/
noop.rs

1use opentelemetry::{
2    metrics::{InstrumentProvider, SyncInstrument},
3    KeyValue,
4};
5
6/// A no-op instance of a `Meter`
7#[derive(Debug, Default)]
8pub(crate) struct NoopMeter {
9    _private: (),
10}
11
12impl NoopMeter {
13    /// Create a new no-op meter core.
14    pub(crate) fn new() -> Self {
15        NoopMeter { _private: () }
16    }
17}
18
19impl InstrumentProvider for NoopMeter {}
20
21/// A no-op sync instrument
22#[derive(Debug, Default)]
23pub(crate) struct NoopSyncInstrument {
24    _private: (),
25}
26
27impl NoopSyncInstrument {
28    /// Create a new no-op sync instrument
29    pub(crate) fn new() -> Self {
30        NoopSyncInstrument { _private: () }
31    }
32}
33
34impl<T> SyncInstrument<T> for NoopSyncInstrument {
35    fn measure(&self, _value: T, _attributes: &[KeyValue]) {
36        // Ignored
37    }
38}