From f79c7e130f191900b6c1e139dfedcada8474e01b Mon Sep 17 00:00:00 2001 From: Heemank Verma Date: Tue, 10 Dec 2024 15:28:23 +0530 Subject: [PATCH] Fix/telemetry (#189) update: remove dynamic entries from attributes --- CHANGELOG.md | 1 + .../orchestrator/src/database/mongodb/mod.rs | 25 ++++--------------- crates/orchestrator/src/jobs/mod.rs | 9 ++----- crates/orchestrator/src/routes/job_routes.rs | 10 ++------ .../src/workers/data_submission_worker.rs | 1 - crates/orchestrator/src/workers/proving.rs | 1 - crates/orchestrator/src/workers/snos.rs | 1 - .../orchestrator/src/workers/update_state.rs | 3 +-- 8 files changed, 11 insertions(+), 40 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 168dac2f..29e14f69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -80,6 +80,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). ## Fixed +- refactor: static attributes for telemetry - refactor: aws setup for Event Bridge - refactor: RUST_LOG filtering support - refactor: cargo.toml files cleaned diff --git a/crates/orchestrator/src/database/mongodb/mod.rs b/crates/orchestrator/src/database/mongodb/mod.rs index 1c426017..3fd0daa0 100644 --- a/crates/orchestrator/src/database/mongodb/mod.rs +++ b/crates/orchestrator/src/database/mongodb/mod.rs @@ -98,10 +98,7 @@ impl Database for MongoDb { .map_err(|e| JobError::Other(e.to_string().into()))?; if result.matched_count == 0 { - let attributes = [ - KeyValue::new("db_operation_name", "create_job"), - KeyValue::new("db_operation_job", format!("{:?}", job)), - ]; + let attributes = [KeyValue::new("db_operation_name", "create_job")]; let duration = start.elapsed(); ORCHESTRATOR_METRICS.db_calls_response_time.record(duration.as_secs_f64(), &attributes); Ok(job) @@ -117,10 +114,7 @@ impl Database for MongoDb { "id": id }; tracing::debug!(job_id = %id, category = "db_call", "Fetched job by ID"); - let attributes = [ - KeyValue::new("db_operation_name", "get_job_by_id"), - KeyValue::new("db_operation_id", format!("{:?}", id)), - ]; + let attributes = [KeyValue::new("db_operation_name", "get_job_by_id")]; let duration = start.elapsed(); ORCHESTRATOR_METRICS.db_calls_response_time.record(duration.as_secs_f64(), &attributes); Ok(self.get_job_collection().find_one(filter, None).await?) @@ -134,10 +128,7 @@ impl Database for MongoDb { "job_type": mongodb::bson::to_bson(&job_type)?, }; tracing::debug!(internal_id = %internal_id, job_type = ?job_type, category = "db_call", "Fetched job by internal ID and type"); - let attributes = [ - KeyValue::new("db_operation_name", "get_job_by_internal_id_and_type"), - KeyValue::new("db_operation_id", format!("{:?}", internal_id)), - ]; + let attributes = [KeyValue::new("db_operation_name", "get_job_by_internal_id_and_type")]; let duration = start.elapsed(); ORCHESTRATOR_METRICS.db_calls_response_time.record(duration.as_secs_f64(), &attributes); Ok(self.get_job_collection().find_one(filter, None).await?) @@ -180,10 +171,7 @@ impl Database for MongoDb { match result { Some(job) => { tracing::debug!(job_id = %current_job.id, category = "db_call", "Job updated successfully"); - let attributes = [ - KeyValue::new("db_operation_name", "update_job"), - KeyValue::new("db_operation_id", format!("{:?}", current_job.id)), - ]; + let attributes = [KeyValue::new("db_operation_name", "update_job")]; let duration = start.elapsed(); ORCHESTRATOR_METRICS.db_calls_response_time.record(duration.as_secs_f64(), &attributes); Ok(job) @@ -232,10 +220,7 @@ impl Database for MongoDb { match cursor.try_next().await? { Some(doc) => { let job: JobItem = mongodb::bson::from_document(doc)?; - let attributes = [ - KeyValue::new("db_operation_name", "get_latest_job_by_type"), - KeyValue::new("db_operation_job_type", format!("{:?}", job_type)), - ]; + let attributes = [KeyValue::new("db_operation_name", "get_latest_job_by_type")]; let duration = start.elapsed(); ORCHESTRATOR_METRICS.db_calls_response_time.record(duration.as_secs_f64(), &attributes); Ok(Some(job)) diff --git a/crates/orchestrator/src/jobs/mod.rs b/crates/orchestrator/src/jobs/mod.rs index 91b6f1e5..2263090a 100644 --- a/crates/orchestrator/src/jobs/mod.rs +++ b/crates/orchestrator/src/jobs/mod.rs @@ -180,11 +180,8 @@ pub async fn create_job( .await .map_err(|e| JobError::Other(OtherError(e)))?; - let attributes = [ - KeyValue::new("operation_job_type", format!("{:?}", job_type)), - KeyValue::new("operation_type", "create_job"), - KeyValue::new("operation_job", format!("{:?}", job_item)), - ]; + let attributes = + [KeyValue::new("operation_job_type", format!("{:?}", job_type)), KeyValue::new("operation_type", "create_job")]; tracing::info!(log_type = "completed", category = "general", function_type = "create_job", block_no = %internal_id, "General create job completed for block"); let duration = start.elapsed(); @@ -299,7 +296,6 @@ pub async fn process_job(id: Uuid, config: Arc) -> Result<(), JobError> let attributes = [ KeyValue::new("operation_job_type", format!("{:?}", job.job_type)), KeyValue::new("operation_type", "process_job"), - KeyValue::new("operation_job", format!("{:?}", job)), ]; tracing::info!(log_type = "completed", category = "general", function_type = "process_job", block_no = %internal_id, "General process job completed for block"); @@ -444,7 +440,6 @@ pub async fn verify_job(id: Uuid, config: Arc) -> Result<(), JobError> { let attributes = [ KeyValue::new("operation_job_type", format!("{:?}", job.job_type)), KeyValue::new("operation_type", "verify_job"), - KeyValue::new("operation_job", format!("{:?}", job)), ]; tracing::info!(log_type = "completed", category = "general", function_type = "verify_job", block_no = %internal_id, "General verify job completed for block"); diff --git a/crates/orchestrator/src/routes/job_routes.rs b/crates/orchestrator/src/routes/job_routes.rs index 636aa17e..7f3cd489 100644 --- a/crates/orchestrator/src/routes/job_routes.rs +++ b/crates/orchestrator/src/routes/job_routes.rs @@ -43,10 +43,7 @@ async fn handle_process_job_request( ApiResponse::success(response).into_response() } Err(e) => { - let attributes = [ - KeyValue::new("operation_type", "process_job"), - KeyValue::new("operation_job_id", format!("{:?}", job_id)), - ]; + let attributes = [KeyValue::new("operation_type", "process_job")]; ORCHESTRATOR_METRICS.failed_jobs.add(1.0, &attributes); ApiResponse::::error(e.to_string()).into_response() } @@ -72,10 +69,7 @@ async fn handle_verify_job_request( ApiResponse::success(response).into_response() } Err(e) => { - let attributes = [ - KeyValue::new("operation_type", "verify_job"), - KeyValue::new("operation_job_id", format!("{:?}", job_id)), - ]; + let attributes = [KeyValue::new("operation_type", "verify_job")]; ORCHESTRATOR_METRICS.failed_jobs.add(1.0, &attributes); ApiResponse::::error(e.to_string()).into_response() } diff --git a/crates/orchestrator/src/workers/data_submission_worker.rs b/crates/orchestrator/src/workers/data_submission_worker.rs index 20e1955a..bef5cc3f 100644 --- a/crates/orchestrator/src/workers/data_submission_worker.rs +++ b/crates/orchestrator/src/workers/data_submission_worker.rs @@ -33,7 +33,6 @@ impl Worker for DataSubmissionWorker { let attributes = [ KeyValue::new("operation_job_type", format!("{:?}", JobType::DataSubmission)), KeyValue::new("operation_type", format!("{:?}", "create_job")), - KeyValue::new("operation_internal_id", format!("{:?}", job.internal_id)), ]; ORCHESTRATOR_METRICS.failed_jobs.add(1.0, &attributes); } diff --git a/crates/orchestrator/src/workers/proving.rs b/crates/orchestrator/src/workers/proving.rs index 145235ea..20b0df9d 100644 --- a/crates/orchestrator/src/workers/proving.rs +++ b/crates/orchestrator/src/workers/proving.rs @@ -34,7 +34,6 @@ impl Worker for ProvingWorker { let attributes = [ KeyValue::new("operation_job_type", format!("{:?}", JobType::ProofCreation)), KeyValue::new("operation_type", format!("{:?}", "create_job")), - KeyValue::new("operation_internal_id", format!("{:?}", job.internal_id)), ]; ORCHESTRATOR_METRICS.failed_jobs.add(1.0, &attributes); } diff --git a/crates/orchestrator/src/workers/snos.rs b/crates/orchestrator/src/workers/snos.rs index fc322f16..552da715 100644 --- a/crates/orchestrator/src/workers/snos.rs +++ b/crates/orchestrator/src/workers/snos.rs @@ -55,7 +55,6 @@ impl Worker for SnosWorker { let attributes = [ KeyValue::new("operation_job_type", format!("{:?}", JobType::SnosRun)), KeyValue::new("operation_type", format!("{:?}", "create_job")), - KeyValue::new("operation_internal_id", format!("{:?}", block_num.to_string())), ]; ORCHESTRATOR_METRICS.failed_jobs.add(1.0, &attributes); } diff --git a/crates/orchestrator/src/workers/update_state.rs b/crates/orchestrator/src/workers/update_state.rs index b2708c2d..dd989aba 100644 --- a/crates/orchestrator/src/workers/update_state.rs +++ b/crates/orchestrator/src/workers/update_state.rs @@ -122,9 +122,8 @@ impl Worker for UpdateStateWorker { Err(e) => { tracing::error!(job_id = %new_job_id, error = %e, "Failed to create new state transition job"); let attributes = [ - KeyValue::new("operation_job_type", format!("{:?}", JobType::SnosRun)), + KeyValue::new("operation_job_type", format!("{:?}", JobType::StateTransition)), KeyValue::new("operation_type", format!("{:?}", "create_job")), - KeyValue::new("operation_internal_id", format!("{:?}", new_job_id.to_string())), ]; ORCHESTRATOR_METRICS.failed_jobs.add(1.0, &attributes); return Err(e.into());