From 8290c8f2420dca7ed4dbe5b373f1850e3f2fa6a9 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Tue, 13 Jan 2026 12:40:46 +0000 Subject: [PATCH] chore: remove logging --- .env | 3 -- README.md | 7 --- app/controllers.php | 19 +++----- app/error.php | 43 +----------------- app/init.php | 79 --------------------------------- composer.json | 1 - composer.lock | 56 +---------------------- docker-compose.yml | 2 - src/Executor/Runner/Adapter.php | 11 +---- src/Executor/Runner/Docker.php | 10 +---- 10 files changed, 12 insertions(+), 219 deletions(-) diff --git a/.env b/.env index 2ef1bcf..4dc03b3 100644 --- a/.env +++ b/.env @@ -6,9 +6,6 @@ OPR_EXECUTOR_MAINTENANCE_INTERVAL=60 OPR_EXECUTOR_NETWORK=executor_runtimes OPR_EXECUTOR_IMAGE=executor-local OPR_EXECUTOR_SECRET=executor-secret-key -OPR_EXECUTOR_LOGGING_PROVIDER= -OPR_EXECUTOR_LOGGING_CONFIG= -OPR_EXECUTOR_LOGGING_IDENTIFIER= OPR_EXECUTOR_DOCKER_HUB_USERNAME= OPR_EXECUTOR_DOCKER_HUB_PASSWORD= OPR_EXECUTOR_RUNTIME_VERSIONS=v2,v5 diff --git a/README.md b/README.md index 49c7dfa..cc451d6 100644 --- a/README.md +++ b/README.md @@ -55,8 +55,6 @@ services: - OPR_EXECUTOR_MAINTENANCE_INTERVAL - OPR_EXECUTOR_NETWORK - OPR_EXECUTOR_SECRET - - OPR_EXECUTOR_LOGGING_PROVIDER - - OPR_EXECUTOR_LOGGING_CONFIG - OPR_EXECUTOR_DOCKER_HUB_USERNAME - OPR_EXECUTOR_DOCKER_HUB_PASSWORD - OPR_EXECUTOR_RUNTIME_VERSIONS @@ -85,9 +83,6 @@ OPR_EXECUTOR_INACTIVE_THRESHOLD=60 OPR_EXECUTOR_MAINTENANCE_INTERVAL=60 OPR_EXECUTOR_NETWORK=openruntimes-runtimes OPR_EXECUTOR_SECRET=executor-secret-key -OPR_EXECUTOR_LOGGING_PROVIDER= -OPR_EXECUTOR_LOGGING_CONFIG= -OPR_EXECUTOR_LOGGING_IDENTIFIER= OPR_EXECUTOR_DOCKER_HUB_USERNAME= OPR_EXECUTOR_DOCKER_HUB_PASSWORD= OPR_EXECUTOR_RUNTIME_VERSIONS=v5 @@ -197,8 +192,6 @@ docker compose down | OPR_EXECUTOR_MAINTENANCE_INTERVAL| Interval (in seconds) at which the Executor performs maintenance tasks, ex: `60` | | OPR_EXECUTOR_NETWORK | Network used by the executor for runtimes, ex: `openruntimes-runtimes` | | OPR_EXECUTOR_SECRET | Secret key used by the executor for authentication | -| OPR_EXECUTOR_LOGGING_PROVIDER | Deprecated: use `OPR_EXECUTOR_LOGGING_CONFIG` with DSN instead. External logging provider used by the executor, ex: `sentry` | -| OPR_EXECUTOR_LOGGING_CONFIG | External logging provider DSN used by the executor, ex: `sentry://PROJECT_ID:SENTRY_API_KEY@SENTRY_HOST/` | | OPR_EXECUTOR_DOCKER_HUB_USERNAME | Username for Docker Hub authentication (if applicable) | | OPR_EXECUTOR_DOCKER_HUB_PASSWORD | Password for Docker Hub authentication (if applicable) | | OPR_EXECUTOR_RUNTIME_VERSIONS | Version tag for runtime environments, ex: `v5` | diff --git a/app/controllers.php b/app/controllers.php index bbf8e2c..104bafd 100644 --- a/app/controllers.php +++ b/app/controllers.php @@ -5,7 +5,6 @@ use OpenRuntimes\Executor\Exception; use OpenRuntimes\Executor\BodyMultipart; use OpenRuntimes\Executor\Runner\Adapter as Runner; -use Utopia\Logger\Log; use Utopia\System\System; use Utopia\Http\Http; use Utopia\Http\Request; @@ -25,15 +24,14 @@ ->param('runtimeId', '', new Text(64), 'Runtime unique ID.') ->param('timeout', '600', new Text(16), 'Maximum logs timeout.', true) ->inject('response') - ->inject('log') ->inject('runner') - ->action(function (string $runtimeId, string $timeoutStr, Response $response, Log $log, Runner $runner) { + ->action(function (string $runtimeId, string $timeoutStr, Response $response, Runner $runner) { $timeout = \intval($timeoutStr); $response->sendHeader('Content-Type', 'text/event-stream'); $response->sendHeader('Cache-Control', 'no-cache'); - $runner->getLogs($runtimeId, $timeout, $response, $log); + $runner->getLogs($runtimeId, $timeout, $response); $response->end(); }); @@ -69,9 +67,8 @@ ->param('version', 'v5', new WhiteList(\explode(',', System::getEnv('OPR_EXECUTOR_RUNTIME_VERSIONS', 'v5') ?? 'v5')), 'Runtime Open Runtime version.', true) ->param('restartPolicy', DockerAPI::RESTART_NO, new WhiteList([DockerAPI::RESTART_NO, DockerAPI::RESTART_ALWAYS, DockerAPI::RESTART_ON_FAILURE, DockerAPI::RESTART_UNLESS_STOPPED], true), 'Define restart policy for the runtime once an exit code is returned. Default value is "no". Possible values are "no", "always", "on-failure", "unless-stopped".', true) ->inject('response') - ->inject('log') ->inject('runner') - ->action(function (string $runtimeId, string $image, string $entrypoint, string $source, string $destination, string $outputDirectory, array $variables, string $runtimeEntrypoint, string $command, int $timeout, bool $remove, float $cpus, int $memory, string $version, string $restartPolicy, Response $response, Log $log, Runner $runner) { + ->action(function (string $runtimeId, string $image, string $entrypoint, string $source, string $destination, string $outputDirectory, array $variables, string $runtimeEntrypoint, string $command, int $timeout, bool $remove, float $cpus, int $memory, string $version, string $restartPolicy, Response $response, Runner $runner) { $secret = \bin2hex(\random_bytes(16)); /** @@ -105,7 +102,7 @@ $variables = array_map(fn ($v) => strval($v), $variables); - $container = $runner->createRuntime($runtimeId, $secret, $image, $entrypoint, $source, $destination, $variables, $runtimeEntrypoint, $command, $timeout, $remove, $cpus, $memory, $version, $restartPolicy, $log); + $container = $runner->createRuntime($runtimeId, $secret, $image, $entrypoint, $source, $destination, $variables, $runtimeEntrypoint, $command, $timeout, $remove, $cpus, $memory, $version, $restartPolicy); $response->setStatusCode(Response::STATUS_CODE_CREATED)->json($container); }); @@ -134,10 +131,9 @@ ->desc('Delete a runtime') ->param('runtimeId', '', new Text(64), 'Runtime unique ID.') ->inject('response') - ->inject('log') ->inject('runner') - ->action(function (string $runtimeId, Response $response, Log $log, Runner $runner) { - $runner->deleteRuntime($runtimeId, $log); + ->action(function (string $runtimeId, Response $response, Runner $runner) { + $runner->deleteRuntime($runtimeId); $response->setStatusCode(Response::STATUS_CODE_OK)->send(); }); @@ -165,7 +161,6 @@ ->param('restartPolicy', DockerAPI::RESTART_NO, new WhiteList([DockerAPI::RESTART_NO, DockerAPI::RESTART_ALWAYS, DockerAPI::RESTART_ON_FAILURE, DockerAPI::RESTART_UNLESS_STOPPED], true), 'Define restart policy once exit code is returned by command. Default value is "no". Possible values are "no", "always", "on-failure", "unless-stopped".', true) ->inject('response') ->inject('request') - ->inject('log') ->inject('runner') ->action( function ( @@ -187,7 +182,6 @@ function ( string $restartPolicy, Response $response, Request $request, - Log $log, Runner $runner ) { // Extra parsers and validators to support both JSON and multipart @@ -258,7 +252,6 @@ function ( $runtimeEntrypoint, $logging, $restartPolicy, - $log ); // Backwards compatibility for headers diff --git a/app/error.php b/app/error.php index 65c0260..1ab1105 100644 --- a/app/error.php +++ b/app/error.php @@ -1,55 +1,14 @@ getMessage()); - Console::error('[Error] File: ' . $error->getFile()); - Console::error('[Error] Line: ' . $error->getLine()); - - if ($logger === null) { - return; - } - - // Log everything, except those explicitly marked as not loggable - if ($error instanceof Exception && !$error->isPublishable()) { - return; - } - - try { - $log->setType(Log::TYPE_ERROR); - $log->setMessage($error->getMessage()); - $log->setAction("httpError"); - $log->addTag('code', \strval($error->getCode())); - $log->addTag('verboseType', get_class($error)); - $log->addExtra('file', $error->getFile()); - $log->addExtra('line', $error->getLine()); - $log->addExtra('trace', $error->getTraceAsString()); - - $status = $logger->addLog($log); - - Console::info("Pushed log with response status code: $status"); - } catch (\Throwable $e) { - Console::error("Failed to push log: {$e->getMessage()}"); - } -} - Http::error() ->inject('error') - ->inject('logger') ->inject('response') - ->inject('log') - ->action(function (Throwable $error, ?Logger $logger, Response $response, Log $log) { - logError($log, $error, $logger); - + ->action(function (Throwable $error, Response $response) { // Show all Executor\Exceptions, or everything if in development $public = $error instanceof Exception || Http::isDevelopment(); $exception = $public ? $error : new Exception(Exception::GENERAL_UNKNOWN); diff --git a/app/init.php b/app/init.php index 27a51fa..8082a75 100644 --- a/app/init.php +++ b/app/init.php @@ -1,87 +1,8 @@ set('logger', function () { - $providerName = System::getEnv('OPR_EXECUTOR_LOGGING_PROVIDER', ''); - $providerConfig = System::getEnv('OPR_EXECUTOR_LOGGING_CONFIG', ''); - - try { - $loggingProvider = new DSN($providerConfig ?? ''); - - $providerName = $loggingProvider->getScheme(); - $providerConfig = match ($providerName) { - 'sentry' => ['key' => $loggingProvider->getPassword(), 'projectId' => $loggingProvider->getUser() ?? '', 'host' => 'https://' . $loggingProvider->getHost()], - 'logowl' => ['ticket' => $loggingProvider->getUser() ?? '', 'host' => $loggingProvider->getHost()], - default => ['key' => $loggingProvider->getHost()], - }; - } catch (Throwable) { - $configChunks = \explode(";", ($providerConfig ?? '')); - - $providerConfig = match ($providerName) { - 'sentry' => ['key' => $configChunks[0], 'projectId' => $configChunks[1] ?? '', 'host' => '',], - 'logowl' => ['ticket' => $configChunks[0] ?? '', 'host' => ''], - default => ['key' => $providerConfig], - }; - } - - $logger = null; - - if (!empty($providerName) && is_array($providerConfig) && Logger::hasProvider($providerName)) { - $adapter = match ($providerName) { - 'sentry' => new Sentry($providerConfig['projectId'] ?? '', $providerConfig['key'] ?? '', $providerConfig['host'] ?? ''), - 'logowl' => new LogOwl($providerConfig['ticket'] ?? '', $providerConfig['host'] ?? ''), - 'raygun' => new Raygun($providerConfig['key'] ?? ''), - 'appsignal' => new AppSignal($providerConfig['key'] ?? ''), - default => throw new Exception('Provider "' . $providerName . '" not supported.') - }; - - $logger = new Logger($adapter); - } - - return $logger; -}); - -/** Resources */ -Http::setResource('log', function (?Route $route) { - $log = new Log(); - - $log->setNamespace("executor"); - $log->setEnvironment(Http::isProduction() ? Log::ENVIRONMENT_PRODUCTION : Log::ENVIRONMENT_STAGING); - - $version = (string) System::getEnv('OPR_EXECUTOR_VERSION', 'UNKNOWN'); - $log->setVersion($version); - - $server = System::getEnv('OPR_EXECUTOR_LOGGING_IDENTIFIER', \gethostname() ?: 'UNKNOWN'); - $log->setServer($server); - - if ($route) { - $log->addTag('method', $route->getMethod()); - $log->addTag('url', $route->getPath()); - } - - return $log; -}, ['route']); - -Http::setResource('register', fn () => $register); - -Http::setResource('logger', fn (Registry $register) => $register->get('logger'), ['register']); diff --git a/composer.json b/composer.json index 512aa52..4b2c21f 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,6 @@ "utopia-php/dsn": "0.2.*", "utopia-php/fetch": "0.4.*", "utopia-php/framework": "0.34.*", - "utopia-php/logger": "0.6.*", "utopia-php/orchestration": "0.19.*", "utopia-php/preloader": "0.2.*", "utopia-php/registry": "0.5.*", diff --git a/composer.lock b/composer.lock index 6a97cbf..0f69fcd 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "080e0d692db872b8b5254793956a2917", + "content-hash": "e210d16c714cdaf4f2628e234d2d52fe", "packages": [ { "name": "brick/math", @@ -2102,60 +2102,6 @@ }, "time": "2025-12-18T08:19:56+00:00" }, - { - "name": "utopia-php/logger", - "version": "0.6.2", - "source": { - "type": "git", - "url": "https://github.com/utopia-php/logger.git", - "reference": "25b5bd2ad8bb51292f76332faa7034644fd0941d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/utopia-php/logger/zipball/25b5bd2ad8bb51292f76332faa7034644fd0941d", - "reference": "25b5bd2ad8bb51292f76332faa7034644fd0941d", - "shasum": "" - }, - "require": { - "php": ">=8.0" - }, - "require-dev": { - "laravel/pint": "1.2.*", - "phpstan/phpstan": "1.9.x-dev", - "phpunit/phpunit": "^9.3", - "vimeo/psalm": "4.0.1" - }, - "type": "library", - "autoload": { - "psr-4": { - "Utopia\\Logger\\": "src/Logger" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Utopia Logger library is simple and lite library for logging information, such as errors or warnings. This library is aiming to be as simple and easy to learn and use.", - "keywords": [ - "appsignal", - "errors", - "framework", - "logger", - "logging", - "logs", - "php", - "raygun", - "sentry", - "upf", - "utopia", - "warnings" - ], - "support": { - "issues": "https://github.com/utopia-php/logger/issues", - "source": "https://github.com/utopia-php/logger/tree/0.6.2" - }, - "time": "2024-10-14T16:02:49+00:00" - }, { "name": "utopia-php/orchestration", "version": "0.19.0", diff --git a/docker-compose.yml b/docker-compose.yml index b5c2a55..6e8700a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -46,8 +46,6 @@ services: - OPR_EXECUTOR_MAINTENANCE_INTERVAL - OPR_EXECUTOR_NETWORK - OPR_EXECUTOR_SECRET - - OPR_EXECUTOR_LOGGING_PROVIDER - - OPR_EXECUTOR_LOGGING_CONFIG - OPR_EXECUTOR_DOCKER_HUB_USERNAME - OPR_EXECUTOR_DOCKER_HUB_PASSWORD - OPR_EXECUTOR_RUNTIME_VERSIONS diff --git a/src/Executor/Runner/Adapter.php b/src/Executor/Runner/Adapter.php index bca1b80..0b9c923 100644 --- a/src/Executor/Runner/Adapter.php +++ b/src/Executor/Runner/Adapter.php @@ -3,7 +3,6 @@ namespace OpenRuntimes\Executor\Runner; use Utopia\Http\Response; -use Utopia\Logger\Log; abstract class Adapter { @@ -11,10 +10,9 @@ abstract class Adapter * @param string $runtimeId * @param int $timeout * @param Response $response - * @param Log $log * @return void */ - abstract public function getLogs(string $runtimeId, int $timeout, Response $response, Log $log): void; + abstract public function getLogs(string $runtimeId, int $timeout, Response $response): void; /** * @param string $runtimeId @@ -40,7 +38,6 @@ abstract public function executeCommand(string $runtimeId, string $command, int * @param int $memory * @param string $version * @param string $restartPolicy - * @param Log $log * @return mixed */ abstract public function createRuntime( @@ -59,16 +56,14 @@ abstract public function createRuntime( int $memory, string $version, string $restartPolicy, - Log $log, string $region = '', ): mixed; /** * @param string $runtimeId - * @param Log $log * @return void */ - abstract public function deleteRuntime(string $runtimeId, Log $log): void; + abstract public function deleteRuntime(string $runtimeId): void; /** * @param string $runtimeId @@ -87,7 +82,6 @@ abstract public function deleteRuntime(string $runtimeId, Log $log): void; * @param string $runtimeEntrypoint * @param bool $logging * @param string $restartPolicy - * @param Log $log * @return mixed */ abstract public function createExecution( @@ -107,7 +101,6 @@ abstract public function createExecution( string $runtimeEntrypoint, bool $logging, string $restartPolicy, - Log $log, string $region = '', ): mixed; diff --git a/src/Executor/Runner/Docker.php b/src/Executor/Runner/Docker.php index 4f62277..a684e72 100644 --- a/src/Executor/Runner/Docker.php +++ b/src/Executor/Runner/Docker.php @@ -38,10 +38,9 @@ public function __construct( * @param string $runtimeId * @param int $timeout * @param Response $response - * @param Log $log * @return void */ - public function getLogs(string $runtimeId, int $timeout, Response $response, Log $log): void + public function getLogs(string $runtimeId, int $timeout, Response $response): void { $runtimeName = System::getHostname() . '-' . $runtimeId; @@ -234,7 +233,6 @@ public function executeCommand(string $runtimeId, string $command, int $timeout) * @param int $memory * @param string $version * @param string $restartPolicy - * @param Log $log * @return mixed */ public function createRuntime( @@ -253,7 +251,6 @@ public function createRuntime( int $memory, string $version, string $restartPolicy, - Log $log, string $region = '', ): mixed { $runtimeName = System::getHostname() . '-' . $runtimeId; @@ -540,10 +537,9 @@ public function createRuntime( /** * @param string $runtimeId - * @param Log $log * @return void */ - public function deleteRuntime(string $runtimeId, Log $log): void + public function deleteRuntime(string $runtimeId): void { $runtimeName = System::getHostname() . '-' . $runtimeId; @@ -572,7 +568,6 @@ public function deleteRuntime(string $runtimeId, Log $log): void * @param string $runtimeEntrypoint * @param bool $logging * @param string $restartPolicy - * @param Log $log * @return mixed * @throws Exception */ @@ -593,7 +588,6 @@ public function createExecution( string $runtimeEntrypoint, bool $logging, string $restartPolicy, - Log $log, string $region = '', ): mixed { $runtimeName = System::getHostname() . '-' . $runtimeId;