This commit is contained in:
@@ -100,6 +100,24 @@ impl RequestTimer {
|
||||
}
|
||||
}
|
||||
|
||||
/// An RAII guard that increments the ACTIVE_STREAMS gauge when created
|
||||
/// and decrements it when dropped. This ensures streams are correctly counted
|
||||
/// even if they terminate abruptly.
|
||||
pub struct ActiveStreamGuard;
|
||||
|
||||
impl ActiveStreamGuard {
|
||||
pub fn new() -> Self {
|
||||
ACTIVE_STREAMS.inc();
|
||||
Self
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for ActiveStreamGuard {
|
||||
fn drop(&mut self) {
|
||||
ACTIVE_STREAMS.dec();
|
||||
}
|
||||
}
|
||||
|
||||
/// Render all registered metrics in Prometheus text format.
|
||||
pub fn render_metrics() -> String {
|
||||
let encoder = TextEncoder::new();
|
||||
|
||||
Reference in New Issue
Block a user