mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 07:41:23 +01:00
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::{response::IntoResponse, Json};
|
||||||
use axum_extra::headers::{Authorization, HeaderMapExt};
|
use axum_extra::headers::{Authorization, HeaderMapExt};
|
||||||
use get_profile_information::v1::ProfileField;
|
use get_profile_information::v1::ProfileField;
|
||||||
|
use opentelemetry::KeyValue;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::{
|
api::{
|
||||||
client::error::{Error as RumaError, ErrorKind},
|
client::error::{Error as RumaError, ErrorKind},
|
||||||
|
|
@ -703,6 +704,10 @@ pub(crate) async fn send_transaction_message_route(
|
||||||
let sender_servername =
|
let sender_servername =
|
||||||
body.sender_servername.as_ref().expect("server is authenticated");
|
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 mut resolved_map = BTreeMap::new();
|
||||||
|
|
||||||
let pub_key_map = RwLock::new(BTreeMap::new());
|
let pub_key_map = RwLock::new(BTreeMap::new());
|
||||||
|
|
|
||||||
|
|
@ -155,6 +155,9 @@ pub(crate) struct Metrics {
|
||||||
|
|
||||||
/// Counts where data is found from
|
/// Counts where data is found from
|
||||||
lookup: opentelemetry::metrics::Counter<u64>,
|
lookup: opentelemetry::metrics::Counter<u64>,
|
||||||
|
|
||||||
|
/// Counts incoming federation requests by origin
|
||||||
|
pub(crate) federation_requests: opentelemetry::metrics::Counter<u64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Metrics {
|
impl Metrics {
|
||||||
|
|
@ -205,10 +208,16 @@ impl Metrics {
|
||||||
.with_description("Counts where data is found from")
|
.with_description("Counts where data is found from")
|
||||||
.init();
|
.init();
|
||||||
|
|
||||||
|
let federation_requests = meter
|
||||||
|
.u64_counter("federation_requests")
|
||||||
|
.with_description("Counts incoming federation requests by origin")
|
||||||
|
.init();
|
||||||
|
|
||||||
Metrics {
|
Metrics {
|
||||||
otel_state: (registry, provider),
|
otel_state: (registry, provider),
|
||||||
http_requests_histogram,
|
http_requests_histogram,
|
||||||
lookup,
|
lookup,
|
||||||
|
federation_requests,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue