Skip to content

Commit a56fc2f

Browse files
authored
Derive Debug trait for all structs and enums (#504)
1 parent 55273f0 commit a56fc2f

File tree

30 files changed

+128
-17
lines changed

30 files changed

+128
-17
lines changed

metrics-exporter-prometheus/src/common.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ pub enum BuildError {
8080
ZeroBucketDuration,
8181
}
8282

83+
#[derive(Debug)]
8384
pub struct Snapshot {
8485
pub counters: HashMap<String, HashMap<Vec<String>, u64>>,
8586
pub gauges: HashMap<String, HashMap<Vec<String>, f64>>,

metrics-exporter-prometheus/src/distribution.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const DEFAULT_SUMMARY_BUCKET_COUNT: NonZeroU32 = match NonZeroU32::new(3) {
1515
const DEFAULT_SUMMARY_BUCKET_DURATION: Duration = Duration::from_secs(20);
1616

1717
/// Distribution type.
18-
#[derive(Clone)]
18+
#[derive(Clone, Debug)]
1919
pub enum Distribution {
2020
/// A Prometheus histogram.
2121
///
@@ -137,14 +137,14 @@ impl DistributionBuilder {
137137
}
138138
}
139139

140-
#[derive(Clone)]
140+
#[derive(Clone, Debug)]
141141
struct Bucket {
142142
begin: Instant,
143143
summary: Summary,
144144
}
145145

146146
/// A `RollingSummary` manages a list of [Summary] so that old results can be expired.
147-
#[derive(Clone)]
147+
#[derive(Clone, Debug)]
148148
pub struct RollingSummary {
149149
// Buckets are ordered with the latest buckets first. The buckets are kept in alignment based
150150
// on the instant of the first added bucket and the bucket_duration. There may be gaps in the

metrics-exporter-prometheus/src/exporter/builder.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ use super::ExporterConfig;
3333
use super::ExporterFuture;
3434

3535
/// Builder for creating and installing a Prometheus recorder/exporter.
36+
#[derive(Debug)]
3637
pub struct PrometheusBuilder {
3738
#[cfg_attr(not(any(feature = "http-listener", feature = "push-gateway")), allow(dead_code))]
3839
exporter_config: ExporterConfig,

metrics-exporter-prometheus/src/exporter/http_listener.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ enum ListenerType {
3232
}
3333

3434
/// Error type for HTTP listening.
35+
#[derive(Debug)]
3536
pub enum HttpListeningError {
3637
Hyper(hyper::Error),
3738
Io(std::io::Error),

metrics-exporter-prometheus/src/exporter/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use hyper::Uri;
1414

1515
/// Error types possible from an exporter
1616
#[cfg(any(feature = "http-listener", feature = "push-gateway"))]
17+
#[derive(Debug)]
1718
pub enum ExporterError {
1819
#[cfg(feature = "http-listener")]
1920
HttpListener(HttpListeningError),
@@ -24,14 +25,14 @@ pub enum ExporterError {
2425
pub type ExporterFuture = Pin<Box<dyn Future<Output = Result<(), ExporterError>> + Send + 'static>>;
2526

2627
#[cfg(feature = "http-listener")]
27-
#[derive(Clone)]
28+
#[derive(Clone, Debug)]
2829
enum ListenDestination {
2930
Tcp(SocketAddr),
3031
#[cfg(feature = "uds-listener")]
3132
Uds(std::path::PathBuf),
3233
}
3334

34-
#[derive(Clone)]
35+
#[derive(Clone, Debug)]
3536
enum ExporterConfig {
3637
// Run an HTTP listener on the given `listen_address`.
3738
#[cfg(feature = "http-listener")]

metrics-exporter-prometheus/src/recorder.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use crate::formatting::{
1515
};
1616
use crate::registry::GenerationalAtomicStorage;
1717

18+
#[derive(Debug)]
1819
pub(crate) struct Inner {
1920
pub registry: Registry<Key, GenerationalAtomicStorage>,
2021
pub recency: Recency<Key>,
@@ -214,6 +215,7 @@ impl Inner {
214215
/// Most users will not need to interact directly with the recorder, and can simply deal with the
215216
/// builder methods on [`PrometheusBuilder`](crate::PrometheusBuilder) for building and installing
216217
/// the recorder/exporter.
218+
#[derive(Debug)]
217219
pub struct PrometheusRecorder {
218220
inner: Arc<Inner>,
219221
}
@@ -275,7 +277,7 @@ impl Recorder for PrometheusRecorder {
275277
/// handled directly by the HTTP listener, or push gateway background task. [`PrometheusHandle`]
276278
/// allows rendering a snapshot of the current metrics stored by an installed [`PrometheusRecorder`]
277279
/// as a payload conforming to the Prometheus exposition format.
278-
#[derive(Clone)]
280+
#[derive(Clone, Debug)]
279281
pub struct PrometheusHandle {
280282
inner: Arc<Inner>,
281283
}

metrics-exporter-prometheus/src/registry.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use quanta::Instant;
77
pub type GenerationalAtomicStorage = GenerationalStorage<AtomicStorage>;
88

99
/// Atomic metric storage for the prometheus exporter.
10+
#[derive(Debug)]
1011
pub struct AtomicStorage;
1112

1213
impl<K> metrics_util::registry::Storage<K> for AtomicStorage {
@@ -28,6 +29,7 @@ impl<K> metrics_util::registry::Storage<K> for AtomicStorage {
2829
}
2930

3031
/// An `AtomicBucket` newtype wrapper that tracks the time of value insertion.
32+
#[derive(Debug)]
3133
pub struct AtomicBucketInstant<T> {
3234
inner: AtomicBucket<(T, Instant)>,
3335
}

metrics-exporter-tcp/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ impl std::error::Error for Error {
137137
}
138138
}
139139

140+
#[derive(Debug)]
140141
struct State {
141142
client_count: AtomicUsize,
142143
should_send: AtomicBool,
@@ -188,6 +189,7 @@ impl State {
188189
}
189190
}
190191

192+
#[derive(Debug)]
191193
struct Handle {
192194
key: Key,
193195
state: Arc<State>,
@@ -230,11 +232,13 @@ impl HistogramFn for Handle {
230232
}
231233

232234
/// A TCP recorder.
235+
#[derive(Debug)]
233236
pub struct TcpRecorder {
234237
state: Arc<State>,
235238
}
236239

237240
/// Builder for creating and installing a TCP recorder/exporter.
241+
#[derive(Debug)]
238242
pub struct TcpBuilder {
239243
listen_addr: SocketAddr,
240244
buffer_size: Option<usize>,

metrics-tracing-context/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ use tracing_integration::Map;
114114
pub use tracing_integration::{Labels, MetricsLayer};
115115

116116
/// [`TracingContextLayer`] provides an implementation of a [`Layer`] for [`TracingContext`].
117+
#[derive(Debug)]
117118
pub struct TracingContextLayer<F> {
118119
label_filter: F,
119120
}
@@ -156,6 +157,7 @@ where
156157
}
157158

158159
/// [`TracingContext`] is a [`metrics::Recorder`] that injects labels from [`tracing::Span`]s.
160+
#[derive(Debug)]
159161
pub struct TracingContext<R, F> {
160162
inner: R,
161163
label_filter: F,

metrics-tracing-context/tests/integration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ fn test_nested_spans() {
522522
);
523523
}
524524

525-
#[derive(Clone)]
525+
#[derive(Clone, Debug)]
526526
struct OnlyUser;
527527

528528
impl LabelFilter for OnlyUser {

0 commit comments

Comments
 (0)