feat: telemetry for storage devices (#9761)

This commit is contained in:
Fabian Gruber 2025-05-15 10:21:38 +02:00 committed by GitHub
parent fdbc01aa3d
commit 651cec65da
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 50 additions and 44 deletions

View file

@ -507,21 +507,21 @@ App::setResource('timelimit', function (\Redis $redis) {
};
}, ['redis']);
App::setResource('deviceForLocal', function () {
return new Local();
});
App::setResource('deviceForLocal', function (Telemetry $telemetry) {
return new Device\Telemetry($telemetry, new Local());
}, ['telemetry']);
App::setResource('deviceForFiles', function ($project) {
return getDevice(APP_STORAGE_UPLOADS . '/app-' . $project->getId());
}, ['project']);
App::setResource('deviceForFiles', function ($project, Telemetry $telemetry) {
return new Device\Telemetry($telemetry, getDevice(APP_STORAGE_UPLOADS . '/app-' . $project->getId()));
}, ['project', 'telemetry']);
App::setResource('deviceForFunctions', function ($project) {
return getDevice(APP_STORAGE_FUNCTIONS . '/app-' . $project->getId());
}, ['project']);
App::setResource('deviceForFunctions', function ($project, Telemetry $telemetry) {
return new Device\Telemetry($telemetry, getDevice(APP_STORAGE_FUNCTIONS . '/app-' . $project->getId()));
}, ['project', 'telemetry']);
App::setResource('deviceForBuilds', function ($project) {
return getDevice(APP_STORAGE_BUILDS . '/app-' . $project->getId());
}, ['project']);
App::setResource('deviceForBuilds', function ($project, Telemetry $telemetry) {
return new Device\Telemetry($telemetry, getDevice(APP_STORAGE_BUILDS . '/app-' . $project->getId()));
}, ['project', 'telemetry']);
function getDevice(string $root, string $connection = ''): Device
{

View file

@ -37,7 +37,10 @@ use Utopia\Queue\Message;
use Utopia\Queue\Publisher;
use Utopia\Queue\Server;
use Utopia\Registry\Registry;
use Utopia\Storage\Device;
use Utopia\System\System;
use Utopia\Telemetry\Adapter as Telemetry;
use Utopia\Telemetry\Adapter\None as NoTelemetry;
Authorization::disable();
Runtime::enableCoroutine(SWOOLE_HOOK_ALL);
@ -334,21 +337,23 @@ Server::setResource('pools', function (Registry $register) {
return $register->get('pools');
}, ['register']);
Server::setResource('deviceForFunctions', function (Document $project) {
return getDevice(APP_STORAGE_FUNCTIONS . '/app-' . $project->getId());
}, ['project']);
Server::setResource('telemetry', fn () => new NoTelemetry());
Server::setResource('deviceForFiles', function (Document $project) {
return getDevice(APP_STORAGE_UPLOADS . '/app-' . $project->getId());
}, ['project']);
Server::setResource('deviceForFunctions', function (Document $project, Telemetry $telemetry) {
return new Device\Telemetry($telemetry, getDevice(APP_STORAGE_FUNCTIONS . '/app-' . $project->getId()));
}, ['project', 'telemetry']);
Server::setResource('deviceForBuilds', function (Document $project) {
return getDevice(APP_STORAGE_BUILDS . '/app-' . $project->getId());
}, ['project']);
Server::setResource('deviceForFiles', function (Document $project, Telemetry $telemetry) {
return new Device\Telemetry($telemetry, getDevice(APP_STORAGE_UPLOADS . '/app-' . $project->getId()));
}, ['project', 'telemetry']);
Server::setResource('deviceForCache', function (Document $project) {
return getDevice(APP_STORAGE_CACHE . '/app-' . $project->getId());
}, ['project']);
Server::setResource('deviceForBuilds', function (Document $project, Telemetry $telemetry) {
return new Device\Telemetry($telemetry, getDevice(APP_STORAGE_BUILDS . '/app-' . $project->getId()));
}, ['project', 'telemetry']);
Server::setResource('deviceForCache', function (Document $project, Telemetry $telemetry) {
return new Device\Telemetry($telemetry, getDevice(APP_STORAGE_CACHE . '/app-' . $project->getId()));
}, ['project', 'telemetry']);
Server::setResource(
'isResourceBlocked',

41
composer.lock generated
View file

@ -709,16 +709,16 @@
},
{
"name": "google/protobuf",
"version": "v4.30.2",
"version": "v4.31.0",
"source": {
"type": "git",
"url": "https://github.com/protocolbuffers/protobuf-php.git",
"reference": "a4c4d8565b40b9f76debc9dfeb221412eacb8ced"
"reference": "d59e31ce4bf0e4b48728e90c4d880839edb5be07"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/protocolbuffers/protobuf-php/zipball/a4c4d8565b40b9f76debc9dfeb221412eacb8ced",
"reference": "a4c4d8565b40b9f76debc9dfeb221412eacb8ced",
"url": "https://api.github.com/repos/protocolbuffers/protobuf-php/zipball/d59e31ce4bf0e4b48728e90c4d880839edb5be07",
"reference": "d59e31ce4bf0e4b48728e90c4d880839edb5be07",
"shasum": ""
},
"require": {
@ -747,9 +747,9 @@
"proto"
],
"support": {
"source": "https://github.com/protocolbuffers/protobuf-php/tree/v4.30.2"
"source": "https://github.com/protocolbuffers/protobuf-php/tree/v4.31.0"
},
"time": "2025-03-26T18:01:50+00:00"
"time": "2025-05-14T16:17:23+00:00"
},
{
"name": "league/csv",
@ -3499,16 +3499,16 @@
},
{
"name": "utopia-php/database",
"version": "0.69.1",
"version": "0.69.2",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/database.git",
"reference": "cc6538e05e25d930244ab938c966d32db0922e83"
"reference": "60591ab073bb80bb9843338754b679bb8169e4ed"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/database/zipball/cc6538e05e25d930244ab938c966d32db0922e83",
"reference": "cc6538e05e25d930244ab938c966d32db0922e83",
"url": "https://api.github.com/repos/utopia-php/database/zipball/60591ab073bb80bb9843338754b679bb8169e4ed",
"reference": "60591ab073bb80bb9843338754b679bb8169e4ed",
"shasum": ""
},
"require": {
@ -3549,9 +3549,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/database/issues",
"source": "https://github.com/utopia-php/database/tree/0.69.1"
"source": "https://github.com/utopia-php/database/tree/0.69.2"
},
"time": "2025-05-13T12:00:31+00:00"
"time": "2025-05-14T07:51:44+00:00"
},
{
"name": "utopia-php/domains",
@ -4331,16 +4331,16 @@
},
{
"name": "utopia-php/storage",
"version": "0.18.10",
"version": "0.18.12",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/storage.git",
"reference": "76f31158f4251abb207f7a9b16f7cb0bfdb3b39e"
"reference": "9a2556c39b5f4d9f8e79111fd34ec889b7bb1e97"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/storage/zipball/76f31158f4251abb207f7a9b16f7cb0bfdb3b39e",
"reference": "76f31158f4251abb207f7a9b16f7cb0bfdb3b39e",
"url": "https://api.github.com/repos/utopia-php/storage/zipball/9a2556c39b5f4d9f8e79111fd34ec889b7bb1e97",
"reference": "9a2556c39b5f4d9f8e79111fd34ec889b7bb1e97",
"shasum": ""
},
"require": {
@ -4353,9 +4353,10 @@
"ext-xz": "*",
"ext-zlib": "*",
"ext-zstd": "*",
"php": ">=8.0",
"php": ">=8.1",
"utopia-php/framework": "0.*.*",
"utopia-php/system": "0.*.*"
"utopia-php/system": "0.*.*",
"utopia-php/telemetry": "0.1.*"
},
"require-dev": {
"laravel/pint": "1.2.*",
@ -4382,9 +4383,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/storage/issues",
"source": "https://github.com/utopia-php/storage/tree/0.18.10"
"source": "https://github.com/utopia-php/storage/tree/0.18.12"
},
"time": "2025-03-03T10:47:54+00:00"
"time": "2025-05-15T07:55:58+00:00"
},
{
"name": "utopia-php/swoole",