mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-18 16:21:24 +01:00
record FoundIn with metrics instead of traces
This is much more efficient in terms of network use and data storage, and also easier to visualize.
This commit is contained in:
parent
7076c13058
commit
72860d98db
8 changed files with 139 additions and 67 deletions
|
|
@ -8,7 +8,7 @@ use ruma::{
|
|||
|
||||
use crate::{
|
||||
database::KeyValueDatabase,
|
||||
observability::FoundIn,
|
||||
observability::{FoundIn, FoundKind, METRICS},
|
||||
service::{self, appservice::RegistrationInfo},
|
||||
services, utils, Error, Result,
|
||||
};
|
||||
|
|
@ -171,19 +171,21 @@ impl service::rooms::state_cache::Data for KeyValueDatabase {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self), fields(cache_result))]
|
||||
#[tracing::instrument(skip(self))]
|
||||
fn get_our_real_users(
|
||||
&self,
|
||||
room_id: &RoomId,
|
||||
) -> Result<Arc<HashSet<OwnedUserId>>> {
|
||||
let found_kind = FoundKind::OurRealUsers;
|
||||
|
||||
let maybe =
|
||||
self.our_real_users_cache.read().unwrap().get(room_id).cloned();
|
||||
if let Some(users) = maybe {
|
||||
FoundIn::Cache.record("cache_result");
|
||||
METRICS.record_lookup(found_kind, FoundIn::Cache);
|
||||
Ok(users)
|
||||
} else {
|
||||
self.update_joined_count(room_id)?;
|
||||
FoundIn::Database.record("cache_result");
|
||||
METRICS.record_lookup(found_kind, FoundIn::Database);
|
||||
Ok(Arc::clone(
|
||||
self.our_real_users_cache.read().unwrap().get(room_id).unwrap(),
|
||||
))
|
||||
|
|
@ -192,13 +194,15 @@ impl service::rooms::state_cache::Data for KeyValueDatabase {
|
|||
|
||||
#[tracing::instrument(
|
||||
skip(self, appservice),
|
||||
fields(cache_result, appservice_id = appservice.registration.id),
|
||||
fields(appservice_id = appservice.registration.id),
|
||||
)]
|
||||
fn appservice_in_room(
|
||||
&self,
|
||||
room_id: &RoomId,
|
||||
appservice: &RegistrationInfo,
|
||||
) -> Result<bool> {
|
||||
let found_kind = FoundKind::AppserviceInRoom;
|
||||
|
||||
let maybe = self
|
||||
.appservice_in_room_cache
|
||||
.read()
|
||||
|
|
@ -208,7 +212,7 @@ impl service::rooms::state_cache::Data for KeyValueDatabase {
|
|||
.copied();
|
||||
|
||||
if let Some(b) = maybe {
|
||||
FoundIn::Cache.record("cache_result");
|
||||
METRICS.record_lookup(found_kind, FoundIn::Cache);
|
||||
Ok(b)
|
||||
} else {
|
||||
let bridge_user_id = UserId::parse_with_server_name(
|
||||
|
|
@ -225,7 +229,7 @@ impl service::rooms::state_cache::Data for KeyValueDatabase {
|
|||
})
|
||||
});
|
||||
|
||||
FoundIn::Database.record("cache_result");
|
||||
METRICS.record_lookup(found_kind, FoundIn::Database);
|
||||
self.appservice_in_room_cache
|
||||
.write()
|
||||
.unwrap()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue