feat(metrics): add drainer delay metric (#3034)

This commit is contained in:
Kartikeya Hegde
2023-12-06 11:25:00 +05:30
committed by GitHub
parent cfafd5cd29
commit c6e2ee29d9
5 changed files with 48 additions and 1 deletions

View File

@ -128,6 +128,25 @@ pub fn parse_stream_entries<'a>(
.into_report()
}
pub fn push_drainer_delay(pushed_at: Option<&String>, operation: String) {
if let Some(pushed_at) = pushed_at {
if let Ok(time) = pushed_at.parse::<i64>() {
let drained_at = common_utils::date_time::now_unix_timestamp();
let delay = drained_at - time;
logger::debug!(operation = operation, delay = delay);
metrics::DRAINER_DELAY_SECONDS.record(
&metrics::CONTEXT,
delay,
&[metrics::KeyValue {
key: "operation".into(),
value: operation.into(),
}],
);
}
}
}
// Here the output is in the format (stream_index, jobs_picked),
// similar to the first argument of the function
pub async fn increment_stream_index(