Add metric for updates denied by filters

Signed-off-by: Lee Smet <lee.smet@hotmail.com>
This commit is contained in:
Lee Smet
2024-07-12 15:22:22 +02:00
parent ca4792f247
commit 30dcc7f3d3
3 changed files with 16 additions and 0 deletions

View File

@@ -28,6 +28,7 @@ pub struct PrometheusExporter {
router_tlv_source_died: IntCounter,
router_propage_selected_peers_time_spent: IntCounter,
router_update_skipped_route_selection: IntCounter,
router_update_denied_by_filter: IntCounter,
peer_manager_peer_added: IntCounterVec,
peer_manager_known_peers: IntGauge,
peer_manager_connection_attemps: IntCounterVec,
@@ -131,6 +132,11 @@ impl PrometheusExporter {
"Updates which were processed but did not run the route selection step, because the updated route could not be selected anyway",
)
.expect("Can register an int counter in default registry"),
router_update_denied_by_filter: register_int_counter!(
"mycelium_router_update_denied",
"Updates which were received and immediately denied by a configured filter",
)
.expect("Can register an int counter in default registry"),
peer_manager_peer_added: register_int_counter_vec!(
opts!(
"mycelium_peer_manager_peers_added",
@@ -374,6 +380,11 @@ impl Metrics for PrometheusExporter {
self.router_update_skipped_route_selection.inc()
}
#[inline]
fn router_update_denied_by_filter(&self) {
self.router_update_denied_by_filter.inc()
}
#[inline]
fn peer_manager_peer_added(&self, pt: mycelium::peer_manager::PeerType) {
let label = match pt {

View File

@@ -159,6 +159,10 @@ pub trait Metrics {
#[inline]
fn router_update_skipped_route_selection(&self) {}
/// An update was denied by a configured filter.
#[inline]
fn router_update_denied_by_filter(&self) {}
/// A new [`Peer`](crate::peer::Peer) was added to the
/// [`PeerManager`](crate::peer_manager::PeerManager) while it is running.
#[inline]

View File

@@ -948,6 +948,7 @@ where
for filter in &*self.update_filters {
if !filter.allow(&update) {
debug!("Update denied by filter");
self.metrics.router_update_denied_by_filter();
return;
}
}