Skip to content

Commit

Permalink
feat: add timer metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
evenyag committed Aug 28, 2024
1 parent e10b732 commit 4618f57
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/mito2/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ use crate::cache::cache_size::parquet_meta_size;
use crate::cache::file_cache::{FileType, IndexKey};
use crate::cache::index::{InvertedIndexCache, InvertedIndexCacheRef};
use crate::cache::write_cache::WriteCacheRef;
use crate::metrics::{CACHE_BYTES, CACHE_EVICTION, CACHE_HIT, CACHE_MISS};
use crate::metrics::{
CACHE_BYTES, CACHE_EVICTION, CACHE_HIT, CACHE_MISS, GET_CACHE_ELAPSED, PUT_CACHE_ELAPSED,
};
use crate::read::Batch;
use crate::sst::file::FileId;

Expand Down Expand Up @@ -158,6 +160,7 @@ impl CacheManager {

/// Gets pages for the row group.
pub fn get_pages(&self, page_key: &PageKey) -> Option<Arc<PageValue>> {
let _timer = GET_CACHE_ELAPSED.start_timer();
self.page_cache.as_ref().and_then(|page_cache| {
let value = page_cache.get(page_key);
update_hit_miss(value, PAGE_TYPE)
Expand All @@ -166,6 +169,7 @@ impl CacheManager {

/// Puts pages of the row group into the cache.
pub fn put_pages(&self, page_key: PageKey, pages: Arc<PageValue>) {
let _timer = PUT_CACHE_ELAPSED.start_timer();
if let Some(cache) = &self.page_cache {
CACHE_BYTES
.with_label_values(&[PAGE_TYPE])
Expand Down
2 changes: 2 additions & 0 deletions src/mito2/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ lazy_static! {
vec![0.005, 0.01, 0.05, 0.1, 0.5, 1.0, 5.0, 10.0, 60.0, 300.0]
)
.unwrap();
pub static ref GET_CACHE_ELAPSED: Histogram = READ_STAGE_ELAPSED.with_label_values(&["get_cache"]);
pub static ref PUT_CACHE_ELAPSED: Histogram = READ_STAGE_ELAPSED.with_label_values(&["put_cache"]);
/// Counter of rows read from different source.
pub static ref READ_ROWS_TOTAL: IntCounterVec =
register_int_counter_vec!("greptime_mito_read_rows_total", "mito read rows total", &[TYPE_LABEL]).unwrap();
Expand Down

0 comments on commit 4618f57

Please sign in to comment.