mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-20 09:11:24 +01:00
metrics for online and offline remote server count
This commit is contained in:
parent
5b6aaa19b9
commit
56f025cb47
2 changed files with 92 additions and 7 deletions
|
|
@ -290,6 +290,9 @@ pub(crate) struct Metrics {
|
|||
/// Number of entries in an
|
||||
/// [`OnDemandHashMap`](crate::utils::on_demand_hashmap::OnDemandHashMap)
|
||||
on_demand_hashmap_size: opentelemetry::metrics::Gauge<u64>,
|
||||
|
||||
/// Number of known remote servers in each state (online or offline)
|
||||
remote_server_count: opentelemetry::metrics::Gauge<u64>,
|
||||
}
|
||||
|
||||
impl Metrics {
|
||||
|
|
@ -345,11 +348,17 @@ impl Metrics {
|
|||
.with_description("Number of entries in OnDemandHashMap")
|
||||
.init();
|
||||
|
||||
let remote_server_count = meter
|
||||
.u64_gauge("remote_server_count")
|
||||
.with_description("Number of known remote servers")
|
||||
.init();
|
||||
|
||||
Metrics {
|
||||
otel_state: (registry, provider),
|
||||
http_requests_histogram,
|
||||
lookup,
|
||||
on_demand_hashmap_size,
|
||||
remote_server_count,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -384,6 +393,18 @@ impl Metrics {
|
|||
&[KeyValue::new("name", name)],
|
||||
);
|
||||
}
|
||||
|
||||
/// Record number of remote servers marked online or offline.
|
||||
pub(crate) fn record_remote_server_count(
|
||||
&self,
|
||||
online_count: u64,
|
||||
offline_count: u64,
|
||||
) {
|
||||
self.remote_server_count
|
||||
.record(online_count, &[KeyValue::new("state", "online")]);
|
||||
self.remote_server_count
|
||||
.record(offline_count, &[KeyValue::new("state", "offline")]);
|
||||
}
|
||||
}
|
||||
|
||||
/// Track HTTP metrics by converting this into an [`axum`] layer
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue