diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 31fcd011ec..8c243a0e92 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -1758,8 +1758,9 @@ App::post('/v1/functions/:functionId/executions') } finally { $queueForUsage ->addMetric(METRIC_EXECUTIONS, 1) - ->addMetric(str_replace('{functionInternalId}', $function->getInternalId(), METRIC_FUNCTION_ID_EXECUTIONS), 1) ->addMetric(METRIC_EXECUTIONS_COMPUTE, (int)($execution->getAttribute('duration') * 1000)) // per project + ->addMetric(METRIC_EXECUTIONS_GB_HOURS, 0.5 * ((int)$build->getAttribute('duration', 0) / 3600)) //TODO @bradley: Adjust memory when we allow for custom memory. + ->addMetric(str_replace('{functionInternalId}', $function->getInternalId(), METRIC_FUNCTION_ID_EXECUTIONS), 1) ->addMetric(str_replace('{functionInternalId}', $function->getInternalId(), METRIC_FUNCTION_ID_EXECUTIONS_COMPUTE), (int)($execution->getAttribute('duration') * 1000)) // per function ->addMetric(str_replace('{functionInternalId}', $function->getInternalId(), METRIC_FUNCTION_ID_EXECUTIONS_GB_HOURS), 0.5 * ((int)$build->getAttribute('duration', 0) / 3600)) //TODO @bradley: Adjust memory when we allow for custom memory. ; diff --git a/src/Appwrite/Platform/Workers/Builds.php b/src/Appwrite/Platform/Workers/Builds.php index 306c057ce5..e90d7c77a6 100644 --- a/src/Appwrite/Platform/Workers/Builds.php +++ b/src/Appwrite/Platform/Workers/Builds.php @@ -540,6 +540,7 @@ class Builds extends Action ->addMetric(METRIC_BUILDS, 1) // per project ->addMetric(METRIC_BUILDS_STORAGE, $build->getAttribute('size', 0)) ->addMetric(METRIC_BUILDS_COMPUTE, (int)$build->getAttribute('duration', 0) * 1000) + ->addMetric(METRIC_BUILDS_GB_HOURS, 0.5 * ((int)$build->getAttribute('duration', 0) / 3600)) //TODO @bradley: Adjust memory when we allow for custom memory. ->addMetric(str_replace('{functionInternalId}', $function->getInternalId(), METRIC_FUNCTION_ID_BUILDS), 1) // per function ->addMetric(str_replace('{functionInternalId}', $function->getInternalId(), METRIC_FUNCTION_ID_BUILDS_STORAGE), $build->getAttribute('size', 0)) ->addMetric(str_replace('{functionInternalId}', $function->getInternalId(), METRIC_FUNCTION_ID_BUILDS_COMPUTE), (int)$build->getAttribute('duration', 0) * 1000)