{"record":{"id":"e7817252c318f1f0","repo":"SonarSource/sonarqube","slug":"can-t-report-metric-data-for-a-ce-task-with-entity","errorCode":null,"errorMessage":"Can't report metric data for a CE task with entity uuid {}","messagePattern":"Can't report metric data for a CE task with entity uuid (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"server/sonar-webserver-monitoring/src/main/java/org/sonar/server/monitoring/ce/RecentTasksDurationTask.java","lineNumber":93,"sourceCode":"      .toList();\n  }\n\n  private void reportObservedDurationForTasks(List<CeActivityDto> tasks, Map<String, String> entityUuidAndKeys) {\n    for (CeActivityDto task : tasks) {\n      String entityUuid = task.getEntityUuid();\n      Long executionTimeMs = task.getExecutionTimeMs();\n      try {\n        requireNonNull(executionTimeMs);\n\n        if (entityUuid != null) {\n          String label = entityUuidAndKeys.get(entityUuid);\n          requireNonNull(label);\n          metrics.observeComputeEngineTaskDuration(executionTimeMs, task.getTaskType(), label);\n        } else {\n          metrics.observeComputeEngineSystemTaskDuration(executionTimeMs, task.getTaskType());\n        }\n      } catch (RuntimeException e) {\n        LOGGER.warn(\"Can't report metric data for a CE task with entity uuid \" + entityUuid, e);\n      }\n    }\n  }\n\n}\n","sourceCodeStart":75,"sourceCodeEnd":99,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-webserver-monitoring/src/main/java/org/sonar/server/monitoring/ce/RecentTasksDurationTask.java#L75-L99","documentation":"RecentTasksDurationTask reports observed CE task durations as Prometheus metrics, choosing a label-based metric for user tasks and a system metric otherwise. If metric reporting throws a RuntimeException, it is logged per task with the task's entity uuid instead of failing the whole run.","triggerScenarios":"metrics.observeComputeEngineTaskDuration or observeComputeEngineSystemTaskDuration throws RuntimeException while processing a finished CE task with the given entity uuid.","commonSituations":"Prometheus registry rejecting a label value (e.g. unexpected task type); concurrent metric registration issues; empty/invalid executionTimeMs.","solutions":["Read the attached exception `e` for the actual metric-reporting failure","Check the task's getTaskType() for a value the metrics layer doesn't expect","Verify Prometheus client/registry configuration is initialized before the task runs","Report the entity uuid from the log to correlate with the CE task row"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (task.getTaskType() == null || executionTimeMs < 0) return; // skip invalid task before metric call","typeGuard":null,"tryCatchPattern":"try { metrics.observeComputeEngineTaskDuration(ms, type, label); } catch (RuntimeException e) { log.warn(\"metric report failed for entity {}\", entityUuid, e); }","preventionTips":["Keep metric label values within the registered label set","Initialize the metrics registry before tasks run","Log and track entity uuids to diagnose recurring failures"],"tags":["metrics","prometheus","compute-engine"],"backgroundTag":"api-request-failed","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}