Merge remote-tracking branch 'origin/refactor-usage-sn' into refactor-usage-sn
This commit is contained in:
commit
24969ebc4f
3 changed files with 37 additions and 78 deletions
|
@ -15,23 +15,17 @@ use Appwrite\Extend\Exception as AppwriteException;
|
||||||
use Appwrite\Messaging\Adapter\Realtime;
|
use Appwrite\Messaging\Adapter\Realtime;
|
||||||
use Appwrite\Utopia\Request;
|
use Appwrite\Utopia\Request;
|
||||||
use Appwrite\Utopia\Response;
|
use Appwrite\Utopia\Response;
|
||||||
use Appwrite\Utopia\View;
|
|
||||||
use Utopia\Abuse\Abuse;
|
use Utopia\Abuse\Abuse;
|
||||||
use Utopia\Abuse\Adapters\TimeLimit;
|
use Utopia\Abuse\Adapters\TimeLimit;
|
||||||
use Utopia\App;
|
use Utopia\App;
|
||||||
use Utopia\Cache\Adapter\Filesystem;
|
use Utopia\Cache\Adapter\Filesystem;
|
||||||
use Utopia\Cache\Cache;
|
use Utopia\Cache\Cache;
|
||||||
use Utopia\CLI\Console;
|
|
||||||
use Utopia\Config\Config;
|
use Utopia\Config\Config;
|
||||||
use Utopia\Database\Database;
|
use Utopia\Database\Database;
|
||||||
use Utopia\Database\DateTime;
|
use Utopia\Database\DateTime;
|
||||||
use Utopia\Database\Document;
|
use Utopia\Database\Document;
|
||||||
use Utopia\Database\Helpers\Role;
|
use Utopia\Database\Helpers\Role;
|
||||||
use Utopia\Database\Validator\Authorization;
|
use Utopia\Database\Validator\Authorization;
|
||||||
use Utopia\DSN\DSN;
|
|
||||||
use Utopia\Logger\Log;
|
|
||||||
use Utopia\Logger\Log\User;
|
|
||||||
use Utopia\Logger\Logger;
|
|
||||||
use Utopia\System\System;
|
use Utopia\System\System;
|
||||||
use Utopia\Validator\WhiteList;
|
use Utopia\Validator\WhiteList;
|
||||||
|
|
||||||
|
@ -745,38 +739,3 @@ App::init()
|
||||||
throw new Exception(Exception::GENERAL_USAGE_DISABLED);
|
throw new Exception(Exception::GENERAL_USAGE_DISABLED);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
App::error()
|
|
||||||
->inject('error')
|
|
||||||
->inject('request')
|
|
||||||
->inject('response')
|
|
||||||
->inject('project')
|
|
||||||
->inject('queueForUsage')
|
|
||||||
->action(function (Throwable $error, Request $request, Response $response, Document $project, Audit $queueForAudits, Usage $queueForUsage) {
|
|
||||||
|
|
||||||
if ($error instanceof AppwriteException) {
|
|
||||||
$publish = $error->isPublishable();
|
|
||||||
} else {
|
|
||||||
$publish = $error->getCode() === 0 || $error->getCode() >= 500;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($publish && $project->getId() !== 'console') {
|
|
||||||
if (!Auth::isPrivilegedUser(Authorization::getRoles())) {
|
|
||||||
$fileSize = 0;
|
|
||||||
$file = $request->getFiles('file');
|
|
||||||
if (!empty($file)) {
|
|
||||||
$fileSize = (\is_array($file['size']) && isset($file['size'][0])) ? $file['size'][0] : $file['size'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$queueForUsage
|
|
||||||
->addMetric(METRIC_NETWORK_REQUESTS, 1)
|
|
||||||
->addMetric(METRIC_NETWORK_INBOUND, $request->getSize() + $fileSize)
|
|
||||||
->addMetric(METRIC_NETWORK_OUTBOUND, $response->getSize());
|
|
||||||
}
|
|
||||||
|
|
||||||
$queueForUsage
|
|
||||||
->setProject($project)
|
|
||||||
->trigger();
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
|
@ -279,7 +279,7 @@ Server::setResource('deviceForLocalFiles', function (Document $project) {
|
||||||
|
|
||||||
$pools = $register->get('pools');
|
$pools = $register->get('pools');
|
||||||
$platform = new Appwrite();
|
$platform = new Appwrite();
|
||||||
$args = $_SERVER['argv'];
|
$args = $platform->getEnv('argv');
|
||||||
|
|
||||||
if (!isset($args[1])) {
|
if (!isset($args[1])) {
|
||||||
Console::error('Missing worker name');
|
Console::error('Missing worker name');
|
||||||
|
|
72
composer.lock
generated
72
composer.lock
generated
|
@ -2163,16 +2163,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "utopia-php/platform",
|
"name": "utopia-php/platform",
|
||||||
"version": "0.5.1",
|
"version": "0.5.2",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/utopia-php/platform.git",
|
"url": "https://github.com/utopia-php/platform.git",
|
||||||
"reference": "3eceef0b6593fe0f7d2efd36d40402a395a4c285"
|
"reference": "b9feabc79b92dc2b05683a986ad43bce5c1583e3"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/utopia-php/platform/zipball/3eceef0b6593fe0f7d2efd36d40402a395a4c285",
|
"url": "https://api.github.com/repos/utopia-php/platform/zipball/b9feabc79b92dc2b05683a986ad43bce5c1583e3",
|
||||||
"reference": "3eceef0b6593fe0f7d2efd36d40402a395a4c285",
|
"reference": "b9feabc79b92dc2b05683a986ad43bce5c1583e3",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -2180,7 +2180,7 @@
|
||||||
"ext-redis": "*",
|
"ext-redis": "*",
|
||||||
"php": ">=8.0",
|
"php": ">=8.0",
|
||||||
"utopia-php/cli": "0.15.*",
|
"utopia-php/cli": "0.15.*",
|
||||||
"utopia-php/framework": "0.*.*"
|
"utopia-php/framework": "0.33.*"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"laravel/pint": "1.2.*",
|
"laravel/pint": "1.2.*",
|
||||||
|
@ -2206,9 +2206,9 @@
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/utopia-php/platform/issues",
|
"issues": "https://github.com/utopia-php/platform/issues",
|
||||||
"source": "https://github.com/utopia-php/platform/tree/0.5.1"
|
"source": "https://github.com/utopia-php/platform/tree/0.5.2"
|
||||||
},
|
},
|
||||||
"time": "2023-12-26T16:14:41+00:00"
|
"time": "2024-05-22T12:50:35+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "utopia-php/pools",
|
"name": "utopia-php/pools",
|
||||||
|
@ -2591,16 +2591,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "utopia-php/vcs",
|
"name": "utopia-php/vcs",
|
||||||
"version": "0.6.5",
|
"version": "0.6.6",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/utopia-php/vcs.git",
|
"url": "https://github.com/utopia-php/vcs.git",
|
||||||
"reference": "104e47ea8e38c156ec0e0bd415caa3dcd5046fe2"
|
"reference": "e538264cfee5e3efdfe1771efba04750cf20b2c4"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/utopia-php/vcs/zipball/104e47ea8e38c156ec0e0bd415caa3dcd5046fe2",
|
"url": "https://api.github.com/repos/utopia-php/vcs/zipball/e538264cfee5e3efdfe1771efba04750cf20b2c4",
|
||||||
"reference": "104e47ea8e38c156ec0e0bd415caa3dcd5046fe2",
|
"reference": "e538264cfee5e3efdfe1771efba04750cf20b2c4",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -2634,9 +2634,9 @@
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/utopia-php/vcs/issues",
|
"issues": "https://github.com/utopia-php/vcs/issues",
|
||||||
"source": "https://github.com/utopia-php/vcs/tree/0.6.5"
|
"source": "https://github.com/utopia-php/vcs/tree/0.6.6"
|
||||||
},
|
},
|
||||||
"time": "2024-01-08T17:11:12+00:00"
|
"time": "2024-05-17T09:36:30+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "utopia-php/websocket",
|
"name": "utopia-php/websocket",
|
||||||
|
@ -2823,16 +2823,16 @@
|
||||||
"packages-dev": [
|
"packages-dev": [
|
||||||
{
|
{
|
||||||
"name": "appwrite/sdk-generator",
|
"name": "appwrite/sdk-generator",
|
||||||
"version": "0.38.5",
|
"version": "0.38.6",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/appwrite/sdk-generator.git",
|
"url": "https://github.com/appwrite/sdk-generator.git",
|
||||||
"reference": "830a46cc8e34ee096a76d4af6f00adf008a7cbf8"
|
"reference": "d7016d6d72545e84709892faca972eb4bf5bd699"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/830a46cc8e34ee096a76d4af6f00adf008a7cbf8",
|
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/d7016d6d72545e84709892faca972eb4bf5bd699",
|
||||||
"reference": "830a46cc8e34ee096a76d4af6f00adf008a7cbf8",
|
"reference": "d7016d6d72545e84709892faca972eb4bf5bd699",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -2868,9 +2868,9 @@
|
||||||
"description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms",
|
"description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms",
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/appwrite/sdk-generator/issues",
|
"issues": "https://github.com/appwrite/sdk-generator/issues",
|
||||||
"source": "https://github.com/appwrite/sdk-generator/tree/0.38.5"
|
"source": "https://github.com/appwrite/sdk-generator/tree/0.38.6"
|
||||||
},
|
},
|
||||||
"time": "2024-05-17T00:59:59+00:00"
|
"time": "2024-05-20T18:00:16+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "doctrine/deprecations",
|
"name": "doctrine/deprecations",
|
||||||
|
@ -2991,16 +2991,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "laravel/pint",
|
"name": "laravel/pint",
|
||||||
"version": "v1.15.3",
|
"version": "v1.16.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/laravel/pint.git",
|
"url": "https://github.com/laravel/pint.git",
|
||||||
"reference": "3600b5d17aff52f6100ea4921849deacbbeb8656"
|
"reference": "1b3a3dc5bc6a81ff52828ba7277621f1d49d6d98"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/laravel/pint/zipball/3600b5d17aff52f6100ea4921849deacbbeb8656",
|
"url": "https://api.github.com/repos/laravel/pint/zipball/1b3a3dc5bc6a81ff52828ba7277621f1d49d6d98",
|
||||||
"reference": "3600b5d17aff52f6100ea4921849deacbbeb8656",
|
"reference": "1b3a3dc5bc6a81ff52828ba7277621f1d49d6d98",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -3011,11 +3011,11 @@
|
||||||
"php": "^8.1.0"
|
"php": "^8.1.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"friendsofphp/php-cs-fixer": "^3.54.0",
|
"friendsofphp/php-cs-fixer": "^3.57.1",
|
||||||
"illuminate/view": "^10.48.8",
|
"illuminate/view": "^10.48.10",
|
||||||
"larastan/larastan": "^2.9.5",
|
"larastan/larastan": "^2.9.6",
|
||||||
"laravel-zero/framework": "^10.3.0",
|
"laravel-zero/framework": "^10.4.0",
|
||||||
"mockery/mockery": "^1.6.11",
|
"mockery/mockery": "^1.6.12",
|
||||||
"nunomaduro/termwind": "^1.15.1",
|
"nunomaduro/termwind": "^1.15.1",
|
||||||
"pestphp/pest": "^2.34.7"
|
"pestphp/pest": "^2.34.7"
|
||||||
},
|
},
|
||||||
|
@ -3053,7 +3053,7 @@
|
||||||
"issues": "https://github.com/laravel/pint/issues",
|
"issues": "https://github.com/laravel/pint/issues",
|
||||||
"source": "https://github.com/laravel/pint"
|
"source": "https://github.com/laravel/pint"
|
||||||
},
|
},
|
||||||
"time": "2024-04-30T15:02:26+00:00"
|
"time": "2024-05-21T18:08:25+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "matthiasmullie/minify",
|
"name": "matthiasmullie/minify",
|
||||||
|
@ -3469,16 +3469,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpdocumentor/reflection-docblock",
|
"name": "phpdocumentor/reflection-docblock",
|
||||||
"version": "5.4.0",
|
"version": "5.4.1",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
|
"url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
|
||||||
"reference": "298d2febfe79d03fe714eb871d5538da55205b1a"
|
"reference": "9d07b3f7fdcf5efec5d1609cba3c19c5ea2bdc9c"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/298d2febfe79d03fe714eb871d5538da55205b1a",
|
"url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/9d07b3f7fdcf5efec5d1609cba3c19c5ea2bdc9c",
|
||||||
"reference": "298d2febfe79d03fe714eb871d5538da55205b1a",
|
"reference": "9d07b3f7fdcf5efec5d1609cba3c19c5ea2bdc9c",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -3527,9 +3527,9 @@
|
||||||
"description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
|
"description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues",
|
"issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues",
|
||||||
"source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.4.0"
|
"source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.4.1"
|
||||||
},
|
},
|
||||||
"time": "2024-04-09T21:13:58+00:00"
|
"time": "2024-05-21T05:55:05+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpdocumentor/type-resolver",
|
"name": "phpdocumentor/type-resolver",
|
||||||
|
@ -5529,5 +5529,5 @@
|
||||||
"platform-overrides": {
|
"platform-overrides": {
|
||||||
"php": "8.3"
|
"php": "8.3"
|
||||||
},
|
},
|
||||||
"plugin-api-version": "2.6.0"
|
"plugin-api-version": "2.2.0"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue