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/telemetry #189

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 5 additions & 20 deletions crates/orchestrator/src/database/mongodb/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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?)
Expand All @@ -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?)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand Down
9 changes: 2 additions & 7 deletions crates/orchestrator/src/jobs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -299,7 +296,6 @@ pub async fn process_job(id: Uuid, config: Arc<Config>) -> 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");
Expand Down Expand Up @@ -444,7 +440,6 @@ pub async fn verify_job(id: Uuid, config: Arc<Config>) -> 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");
Expand Down
10 changes: 2 additions & 8 deletions crates/orchestrator/src/routes/job_routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<JobApiResponse>::error(e.to_string()).into_response()
}
Expand All @@ -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::<JobApiResponse>::error(e.to_string()).into_response()
}
Expand Down
1 change: 0 additions & 1 deletion crates/orchestrator/src/workers/data_submission_worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 0 additions & 1 deletion crates/orchestrator/src/workers/proving.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 0 additions & 1 deletion crates/orchestrator/src/workers/snos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
3 changes: 1 addition & 2 deletions crates/orchestrator/src/workers/update_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Loading