mirror of
https://github.com/appwrite/appwrite
synced 2026-05-21 07:58:55 +00:00
separate cumulative metrics
This commit is contained in:
parent
8ddbde62c1
commit
f41d388bf5
1 changed files with 29 additions and 0 deletions
|
|
@ -319,6 +319,22 @@ class TimeSeries extends Calculator
|
|||
],
|
||||
];
|
||||
|
||||
protected array $cumulativeMetrics = [
|
||||
'deployments.$all.storage.size' => [
|
||||
'table' => 'appwrite_usage_deployments_{scope}_storage_size',
|
||||
],
|
||||
'project.$all.storage.size' => [
|
||||
'table' => 'appwrite_usage_project_{scope}_storage_size',
|
||||
],
|
||||
'files.$all.storage.size' => [
|
||||
'table' => 'appwrite_usage_files_{scope}_storage_size',
|
||||
],
|
||||
'files.$bucketId.storage.size' => [
|
||||
'table' => 'appwrite_usage_files_{scope}_storage_size',
|
||||
'groupBy' => ['bucketId']
|
||||
],
|
||||
];
|
||||
|
||||
public function __construct(Database $database, InfluxDatabase $influxDB, callable $errorHandler = null)
|
||||
{
|
||||
$this->database = $database;
|
||||
|
|
@ -469,5 +485,18 @@ class TimeSeries extends Calculator
|
|||
}
|
||||
}
|
||||
|
||||
// for cumulative metrics only get hourly metrics from timeseries
|
||||
foreach ($this->cumulativeMetrics as $metric => $options) {
|
||||
try {
|
||||
$this->syncFromInfluxDB($metric, $options, $this->periods[0]);
|
||||
} catch (\Exception $e) {
|
||||
if (is_callable($this->errorHandler)) {
|
||||
call_user_func($this->errorHandler, $e);
|
||||
} else {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue