1
0
Fork 0
mirror of synced 2024-10-02 10:16:27 +13:00

compute stats

This commit is contained in:
Damodar Lohani 2022-06-29 07:03:06 +00:00
parent 01016b0444
commit 25aca3c4d3

View file

@ -220,6 +220,23 @@ class UsageDB extends Usage
$this->createOrUpdateMetric($projectId, 'storage.total', $projectFilesTotal + $deploymentsTotal); $this->createOrUpdateMetric($projectId, 'storage.total', $projectFilesTotal + $deploymentsTotal);
} }
/**
* Storage Stats
* Metrics: storage.total, storage.files.total, storage.buckets.{bucketId}.files.total,
* storage.buckets.count, storage.files.count, storage.buckets.{bucketId}.files.count
*
* @param string $projectId
*
* @return void
*/
private function computeStats(string $projectId): void
{
$executionTotal = $this->sum($projectId, 'executions', 'time', 'functions.executionTime.total');
$buildTotal = $this->sum($projectId, 'builds', 'duration', 'functions.buildTime.total');
$this->createOrUpdateMetric($projectId, 'functions.compute.total', $executionTotal + $buildTotal);
}
/** /**
* Database Stats * Database Stats
* Collect all database stats * Collect all database stats
@ -268,7 +285,7 @@ class UsageDB extends Usage
{ {
$this->foreachDocument('console', 'projects', [], function (Document $project) { $this->foreachDocument('console', 'projects', [], function (Document $project) {
$projectId = $project->getInternalId(); $projectId = $project->getInternalId();
$this->computeStats($projectId);
$this->usersStats($projectId); $this->usersStats($projectId);
$this->databaseStats($projectId); $this->databaseStats($projectId);
$this->storageStats($projectId); $this->storageStats($projectId);