1
0
Fork 0
mirror of synced 2024-07-06 07:00:56 +12:00

Merge branch 'refactor-usage-sn' of github.com:appwrite/appwrite into remove-cloud-scripts

This commit is contained in:
shimon 2024-02-19 17:38:13 +02:00
commit 22e7c58d7d
4 changed files with 7 additions and 4 deletions

View file

@ -250,7 +250,6 @@ try {
Console::error($e->getMessage() . ', File: ' . $e->getFile() . ', Line: ' . $e->getLine());
}
$worker = $platform->getWorker();
$worker
@ -265,7 +264,8 @@ $worker
->inject('error')
->inject('logger')
->inject('log')
->action(function (Throwable $error, ?Logger $logger, Log $log) {
->inject('project')
->action(function (Throwable $error, ?Logger $logger, Log $log, Document $project) {
$version = App::getEnv('_APP_VERSION', 'UNKNOWN');
if ($error instanceof PDOException) {
@ -281,6 +281,7 @@ $worker
$log->setAction('appwrite-queue-' . App::getEnv('QUEUE'));
$log->addTag('verboseType', get_class($error));
$log->addTag('code', $error->getCode());
$log->addTag('projectId', $project->getId() ?? 'n/a');
$log->addExtra('file', $error->getFile());
$log->addExtra('line', $error->getLine());
$log->addExtra('trace', $error->getTraceAsString());

View file

@ -365,6 +365,7 @@ class Mail extends Event
$client = new Client($this->queue, $this->connection);
return $client->enqueue([
'project' => $this->project,
'recipient' => $this->recipient,
'name' => $this->name,
'subject' => $this->subject,

View file

@ -76,6 +76,7 @@ class Usage extends Action
}
$this->stats[$projectId]['project'] = $project;
$this->stats[$projectId]['receivedAt'] = DateTime::now();
foreach ($payload['metrics'] ?? [] as $metric) {
$this->keys++;
if (!isset($this->stats[$projectId]['keys'][$metric['key']])) {

View file

@ -59,12 +59,12 @@ class UsageDump extends Action
foreach ($payload['stats'] ?? [] as $stats) {
$project = new Document($stats['project'] ?? []);
$numberOfKeys = !empty($stats['keys']) ? count($stats['keys']) : 0;
$receivedAt = $stats['receivedAt'] ?? 'NONE';
if ($numberOfKeys === 0) {
continue;
}
console::log('[' . DateTime::now() . '] ProjectId [' . $project->getInternalId() . '] Database [' . $project['database'] . '] ' . $numberOfKeys . ' keys');
console::log('[' . DateTime::now() . '] ProjectId [' . $project->getInternalId() . '] ReceivedAt [' . $receivedAt . '] ' . $numberOfKeys . ' keys');
try {
$dbForProject = $getProjectDB($project);