1
0
Fork 0
mirror of synced 2024-06-27 02:31:04 +12:00

Fix executions usage count

This commit is contained in:
Matej Bačo 2022-11-15 09:33:07 +00:00
parent a376bdcb60
commit 8dd5eb09f0
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(201, $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,