diff --git a/app/init.php b/app/init.php index 7b252d19e7..071d9bfff9 100644 --- a/app/init.php +++ b/app/init.php @@ -243,7 +243,7 @@ const METRIC_FUNCTION_ID_DEPLOYMENTS_STORAGE = '{resourceType}.{resourceInterna const METRIC_FUNCTION_ID_BUILDS_MB_SECONDS = '{functionInternalId}.builds.mbSeconds'; const METRIC_EXECUTIONS = 'executions'; const METRIC_EXECUTIONS_COMPUTE = 'executions.compute'; -const METRIC_EXECUTIONS_MB_SECONDS = 'executions.mb_seconds'; +const METRIC_EXECUTIONS_MB_SECONDS = 'executions.mbSeconds'; const METRIC_FUNCTION_ID_EXECUTIONS = '{functionInternalId}.executions'; const METRIC_FUNCTION_ID_EXECUTIONS_COMPUTE = '{functionInternalId}.executions.compute'; const METRIC_FUNCTION_ID_EXECUTIONS_MB_SECONDS = '{functionInternalId}.executions.mbSeconds'; diff --git a/src/Appwrite/Platform/Workers/Usage.php b/src/Appwrite/Platform/Workers/Usage.php index 54905ba0d0..69f072ebce 100644 --- a/src/Appwrite/Platform/Workers/Usage.php +++ b/src/Appwrite/Platform/Workers/Usage.php @@ -186,10 +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_MB_SECONDS))); + $buildsMbSeconds = $dbForProject->getDocument('stats', md5(self::INFINITY_PERIOD . str_replace('{functionInternalId}', $document->getInternalId(), METRIC_FUNCTION_ID_BUILDS_MB_SECONDS))); $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_MB_SECONDS))); + $executionsMbSeconds = $dbForProject->getDocument('stats', md5(self::INFINITY_PERIOD . str_replace('{functionInternalId}', $document->getInternalId(), METRIC_FUNCTION_ID_EXECUTIONS_MB_SECONDS))); if (!empty($deployments['value'])) { $metrics[] = [ @@ -226,6 +226,13 @@ class Usage extends Action ]; } + if (!empty($buildsMbSeconds['value'])) { + $metrics[] = [ + 'key' => METRIC_BUILDS_MB_SECONDS, + 'value' => ($buildsMbSeconds['value'] * -1), + ]; + } + if (!empty($executions['value'])) { $metrics[] = [ 'key' => METRIC_EXECUTIONS, @@ -239,6 +246,13 @@ class Usage extends Action 'value' => ($executionsCompute['value'] * -1), ]; } + + if (!empty($executionsMbSeconds['value'])) { + $metrics[] = [ + 'key' => METRIC_EXECUTIONS_MB_SECONDS, + 'value' => ($executionsMbSeconds['value'] * -1), + ]; + } break; default: break; diff --git a/src/Appwrite/Utopia/Response/Model/UsageFunction.php b/src/Appwrite/Utopia/Response/Model/UsageFunction.php index feb4629895..68779e1936 100644 --- a/src/Appwrite/Utopia/Response/Model/UsageFunction.php +++ b/src/Appwrite/Utopia/Response/Model/UsageFunction.php @@ -66,7 +66,7 @@ class UsageFunction extends Model ]) ->addRule('executionsMbSecondsTotal', [ 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated sum of function executions mbSeconds.', + 'description' => 'Total aggregated sum of function executions mbSeconds.', 'default' => 0, 'example' => 0, ]) @@ -107,7 +107,7 @@ class UsageFunction extends Model ]) ->addRule('buildsMbSeconds', [ 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated number of function builds mbSeconds.', + 'description' => 'Aggregated number of function builds mbSeconds per period.', 'default' => [], 'example' => [], 'array' => true