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/instrumentation #200

Merged
merged 4 commits into from
Dec 27, 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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,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 @@ -297,16 +297,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 @@ -476,7 +476,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 All @@ -497,6 +497,21 @@ pub async fn handle_job_failure(id: Uuid, config: Arc<Config>) -> Result<(), Job
.await
}

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(())
}

async fn move_job_to_failed(job: &JobItem, config: Arc<Config>, reason: String) -> Result<(), JobError> {
if job.status == JobStatus::Completed {
tracing::error!(job_id = ?job.id, job_status = ?job.status, "Invalid state exists on DL queue");
Expand Down
Loading