pub mod name {
pub const CLIENT_CACHE_BYTES_READ_CACHE: &str = "Client.CacheBytesReadCache";
pub const CLIENT_CACHE_BYTES_READ_IN_STREAM_BUFFER: &str =
"Client.CacheBytesReadInStreamBuffer";
pub const CLIENT_CACHE_BYTES_READ_EXTERNAL: &str = "Client.CacheBytesReadExternal";
pub const CLIENT_CACHE_BYTES_REQUESTED_EXTERNAL: &str = "Client.CacheBytesRequestedExternal";
pub const CLIENT_CACHE_BYTES_WRITTEN_CACHE: &str = "Client.CacheBytesWrittenCache";
pub const CLIENT_CACHE_PAGE_READ_CACHE_TIME_NS: &str = "Client.CachePageReadCacheTimeNanos";
pub const CLIENT_CACHE_PAGE_READ_EXTERNAL_TIME_NS: &str =
"Client.CachePageReadExternalTimeNanos";
pub const CLIENT_CACHE_PAGES: &str = "Client.CachePages";
pub const CLIENT_CACHE_SPACE_AVAILABLE: &str = "Client.CacheSpaceAvailable";
pub const CLIENT_CACHE_SPACE_USED: &str = "Client.CacheSpaceUsed";
pub const CLIENT_CACHE_SPACE_USED_COUNT: &str = "Client.CacheSpaceUsedCount";
pub const CLIENT_CACHE_HIT_RATE: &str = "Client.CacheHitRate";
pub const CLIENT_CACHE_BYTES_EVICTED: &str = "Client.CacheBytesEvicted";
pub const CLIENT_CACHE_PAGES_EVICTED: &str = "Client.CachePagesEvicted";
pub const CLIENT_CACHE_BYTES_DISCARDED: &str = "Client.CacheBytesDiscarded";
pub const CLIENT_CACHE_PAGES_DISCARDED: &str = "Client.CachePagesDiscarded";
pub const CLIENT_CACHE_STATE: &str = "Client.CacheState";
pub const CLIENT_CACHE_CLEAN_ERRORS: &str = "Client.CacheCleanErrors";
pub const CLIENT_CACHE_CLEANUP_GET_ERRORS: &str = "Client.CacheCleanupGetErrors";
pub const CLIENT_CACHE_CLEANUP_PUT_ERRORS: &str = "Client.CacheCleanupPutErrors";
pub const CLIENT_CACHE_CREATE_ERRORS: &str = "Client.CacheCreateErrors";
pub const CLIENT_CACHE_DELETE_ERRORS: &str = "Client.CacheDeleteErrors";
pub const CLIENT_CACHE_DELETE_NON_EXISTING_PAGE_ERRORS: &str =
"Client.CacheDeleteNonExistingPageErrors";
pub const CLIENT_CACHE_DELETE_NOT_READY_ERRORS: &str = "Client.CacheDeleteNotReadyErrors";
pub const CLIENT_CACHE_DELETE_FROM_STORE_ERRORS: &str = "Client.CacheDeleteFromStoreErrors";
pub const CLIENT_CACHE_DELETE_STORE_DELETE_ERRORS: &str = "Client.CacheDeleteStoreDeleteErrors";
pub const CLIENT_CACHE_GET_ERRORS: &str = "Client.CacheGetErrors";
pub const CLIENT_CACHE_GET_NOT_READY_ERRORS: &str = "Client.CacheGetNotReadyErrors";
pub const CLIENT_CACHE_GET_STORE_READ_ERRORS: &str = "Client.CacheGetStoreReadErrors";
pub const CLIENT_CACHE_PUT_ERRORS: &str = "Client.CachePutErrors";
pub const CLIENT_CACHE_PUT_ASYNC_REJECTION_ERRORS: &str = "Client.CachePutAsyncRejectionErrors";
pub const CLIENT_CACHE_PUT_EVICTION_ERRORS: &str = "Client.CachePutEvictionErrors";
pub const CLIENT_CACHE_PUT_BENIGN_RACING_ERRORS: &str = "Client.CachePutBenignRacingErrors";
pub const CLIENT_CACHE_PUT_INSUFFICIENT_SPACE_ERRORS: &str =
"Client.CachePutInsufficientSpaceErrors";
pub const CLIENT_CACHE_PUT_NOT_READY_ERRORS: &str = "Client.CachePutNotReadyErrors";
pub const CLIENT_CACHE_PUT_STORE_DELETE_ERRORS: &str = "Client.CachePutStoreDeleteErrors";
pub const CLIENT_CACHE_PUT_STORE_WRITE_ERRORS: &str = "Client.CachePutStoreWriteErrors";
pub const CLIENT_CACHE_PUT_STORE_WRITE_NO_SPACE_ERRORS: &str =
"Client.CachePutStoreWriteNoSpaceErrors";
pub const CLIENT_CACHE_STORE_DELETE_TIMEOUT: &str = "Client.CacheStoreDeleteTimeout";
pub const CLIENT_CACHE_STORE_GET_TIMEOUT: &str = "Client.CacheStoreGetTimeout";
pub const CLIENT_CACHE_STORE_PUT_TIMEOUT: &str = "Client.CacheStorePutTimeout";
pub const CLIENT_CACHE_STORE_THREADS_REJECTED: &str = "Client.CacheStoreThreadsRejected";
pub const CLIENT_CACHE_URING_BACKEND_ACTIVE: &str = "Client.CacheUringBackendActive";
pub const CLIENT_CACHE_URING_QUEUE_DEPTH: &str = "Client.CacheUringQueueDepth";
pub const CLIENT_CACHE_URING_THREAD_COUNT: &str = "Client.CacheUringThreadCount";
pub const CLIENT_CACHE_URING_SUBMITTED_TOTAL: &str = "Client.CacheUringSubmittedTotal";
pub const CLIENT_CACHE_URING_COMPLETED_TOTAL: &str = "Client.CacheUringCompletedTotal";
pub const CLIENT_CACHE_URING_ERRORS_TOTAL: &str = "Client.CacheUringErrorsTotal";
pub const CLIENT_CACHE_URING_IN_FLIGHT: &str = "Client.CacheUringInFlight";
}
use crate::metrics::{counter, gauge};
pub fn publish_hit_rate() {
let hit = counter(name::CLIENT_CACHE_BYTES_READ_CACHE).get();
let ext = counter(name::CLIENT_CACHE_BYTES_READ_EXTERNAL).get();
let total = hit + ext;
let rate = if total > 0 {
hit.saturating_mul(100) / total
} else {
0
};
gauge(name::CLIENT_CACHE_HIT_RATE).set(rate);
}