forked from mirror/grapevine
count federation requests by server name
This resuls in very high cardinality, so probably not something to run for a long period of time.
This commit is contained in:
parent
2da85c96fc
commit
509a25b9ba
2 changed files with 14 additions and 0 deletions
|
@ -12,6 +12,7 @@ use std::{
|
|||
use axum::{response::IntoResponse, Json};
|
||||
use axum_extra::headers::{Authorization, HeaderMapExt};
|
||||
use get_profile_information::v1::ProfileField;
|
||||
use opentelemetry::KeyValue;
|
||||
use ruma::{
|
||||
api::{
|
||||
client::error::{Error as RumaError, ErrorKind},
|
||||
|
@ -703,6 +704,10 @@ pub(crate) async fn send_transaction_message_route(
|
|||
let sender_servername =
|
||||
body.sender_servername.as_ref().expect("server is authenticated");
|
||||
|
||||
METRICS
|
||||
.federation_requests
|
||||
.add(1, &[KeyValue::new("server_name", sender_servername.to_string())]);
|
||||
|
||||
let mut resolved_map = BTreeMap::new();
|
||||
|
||||
let pub_key_map = RwLock::new(BTreeMap::new());
|
||||
|
|
|
@ -155,6 +155,9 @@ pub(crate) struct Metrics {
|
|||
|
||||
/// Counts where data is found from
|
||||
lookup: opentelemetry::metrics::Counter<u64>,
|
||||
|
||||
/// Counts incoming federation requests by origin
|
||||
pub(crate) federation_requests: opentelemetry::metrics::Counter<u64>,
|
||||
}
|
||||
|
||||
impl Metrics {
|
||||
|
@ -205,10 +208,16 @@ impl Metrics {
|
|||
.with_description("Counts where data is found from")
|
||||
.init();
|
||||
|
||||
let federation_requests = meter
|
||||
.u64_counter("federation_requests")
|
||||
.with_description("Counts incoming federation requests by origin")
|
||||
.init();
|
||||
|
||||
Metrics {
|
||||
otel_state: (registry, provider),
|
||||
http_requests_histogram,
|
||||
lookup,
|
||||
federation_requests,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue