1
0
Fork 0
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:
Charles Hall 2024-06-05 07:18:31 -07:00
parent 2da85c96fc
commit 509a25b9ba
No known key found for this signature in database
GPG key ID: 7B8E0645816E07CF
2 changed files with 14 additions and 0 deletions

View file

@ -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());

View file

@ -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,
}
}