1
0
Fork 0
mirror of synced 2024-05-09 07:12:34 +12:00

Merge pull request #4674 from appwrite/fix-usage-executions

Fix: usage executions
This commit is contained in:
Torsten Dittmann 2022-11-15 15:39:12 +01:00 committed by GitHub
commit 006cb4665e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 1 deletions

View file

@ -368,6 +368,7 @@ class FunctionsV1 extends Worker
$usage = new Stats($statsd);
$usage
->setParam('projectId', $project->getId())
->setParam('projectInternalId', $project->getInternalId())
->setParam('functionId', $function->getId())
->setParam('executions.{scope}.compute', 1)
->setParam('executionStatus', $execution->getAttribute('status', ''))

View file

@ -492,7 +492,7 @@ class TimeSeries extends Calculator
$value = (!empty($point['value'])) ? $point['value'] : 0;
if (empty($point['projectInternalId'] ?? null)) {
return;
continue;
}
$this->createOrUpdateMetric(
$point['projectInternalId'],

View file

@ -684,6 +684,25 @@ class UsageTest extends Scope
}
$executionTime += (int) ($execution['body']['duration'] * 1000);
$execution = $this->client->call(Client::METHOD_POST, '/functions/' . $functionId . '/executions', $headers, [
'async' => true,
]);
$this->assertEquals(202, $execution['headers']['status-code']);
$this->assertNotEmpty($execution['body']['$id']);
$this->assertEquals($functionId, $execution['body']['functionId']);
sleep(10);
$execution = $this->client->call(Client::METHOD_GET, '/functions/' . $functionId . '/executions/' . $execution['body']['$id'], $headers);
if ($execution['body']['status'] == 'failed') {
$failures++;
} elseif ($execution['body']['status'] == 'completed') {
$executions++;
}
$executionTime += (int) ($execution['body']['duration'] * 1000);
$data = array_merge($data, [
'functionId' => $functionId,
'executionTime' => $executionTime,