Skip to main content

feldera_adapterlib/
metrics.rs

1/// The type of a connector metric.
2#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
3pub enum ValueType {
4    /// A monotonically increasing counter.
5    Counter,
6    /// An instantaneous gauge.
7    Gauge,
8}
9
10impl ValueType {
11    pub fn as_str(&self) -> &'static str {
12        match self {
13            ValueType::Counter => "counter",
14            ValueType::Gauge => "gauge",
15        }
16    }
17}
18
19/// Connector-specific metrics exported via the Prometheus `/metrics` endpoint.
20///
21/// Connectors that have metrics beyond the standard `InputEndpointMetrics`
22/// should implement this trait and register themselves via
23/// `InputConsumer::set_custom_metrics` during `TransportInputEndpoint::open`.
24pub trait ConnectorMetrics: Send + Sync {
25    /// Return a list of `(name, help, value_type, value)` tuples.
26    ///
27    /// The returned `name`s must be valid Prometheus metric name components
28    /// (no spaces, no special characters other than `_`).
29    fn metrics(&self) -> Vec<(&'static str, &'static str, ValueType, f64)>;
30}