1
0
Fork 0
mirror of synced 2024-06-14 08:44:49 +12:00

stats on build

This commit is contained in:
Damodar Lohani 2022-06-29 06:30:24 +00:00
parent c5dde7c2f5
commit 6a90c7c653

View file

@ -6,7 +6,7 @@ use Appwrite\Resque\Worker;
use Appwrite\Utopia\Response\Model\Deployment;
use Cron\CronExpression;
use Executor\Executor;
use Utopia\Database\Validator\Authorization;
use Appwrite\Stats\Stats;
use Utopia\App;
use Utopia\CLI\Console;
use Utopia\Storage\Storage;
@ -213,6 +213,22 @@ class BuildsV1 extends Worker
channels: $target['channels'],
roles: $target['roles']
);
/** Update usage stats */
global $register;
if (App::getEnv('_APP_USAGE_STATS', 'enabled') === 'enabled') {
$statsd = $register->get('statsd');
$usage = new Stats($statsd);
$usage
->setParam('projectId', $project->getId())
->setParam('functionId', $function->getId())
->setParam('functionExecution', 1)
->setParam('functionBuildStatus', $build->getAttribute('status', ''))
->setParam('functionBuildTime', $build->getAttribute('duration') * 1000) // ms
->setParam('networkRequestSize', 0)
->setParam('networkResponseSize', 0)
->submit();
}
}
}