feat: function execution time for failed executions
This commit is contained in:
parent
1728833307
commit
ee056e582f
4 changed files with 8 additions and 2 deletions
|
@ -960,6 +960,9 @@ App::post('/v1/functions/:functionId/executions')
|
|||
$execution->setAttribute('stderr', $executionResponse['stderr']);
|
||||
$execution->setAttribute('time', $executionResponse['time']);
|
||||
} catch (\Throwable $th) {
|
||||
$endtime = \time();
|
||||
$time = $endtime - $execution->getAttribute('dateCreated');
|
||||
$execution->setAttribute('time', $time);
|
||||
$execution->setAttribute('status', 'failed');
|
||||
$execution->setAttribute('statusCode', $th->getCode());
|
||||
$execution->setAttribute('stderr', $th->getMessage());
|
||||
|
|
|
@ -470,7 +470,7 @@ App::post('/v1/execution')
|
|||
case $statusCode >= 500:
|
||||
$stderr = $executorResponse ?? 'Internal Runtime error.';
|
||||
break;
|
||||
case $statusCode >= 200:
|
||||
case $statusCode >= 100:
|
||||
$stdout = $executorResponse;
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -307,6 +307,9 @@ class FunctionsV1 extends Worker
|
|||
$execution->setAttribute('stderr', $executionResponse['stderr']);
|
||||
$execution->setAttribute('time', $executionResponse['time']);
|
||||
} catch (\Throwable $th) {
|
||||
$endtime = \time();
|
||||
$time = $endtime - $execution->getAttribute('dateCreated');
|
||||
$execution->setAttribute('time', $time);
|
||||
$execution->setAttribute('status', 'failed');
|
||||
$execution->setAttribute('statusCode', $th->getCode());
|
||||
$execution->setAttribute('stderr', $th->getMessage());
|
||||
|
|
|
@ -761,7 +761,7 @@ class FunctionsCustomServerTest extends Scope
|
|||
$this->assertEquals($executions['body']['executions'][0]['$id'], $executionId);
|
||||
$this->assertEquals($executions['body']['executions'][0]['trigger'], 'http');
|
||||
$this->assertEquals($executions['body']['executions'][0]['status'], 'failed');
|
||||
$this->assertEquals($executions['body']['executions'][0]['statusCode'], 124);
|
||||
$this->assertEquals($executions['body']['executions'][0]['statusCode'], 500);
|
||||
$this->assertGreaterThan(2, $executions['body']['executions'][0]['time']);
|
||||
$this->assertLessThan(3, $executions['body']['executions'][0]['time']);
|
||||
$this->assertEquals($executions['body']['executions'][0]['stdout'], '');
|
||||
|
|
Loading…
Reference in a new issue