Coverage Report

Created: 2025-12-28 06:31

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/prometheus-client-0.24.0/src/metrics.rs
Line
Count
Source
1
//! Metric type implementations.
2
3
pub mod counter;
4
pub mod exemplar;
5
pub mod family;
6
pub mod gauge;
7
pub mod histogram;
8
pub mod info;
9
10
/// A metric that is aware of its Open Metrics metric type.
11
pub trait TypedMetric {
12
    /// The OpenMetrics metric type.
13
    const TYPE: MetricType = MetricType::Unknown;
14
}
15
16
/// OpenMetrics metric type.
17
#[derive(Clone, Copy, Debug)]
18
#[allow(missing_docs)]
19
pub enum MetricType {
20
    Counter,
21
    Gauge,
22
    Histogram,
23
    Info,
24
    Unknown,
25
    // Not (yet) supported metric types.
26
    //
27
    // GaugeHistogram,
28
    // StateSet,
29
    // Summary
30
}
31
32
impl MetricType {
33
    /// Returns the given metric type's str representation.
34
0
    pub fn as_str(&self) -> &str {
35
0
        match self {
36
0
            MetricType::Counter => "counter",
37
0
            MetricType::Gauge => "gauge",
38
0
            MetricType::Histogram => "histogram",
39
0
            MetricType::Info => "info",
40
0
            MetricType::Unknown => "unknown",
41
        }
42
0
    }
43
}