Skip to content
Merged
Show file tree
Hide file tree
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
45 changes: 43 additions & 2 deletions src/service/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,48 @@ pub fn fetch_request_pages(kind: &ObjectKind, pages: u16) {
.observe(f64::from(pages));
}

pub fn page_request_count(kind: &ObjectKind, typ: &str) {
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum PageRequestType {
/// Total page requests observed by the service.
Access,
/// Page requests that fetched bytes from object storage.
Download,
/// Object storage fetches where a hedged request was issued.
Hedged,
/// Fetches whose primary attempt used the client-preferred bucket.
ClientPref,
/// Fetches that succeeded via a fallback bucket after the primary path failed.
Fallback,
/// Page requests that completed successfully, regardless of hit/miss path.
Success,
/// Aggregate cache-hit count (includes both memory and disk hits).
CacheHit,
/// Cache hits served from in-memory cache.
CacheHitMemory,
/// Cache hits served from disk cache.
CacheHitDisk,
/// Requests that waited on another in-flight miss for the same page instead of downloading.
Coalesced,
}

impl PageRequestType {
const fn as_label(self) -> &'static str {
match self {
Self::Access => "access",
Self::Download => "download",
Self::Hedged => "hedged",
Self::ClientPref => "client_pref",
Self::Fallback => "fallback",
Self::Success => "success",
Self::CacheHit => "cache_hit",
Self::CacheHitMemory => "cache_hit_memory",
Self::CacheHitDisk => "cache_hit_disk",
Self::Coalesced => "coalesced",
}
}
}

pub fn page_request_count(kind: &ObjectKind, typ: PageRequestType) {
static COUNTER: LazyLock<IntCounterVec> = LazyLock::new(|| {
register_int_counter_vec!(
"cachey_page_request_total",
Expand All @@ -139,7 +180,7 @@ pub fn page_request_count(kind: &ObjectKind, typ: &str) {
.unwrap()
});

COUNTER.with_label_values(&[&**kind, typ]).inc();
COUNTER.with_label_values(&[&**kind, typ.as_label()]).inc();
}

pub fn page_download_latency(kind: &ObjectKind, latency: std::time::Duration) {
Expand Down
Loading