mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Remove superfluous Console logs from StatsResources worker
Replace redundant Console::info/error/success logs with Span::add for document count — all other details (project ID, sequence, region, database, duration) are already captured by the telemetry span. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
e2d6b76a88
commit
44cd5bb7f0
@@ -5,11 +5,11 @@ namespace Appwrite\Platform\Workers;
|
||||
use Appwrite\Platform\Action;
|
||||
use Exception;
|
||||
use Throwable;
|
||||
use Utopia\Console;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Database\Document;
|
||||
use Utopia\Database\Query;
|
||||
use Utopia\Queue\Message;
|
||||
use Utopia\Telemetry\Span;
|
||||
|
||||
class StatsResources extends Action
|
||||
{
|
||||
@@ -76,29 +76,15 @@ class StatsResources extends Action
|
||||
// Reset documents for each job
|
||||
$this->documents = [];
|
||||
|
||||
$startTime = microtime(true);
|
||||
$this->countForProject($dbForPlatform, $getLogsDB, $getProjectDB, $project);
|
||||
$endTime = microtime(true);
|
||||
$executionTime = $endTime - $startTime;
|
||||
Console::info('Project: ' . $project->getId() . '(' . $project->getSequence() . ') aggregated in ' . $executionTime .' seconds');
|
||||
}
|
||||
|
||||
protected function countForProject(Database $dbForPlatform, callable $getLogsDB, callable $getProjectDB, Document $project): void
|
||||
{
|
||||
Console::info('Begining count for: ' . $project->getId());
|
||||
|
||||
$dbForLogs = null;
|
||||
$dbForProject = null;
|
||||
try {
|
||||
/** @var \Utopia\Database\Database $dbForLogs */
|
||||
$dbForLogs = call_user_func($getLogsDB, $project);
|
||||
/** @var \Utopia\Database\Database $dbForProject */
|
||||
$dbForProject = call_user_func($getProjectDB, $project);
|
||||
} catch (Throwable $th) {
|
||||
Console::error('Unable to get database');
|
||||
Console::error($th->getMessage());
|
||||
return;
|
||||
}
|
||||
/** @var \Utopia\Database\Database $dbForLogs */
|
||||
$dbForLogs = call_user_func($getLogsDB, $project);
|
||||
/** @var \Utopia\Database\Database $dbForProject */
|
||||
$dbForProject = call_user_func($getProjectDB, $project);
|
||||
|
||||
try {
|
||||
|
||||
@@ -209,7 +195,6 @@ class StatsResources extends Action
|
||||
call_user_func_array($this->logError, [$th, "StatsResources", "count_for_project_{$project->getId()}"]);
|
||||
}
|
||||
|
||||
Console::info('End of count for: ' . $project->getId());
|
||||
}
|
||||
|
||||
protected function countForBuckets(Database $dbForProject, Database $dbForLogs, string $region)
|
||||
@@ -463,7 +448,7 @@ class StatsResources extends Action
|
||||
|
||||
protected function writeDocuments(Database $dbForLogs, Document $project): void
|
||||
{
|
||||
$message = 'Stats writeDocuments project: ' . $project->getId() . '(' . $project->getSequence() . ')';
|
||||
Span::add('documents.count', count($this->documents));
|
||||
|
||||
/**
|
||||
* sort by unique index key reduce locks/deadlocks
|
||||
@@ -492,16 +477,9 @@ class StatsResources extends Action
|
||||
return strcmp($a['time'], $b['time']);
|
||||
});
|
||||
|
||||
try {
|
||||
$dbForLogs->upsertDocuments(
|
||||
'stats',
|
||||
$this->documents,
|
||||
);
|
||||
|
||||
Console::success($message . ' | Documents: ' . count($this->documents));
|
||||
} catch (\Throwable $e) {
|
||||
Console::error('Error: ' . $message . ' | Exception: ' . $e->getMessage());
|
||||
throw $e;
|
||||
}
|
||||
$dbForLogs->upsertDocuments(
|
||||
'stats',
|
||||
$this->documents,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user