Fix active streams metric
Publish Server Image / build-and-push-image (push) Successful in 4m50s

This commit is contained in:
Ultradesu
2026-03-11 01:39:29 +00:00
parent 848d1643a5
commit dc77933c9e
3 changed files with 21 additions and 5 deletions
+18
View File
@@ -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();