mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 07:41:23 +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
9364d44ce2
commit
0c2094a56f
8 changed files with 142 additions and 68 deletions
|
|
@ -10,7 +10,10 @@ use lru_cache::LruCache;
|
|||
use ruma::{EventId, RoomId};
|
||||
|
||||
use self::data::StateDiff;
|
||||
use crate::{observability::FoundIn, services, utils, Result};
|
||||
use crate::{
|
||||
observability::{FoundIn, Lookup, METRICS},
|
||||
services, utils, Result,
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub(crate) struct CompressedStateLayer {
|
||||
|
|
@ -33,15 +36,17 @@ impl Service {
|
|||
/// Returns a stack with info on shortstatehash, full state, added diff and
|
||||
/// removed diff for the selected shortstatehash and each parent layer.
|
||||
#[allow(clippy::type_complexity)]
|
||||
#[tracing::instrument(skip(self), fields(cache_result))]
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub(crate) fn load_shortstatehash_info(
|
||||
&self,
|
||||
shortstatehash: u64,
|
||||
) -> Result<Vec<CompressedStateLayer>> {
|
||||
let lookup = Lookup::StateInfo;
|
||||
|
||||
if let Some(r) =
|
||||
self.stateinfo_cache.lock().unwrap().get_mut(&shortstatehash)
|
||||
{
|
||||
FoundIn::Cache.record("cache_result");
|
||||
METRICS.record_lookup(lookup, FoundIn::Cache);
|
||||
return Ok(r.clone());
|
||||
}
|
||||
|
||||
|
|
@ -76,7 +81,7 @@ impl Service {
|
|||
}]
|
||||
};
|
||||
|
||||
FoundIn::Database.record("cache_result");
|
||||
METRICS.record_lookup(lookup, FoundIn::Database);
|
||||
self.stateinfo_cache
|
||||
.lock()
|
||||
.unwrap()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue