mirror of
https://github.com/appwrite/appwrite
synced 2026-04-21 13:37:16 +00:00
Merge pull request #11905 from appwrite/feat-add-telemetry-for-ss-success-rates
feat(sites): add telemetry to ss rates
This commit is contained in:
commit
7568964b7c
1 changed files with 22 additions and 1 deletions
|
|
@ -20,6 +20,8 @@ use Utopia\Platform\Action;
|
|||
use Utopia\Queue\Message;
|
||||
use Utopia\Storage\Device;
|
||||
use Utopia\System\System;
|
||||
use Utopia\Telemetry\Adapter as Telemetry;
|
||||
use Utopia\Telemetry\Counter;
|
||||
|
||||
use function Swoole\Coroutine\batch;
|
||||
|
||||
|
|
@ -44,6 +46,7 @@ class Screenshots extends Action
|
|||
->inject('dbForProject')
|
||||
->inject('project')
|
||||
->inject('deviceForFiles')
|
||||
->inject('telemetry')
|
||||
->callback($this->action(...));
|
||||
}
|
||||
|
||||
|
|
@ -53,7 +56,8 @@ class Screenshots extends Action
|
|||
Database $dbForPlatform,
|
||||
Database $dbForProject,
|
||||
Document $project,
|
||||
Device $deviceForFiles
|
||||
Device $deviceForFiles,
|
||||
Telemetry $telemetry
|
||||
): void {
|
||||
Console::log('Screenshot action started');
|
||||
|
||||
|
|
@ -64,6 +68,7 @@ class Screenshots extends Action
|
|||
}
|
||||
|
||||
$screenshotMessage = Screenshot::fromArray($payload);
|
||||
$counter = $telemetry->createCounter('worker.screenshots.capture');
|
||||
|
||||
Console::log('Site screenshot started');
|
||||
|
||||
|
|
@ -268,8 +273,24 @@ class Screenshots extends Action
|
|||
$date = \date('H:i:s');
|
||||
$this->appendToLogs($dbForProject, $deployment->getId(), $queueForRealtime, "[90m[$date] [90m[[0mappwrite[90m][33m Screenshot capturing failed. Deployment will continue. [0m\n");
|
||||
|
||||
$this->recordTelemetry($counter, 'failure');
|
||||
|
||||
throw $th;
|
||||
}
|
||||
|
||||
$this->recordTelemetry($counter, 'success');
|
||||
}
|
||||
|
||||
protected function recordTelemetry(Counter $counter, string $result): void
|
||||
{
|
||||
try {
|
||||
$counter->add(1, [
|
||||
'resourceType' => RESOURCE_TYPE_SITES,
|
||||
'result' => $result,
|
||||
]);
|
||||
} catch (\Throwable) {
|
||||
// Telemetry should never affect screenshot processing.
|
||||
}
|
||||
}
|
||||
|
||||
protected function appendToLogs(Database $dbForProject, string $deploymentId, Realtime $queueForRealtime, string $logs)
|
||||
|
|
|
|||
Loading…
Reference in a new issue