From b7b9bd59e02e5abb41bed9c82afd33c09c920a96 Mon Sep 17 00:00:00 2001 From: Vishnu Kamana Date: Tue, 20 Jan 2026 15:28:15 -0800 Subject: [PATCH] fix maintenance_job_triggered metric to be published in all code paths --- .../tasks/OperationTasksBuilder.java | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/apps/spark/src/main/java/com/linkedin/openhouse/jobs/scheduler/tasks/OperationTasksBuilder.java b/apps/spark/src/main/java/com/linkedin/openhouse/jobs/scheduler/tasks/OperationTasksBuilder.java index 37e3df399..b82cf8261 100644 --- a/apps/spark/src/main/java/com/linkedin/openhouse/jobs/scheduler/tasks/OperationTasksBuilder.java +++ b/apps/spark/src/main/java/com/linkedin/openhouse/jobs/scheduler/tasks/OperationTasksBuilder.java @@ -171,15 +171,6 @@ private List> processMetadataList( if (optionalOperationTask.isPresent()) { taskList.add(optionalOperationTask.get()); } - - // Publish entity metrics for triggered tasks - Attributes taskAttributes = - Attributes.of( - AttributeKey.stringKey(AppConstants.ENTITY_NAME), metadata.getEntityName(), - AttributeKey.stringKey(AppConstants.ENTITY_TYPE), - metadata.getClass().getSimpleName().replace("Metadata", ""), - AttributeKey.stringKey(AppConstants.JOB_TYPE), jobType.getValue()); - otelEmitter.count(METRICS_SCOPE, "maintenance_job_triggered", 1, taskAttributes); } return taskList; } @@ -193,16 +184,22 @@ public Optional> processMetadata( try { OperationTask task = taskFactory.create(metadata); task.setOtelEmitter(otelEmitter); + + // Publish entity metrics for triggered tasks + Attributes taskAttributes = + Attributes.of( + AttributeKey.stringKey(AppConstants.ENTITY_NAME), + metadata.getEntityName(), + AttributeKey.stringKey(AppConstants.ENTITY_TYPE), + metadata.getClass().getSimpleName().replace("Metadata", ""), + AttributeKey.stringKey(AppConstants.JOB_TYPE), + jobType.getValue()); + otelEmitter.count(METRICS_SCOPE, "maintenance_job_triggered", 1, taskAttributes); + if (!task.shouldRun()) { log.info("Skipping task {}", task); // Publish entity metrics for skipped tasks - Attributes taskAttributes = - Attributes.of( - AttributeKey.stringKey(AppConstants.ENTITY_NAME), metadata.getEntityName(), - AttributeKey.stringKey(AppConstants.ENTITY_TYPE), - metadata.getClass().getSimpleName().replace("Metadata", ""), - AttributeKey.stringKey(AppConstants.JOB_TYPE), task.getType().getValue()); otelEmitter.count(METRICS_SCOPE, "maintenance_job_skipped", 1, taskAttributes); return Optional.empty(); } else {