Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions common/src/db/pagination_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use actix_web::{HttpResponse, ResponseError, body::BoxBody};
use moka::future::Cache;
use opentelemetry::{global, metrics::Counter};
use std::{sync::Arc, time::Duration};
use tracing::instrument;

use crate::error::ErrorInformation;

Expand Down Expand Up @@ -57,6 +58,7 @@ impl PaginationCache {
}

/// Return a cached total count, computing it at most once for concurrent requests with the same key.
#[instrument(skip(self, compute), fields(cache_hit = true))]
pub async fn cached_total(
&self,
key: String,
Expand All @@ -67,6 +69,7 @@ impl PaginationCache {
self.cache
.try_get_with(key, async {
misses.add(1, &[]);
tracing::Span::current().record("cache_hit", false);
compute().await
})
.await
Expand Down
Loading