Skip to content

Commit

Permalink
update: proving time -> verification time
Browse files Browse the repository at this point in the history
  • Loading branch information
heemankv committed Dec 15, 2024
1 parent 7cf2932 commit 66e3c31
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
24 changes: 11 additions & 13 deletions crates/orchestrator/src/jobs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,7 @@ pub async fn process_job(id: Uuid, config: Arc<Config>) -> Result<(), JobError>
Ok(Ok(external_id)) => {
tracing::debug!(job_id = ?id, "Successfully processed job");
// Add the time of processing to the metadata.
if job.job_type == JobType::ProofCreation {
job.metadata.insert("processing_completed_at".to_string(), Utc::now().timestamp_millis().to_string());
}
job.metadata.insert("processing_completed_at".to_string(), Utc::now().timestamp_millis().to_string());
external_id
}
Ok(Err(e)) => {
Expand Down Expand Up @@ -357,16 +355,16 @@ pub async fn verify_job(id: Uuid, config: Arc<Config>) -> Result<(), JobError> {
match verification_status {
JobVerificationStatus::Verified => {
tracing::info!(job_id = ?id, "Job verified successfully");
if job.job_type == JobType::ProofCreation {
match job
.metadata
.get("processing_completed_at")
.and_then(|time| time.parse::<i64>().ok())
.map(|start| Utc::now().timestamp_millis() - start)
{
Some(time_taken) => ORCHESTRATOR_METRICS.proving_time.record(time_taken as f64, &[]),
None => tracing::warn!("Failed to calculate proving time: Invalid or missing processing time"),
}
match job
.metadata
.get("processing_completed_at")
.and_then(|time| time.parse::<i64>().ok())
.map(|start| Utc::now().timestamp_millis() - start)
{
Some(time_taken) => ORCHESTRATOR_METRICS
.verification_time
.record(time_taken as f64, &[KeyValue::new("operation_job_type", format!("{:?}", job.job_type))]),
None => tracing::warn!("Failed to calculate verification time: Invalid or missing processing time"),
}
let mut metadata = job.metadata.clone();
metadata.remove("processing_completed_at");
Expand Down
10 changes: 5 additions & 5 deletions crates/orchestrator/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub struct OrchestratorMetrics {
pub successful_job_operations: Counter<f64>,
pub failed_job_operations: Counter<f64>,
pub failed_jobs: Counter<f64>,
pub proving_time: Gauge<f64>,
pub verification_time: Gauge<f64>,
pub jobs_response_time: Gauge<f64>,
pub db_calls_response_time: Gauge<f64>,
}
Expand Down Expand Up @@ -58,10 +58,10 @@ impl Metrics for OrchestratorMetrics {
"jobs".to_string(),
);

let proving_time = register_gauge_metric_instrument(
let verification_time = register_gauge_metric_instrument(
&orchestrator_meter,
"proving_time".to_string(),
"A gauge to show the time taken for proving task".to_string(),
"verification_time".to_string(),
"A gauge to show the time taken for verification of tasks".to_string(),
"ms".to_string(),
);

Expand All @@ -84,7 +84,7 @@ impl Metrics for OrchestratorMetrics {
successful_job_operations,
failed_job_operations,
failed_jobs,
proving_time,
verification_time,
jobs_response_time,
db_calls_response_time,
}
Expand Down

0 comments on commit 66e3c31

Please sign in to comment.