diff --git a/app/init.php b/app/init.php index 3244e67c26..494e81ea8c 100644 --- a/app/init.php +++ b/app/init.php @@ -234,6 +234,7 @@ const METRIC_DEPLOYMENTS_STORAGE = 'deployments.storage'; const METRIC_BUILDS = 'builds'; const METRIC_BUILDS_STORAGE = 'builds.storage'; const METRIC_BUILDS_COMPUTE = 'builds.compute'; +const METRIC_BUILDS_GB_HOURS = 'builds.gb_hours'; const METRIC_FUNCTION_ID_BUILDS = '{functionInternalId}.builds'; const METRIC_FUNCTION_ID_BUILDS_STORAGE = '{functionInternalId}.builds.storage'; const METRIC_FUNCTION_ID_BUILDS_COMPUTE = '{functionInternalId}.builds.compute'; @@ -242,6 +243,7 @@ const METRIC_FUNCTION_ID_DEPLOYMENTS_STORAGE = '{resourceType}.{resourceInterna const METRIC_FUNCTION_ID_BUILDS_GB_HOURS = '{functionInternalId}.builds.gb_hours'; const METRIC_EXECUTIONS = 'executions'; const METRIC_EXECUTIONS_COMPUTE = 'executions.compute'; +const METRIC_EXECUTIONS_GB_HOURS = 'executions.gb_hours'; const METRIC_FUNCTION_ID_EXECUTIONS = '{functionInternalId}.executions'; const METRIC_FUNCTION_ID_EXECUTIONS_COMPUTE = '{functionInternalId}.executions.compute'; const METRIC_FUNCTION_ID_EXECUTIONS_GB_HOURS = '{functionInternalId}.compute.gb_hours'; diff --git a/src/Appwrite/Platform/Workers/Usage.php b/src/Appwrite/Platform/Workers/Usage.php index 48724c0d0d..f38ee71e06 100644 --- a/src/Appwrite/Platform/Workers/Usage.php +++ b/src/Appwrite/Platform/Workers/Usage.php @@ -186,8 +186,10 @@ class Usage extends Action $builds = $dbForProject->getDocument('stats', md5(self::INFINITY_PERIOD . str_replace('{functionInternalId}', $document->getInternalId(), METRIC_FUNCTION_ID_BUILDS))); $buildsStorage = $dbForProject->getDocument('stats', md5(self::INFINITY_PERIOD . str_replace('{functionInternalId}', $document->getInternalId(), METRIC_FUNCTION_ID_BUILDS_STORAGE))); $buildsCompute = $dbForProject->getDocument('stats', md5(self::INFINITY_PERIOD . str_replace('{functionInternalId}', $document->getInternalId(), METRIC_FUNCTION_ID_BUILDS_COMPUTE))); + $buildsGBHours = $dbForProject->getDocument('stats', md5(self::INFINITY_PERIOD . str_replace('{functionInternalId}', $document->getInternalId(), METRIC_FUNCTION_ID_BUILDS_GB_HOURS))); $executions = $dbForProject->getDocument('stats', md5(self::INFINITY_PERIOD . str_replace('{functionInternalId}', $document->getInternalId(), METRIC_FUNCTION_ID_EXECUTIONS))); $executionsCompute = $dbForProject->getDocument('stats', md5(self::INFINITY_PERIOD . str_replace('{functionInternalId}', $document->getInternalId(), METRIC_FUNCTION_ID_EXECUTIONS_COMPUTE))); + $executionsGBHours = $dbForProject->getDocument('stats', md5(self::INFINITY_PERIOD . str_replace('{functionInternalId}', $document->getInternalId(), METRIC_FUNCTION_ID_EXECUTIONS_GB_HOURS))); if (!empty($deployments['value'])) { $metrics[] = [ @@ -224,6 +226,13 @@ class Usage extends Action ]; } + if (!empty($buildsGBHours['value'])) { + $metrics[] = [ + 'key' => METRIC_BUILDS_GB_HOURS, + 'value' => ($buildsGBHours['value'] * -1), + ]; + } + if (!empty($executions['value'])) { $metrics[] = [ 'key' => METRIC_EXECUTIONS, @@ -237,6 +246,13 @@ class Usage extends Action 'value' => ($executionsCompute['value'] * -1), ]; } + + if (!empty($executionsGBHours['value'])) { + $metrics[] = [ + 'key' => METRIC_EXECUTIONS_GB_HOURS, + 'value' => ($executionsGBHours['value'] * -1), + ]; + } break; default: break;