Merge pull request #4674 from appwrite/fix-usage-executions
Fix: usage executions
This commit is contained in:
commit
006cb4665e
|
@ -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', ''))
|
||||
|
|
|
@ -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'],
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue