mirror of
https://git.asonix.dog/asonix/background-jobs.git
synced 2024-11-24 21:11:03 +00:00
Add gauges for memory storage
This commit is contained in:
parent
f5163454da
commit
4dbde2c9eb
1 changed files with 16 additions and 2 deletions
|
@ -187,7 +187,8 @@ pub mod memory_storage {
|
||||||
if let Some((_, _, found_job_meta)) = inner.queue_jobs.get_mut(&queue_key) {
|
if let Some((_, _, found_job_meta)) = inner.queue_jobs.get_mut(&queue_key) {
|
||||||
*found_job_meta = Some((runner_id, OffsetDateTime::now_utc()));
|
*found_job_meta = Some((runner_id, OffsetDateTime::now_utc()));
|
||||||
} else {
|
} else {
|
||||||
metrics::counter!("background-jobs.core.heartbeat.missing-queue-job").increment(1);
|
metrics::counter!("background-jobs.memory.heartbeat.missing-queue-job")
|
||||||
|
.increment(1);
|
||||||
tracing::warn!("Missing job meta for {queue_key:?}");
|
tracing::warn!("Missing job meta for {queue_key:?}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,7 +202,7 @@ pub mod memory_storage {
|
||||||
let queue_key = (job.queue.clone(), queue_time_id);
|
let queue_key = (job.queue.clone(), queue_time_id);
|
||||||
|
|
||||||
if inner.queue_jobs.remove(&queue_key).is_none() {
|
if inner.queue_jobs.remove(&queue_key).is_none() {
|
||||||
metrics::counter!("background-jobs.core.remove.missing-queue-job").increment(1);
|
metrics::counter!("background-jobs.memory.remove.missing-queue-job").increment(1);
|
||||||
tracing::warn!("failed to remove job meta for {queue_key:?}");
|
tracing::warn!("failed to remove job meta for {queue_key:?}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,10 +230,23 @@ pub mod memory_storage {
|
||||||
|
|
||||||
inner.queues.entry(queue).or_default().notify(1);
|
inner.queues.entry(queue).or_default().notify(1);
|
||||||
|
|
||||||
|
metrics::gauge!("background-jobs.memory.insert.queues")
|
||||||
|
.set(recordable(inner.queues.len()));
|
||||||
|
metrics::gauge!("background-jobs.memory.insert.jobs").set(recordable(inner.jobs.len()));
|
||||||
|
metrics::gauge!("background-jobs.memory.insert.queue-jobs")
|
||||||
|
.set(recordable(inner.queue_jobs.len()));
|
||||||
|
|
||||||
id.0
|
id.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn recordable(value: usize) -> u32 {
|
||||||
|
let value = value as u64;
|
||||||
|
let value = value % u64::from(u32::MAX);
|
||||||
|
|
||||||
|
value as _
|
||||||
|
}
|
||||||
|
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
impl<T: Timer + Send + Sync + Clone> super::Storage for Storage<T> {
|
impl<T: Timer + Send + Sync + Clone> super::Storage for Storage<T> {
|
||||||
type Error = Infallible;
|
type Error = Infallible;
|
||||||
|
|
Loading…
Reference in a new issue