Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(job-processor): max_attepts_reached metric #626

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions core/lib/queued_job_processor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ pub trait JobProcessor: Sync + Send {
task: JoinHandle<anyhow::Result<Self::JobArtifacts>>,
) -> anyhow::Result<()> {
let attempts = self.get_job_attempts(&job_id).await?;
let max_attempts = self.max_attempts();
if attempts == max_attempts {
METRICS.max_attempts_reached[&(Self::SERVICE_NAME, format!("{job_id:?}"))].inc();
tracing::error!(
"Max attempts ({max_attempts}) reached for {} job {:?}",
Self::SERVICE_NAME,
job_id,
);
}

let result = loop {
tracing::trace!(
"Polling {} task with id {:?}. Is finished: {}",
Expand Down Expand Up @@ -144,15 +154,6 @@ pub trait JobProcessor: Sync + Send {
error_message
);

let max_attempts = self.max_attempts();
if attempts == max_attempts {
METRICS.max_attempts_reached[&(Self::SERVICE_NAME, format!("{job_id:?}"))].inc();
tracing::error!(
"Max attempts ({max_attempts}) reached for {} job {:?}",
Self::SERVICE_NAME,
job_id,
);
}
self.save_failure(job_id, started_at, error_message).await;
Ok(())
}
Expand Down