Skip to content

Commit

Permalink
export more metrics
Browse files Browse the repository at this point in the history
Signed-off-by: MrCroxx <[email protected]>
  • Loading branch information
MrCroxx committed Oct 11, 2023
1 parent 86ade2e commit 3a94f45
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion src/storage/src/hummock/event_handler/refiller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub static GLOBAL_CACHE_REFILL_METRICS: LazyLock<CacheRefillMetrics> =
pub struct CacheRefillMetrics {
pub refill_duration: HistogramVec,
pub refill_total: GenericCounterVec<AtomicU64>,
pub refill_bytes: GenericCounterVec<AtomicU64>,

pub data_refill_success_duration: Histogram,
pub meta_refill_success_duration: Histogram,
Expand All @@ -56,6 +57,9 @@ pub struct CacheRefillMetrics {
pub data_refill_started_total: GenericCounter<AtomicU64>,
pub meta_refill_attempts_total: GenericCounter<AtomicU64>,

pub data_refill_ideal_bytes: GenericCounter<AtomicU64>,
pub data_refill_success_bytes: GenericCounter<AtomicU64>,

pub refill_queue_total: IntGauge,
}

Expand All @@ -75,6 +79,13 @@ impl CacheRefillMetrics {
registry,
)
.unwrap();
let refill_bytes = register_int_counter_vec_with_registry!(
"refill_bytes",
"refill bytes",
&["type", "op"],
registry,
)
.unwrap();

let data_refill_success_duration = refill_duration
.get_metric_with_label_values(&["data", "success"])
Expand All @@ -96,6 +107,13 @@ impl CacheRefillMetrics {
.get_metric_with_label_values(&["meta", "attempts"])
.unwrap();

let data_refill_ideal_bytes = refill_bytes
.get_metric_with_label_values(&["data", "ideal"])
.unwrap();
let data_refill_success_bytes = refill_bytes
.get_metric_with_label_values(&["data", "success"])
.unwrap();

let refill_queue_total = register_int_gauge_with_registry!(
"refill_queue_total",
"refill queue total",
Expand All @@ -106,13 +124,18 @@ impl CacheRefillMetrics {
Self {
refill_duration,
refill_total,
refill_bytes,

data_refill_success_duration,
meta_refill_success_duration,
data_refill_filtered_total,
data_refill_attempts_total,
data_refill_started_total,
meta_refill_attempts_total,

data_refill_ideal_bytes,
data_refill_success_bytes,

refill_queue_total,
}
}
Expand Down Expand Up @@ -342,6 +365,10 @@ impl CacheRefillTask {
let (range_last, _) = sst.calculate_block_info(block_index_end - 1);
let range = range_first.start..range_last.end;

GLOBAL_CACHE_REFILL_METRICS
.data_refill_ideal_bytes
.inc_by((range.end - range.start) as u64);

let mut writers = Vec::with_capacity(block_index_end - block_index_start);
let mut ranges = Vec::with_capacity(block_index_end - block_index_start);
let mut admits = 0;
Expand Down Expand Up @@ -392,7 +419,13 @@ impl CacheRefillTask {
writer.weight() - writer.key().serialized_len(),
)?;
let block = Box::new(block);
writer.finish(block).await.map_err(HummockError::file_cache)
let res = writer.finish(block).await.map_err(HummockError::file_cache);
if matches!(res, Ok(true)) {
GLOBAL_CACHE_REFILL_METRICS
.data_refill_success_bytes
.inc_by(len as u64);
}
res
};
futures.push(future);
}
Expand Down

0 comments on commit 3a94f45

Please sign in to comment.