From 251db8515b37de5062f842df3da09f9a8425b80b Mon Sep 17 00:00:00 2001 From: Anna Khanova Date: Tue, 5 Mar 2024 13:59:22 +0100 Subject: [PATCH] Report redis broken message metric --- proxy/src/metrics.rs | 9 +++++++++ proxy/src/redis/notifications.rs | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/proxy/src/metrics.rs b/proxy/src/metrics.rs index 66031f5eb2f8..2464b1e611c0 100644 --- a/proxy/src/metrics.rs +++ b/proxy/src/metrics.rs @@ -303,3 +303,12 @@ pub static ENDPOINT_ERRORS_BY_KIND: Lazy> = Lazy::new(|| { ) .unwrap() }); + +pub static REDIS_BROKEN_MESSAGES: Lazy = Lazy::new(|| { + register_int_counter_vec!( + "proxy_redis_errors_total", + "Number of errors by a given classification", + &["channel"], + ) + .unwrap() +}); diff --git a/proxy/src/redis/notifications.rs b/proxy/src/redis/notifications.rs index b8297a206c54..6ae848c0d2c7 100644 --- a/proxy/src/redis/notifications.rs +++ b/proxy/src/redis/notifications.rs @@ -10,6 +10,7 @@ use crate::{ cache::project_info::ProjectInfoCache, cancellation::{CancelMap, CancellationHandler, NotificationsCancellationHandler}, intern::{ProjectIdInt, RoleNameInt}, + metrics::REDIS_BROKEN_MESSAGES, }; const CPLANE_CHANNEL_NAME: &str = "neondb-proxy-ws-updates"; @@ -115,6 +116,9 @@ impl< let msg: Notification = match serde_json::from_str(&payload) { Ok(msg) => msg, Err(e) => { + REDIS_BROKEN_MESSAGES + .with_label_values(&[msg.get_channel_name()]) + .inc(); tracing::error!("broken message: {e}"); return Ok(()); }