Skip to content

Commit

Permalink
Merge branch 'main' into feat/retry-job-status
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohiiit authored Jan 2, 2025
2 parents c436469 + 15b321b commit 6abd00a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## Fixed

- refactor: instrumentation
- refactor: instrumentations
- `is_worker_enabled` status check moved from `VerificationFailed` to `Failed`
- refactor: static attributes for telemetry
- refactor: aws setup for Event Bridge
Expand Down
21 changes: 18 additions & 3 deletions crates/orchestrator/src/jobs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,16 +383,16 @@ pub async fn process_job(id: Uuid, config: Arc<Config>) -> Result<(), JobError>
JobError::Other(OtherError(e))
})?;

let attributes = [
let attributes = vec![
KeyValue::new("operation_job_type", format!("{:?}", job.job_type)),
KeyValue::new("operation_type", "process_job"),
];

tracing::info!(log_type = "completed", category = "general", function_type = "process_job", block_no = %internal_id, "General process job completed for block");
let duration = start.elapsed();
ORCHESTRATOR_METRICS.successful_job_operations.add(1.0, &attributes);
ORCHESTRATOR_METRICS.block_gauge.record(parse_string(&job.internal_id)?, &attributes);
ORCHESTRATOR_METRICS.jobs_response_time.record(duration.as_secs_f64(), &attributes);
register_block_gauge(&job, &attributes)?;
Ok(())
}

Expand Down Expand Up @@ -586,7 +586,7 @@ pub async fn verify_job(id: Uuid, config: Arc<Config>) -> Result<(), JobError> {
let duration = start.elapsed();
ORCHESTRATOR_METRICS.successful_job_operations.add(1.0, &attributes);
ORCHESTRATOR_METRICS.jobs_response_time.record(duration.as_secs_f64(), &attributes);
ORCHESTRATOR_METRICS.block_gauge.record(parse_string(&job.internal_id)?, &attributes);
register_block_gauge(&job, &attributes)?;
Ok(())
}

Expand Down Expand Up @@ -807,6 +807,21 @@ fn get_u64_from_metadata(metadata: &HashMap<String, String>, key: &str) -> color
.wrap_err(format!("Failed to parse u64 from metadata key '{}'", key))
}

fn register_block_gauge(job: &JobItem, attributes: &[KeyValue]) -> Result<(), JobError> {
let block_number = if let JobType::StateTransition = job.job_type {
parse_string(
job.external_id
.unwrap_string()
.map_err(|e| JobError::Other(OtherError::from(format!("Could not parse string: {e}"))))?,
)
} else {
parse_string(&job.internal_id)
}?;

ORCHESTRATOR_METRICS.block_gauge.record(block_number, attributes);
Ok(())
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down

0 comments on commit 6abd00a

Please sign in to comment.