From 7ae9891bb686c95a7489c59c32f7e7b16d17fcf3 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 3 Sep 2026 12:22:32 +0545 Subject: [PATCH] fix(usage): tag build and execution usage with the resource id Build and execution usage rows carried a populated resourceInternalId but an empty resourceId, so the console's GB-hours breakdown - which groups by resourceId - collapsed all build compute into a single "Unknown" row. CLO-4383 required emitting the public id alongside the internal one, but it was only applied to the Cloud-side emitters. Set it on the CE emitters too: Usage\Build (shared by the Builds and Jobs workers, covering functions and sites) and the execution listener used by self-hosted. Also drops the claim that the id is "resolved to resourceType + resourceId in the usage pipeline" - no such resolution exists. --- src/Appwrite/Bus/Listeners/Usage.php | 1 + src/Appwrite/Usage/Build.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/Bus/Listeners/Usage.php b/src/Appwrite/Bus/Listeners/Usage.php index 1d675682bb..f673314cec 100644 --- a/src/Appwrite/Bus/Listeners/Usage.php +++ b/src/Appwrite/Bus/Listeners/Usage.php @@ -65,6 +65,7 @@ class Usage extends Listener $context = (new Context()) ->setResource(rtrim($resourceType, 's')) + ->setResourceId((string) $resource->getId()) ->setResourceInternalId((string) $resourceInternalId) ->addMetric(METRIC_EXECUTIONS, 1) ->addMetric(str_replace(['{resourceType}'], [$resourceType], METRIC_RESOURCE_TYPE_EXECUTIONS), 1) diff --git a/src/Appwrite/Usage/Build.php b/src/Appwrite/Usage/Build.php index a961c49281..fb2fdf6bd5 100644 --- a/src/Appwrite/Usage/Build.php +++ b/src/Appwrite/Usage/Build.php @@ -39,11 +39,11 @@ final class Build $mbSeconds = 0; } - // Per-resource breakdown now travels as resource dimensions on the - // Context (resolved to resourceType + resourceId in the usage pipeline) + // Per-resource breakdown travels as resource dimensions on the Context // instead of per-{resourceInternalId} metric-name templates. $usage ->setResource(rtrim($resourceType, 's')) + ->setResourceId($resource->getId()) ->setResourceInternalId((string) $resource->getSequence()); switch ($deployment->getAttribute('status')) {