Skip to content

Commit 8290c8f

Browse files
committed
chore: remove logging
1 parent be8e6b7 commit 8290c8f

File tree

10 files changed

+12
-219
lines changed

10 files changed

+12
-219
lines changed

.env

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ OPR_EXECUTOR_MAINTENANCE_INTERVAL=60
66
OPR_EXECUTOR_NETWORK=executor_runtimes
77
OPR_EXECUTOR_IMAGE=executor-local
88
OPR_EXECUTOR_SECRET=executor-secret-key
9-
OPR_EXECUTOR_LOGGING_PROVIDER=
10-
OPR_EXECUTOR_LOGGING_CONFIG=
11-
OPR_EXECUTOR_LOGGING_IDENTIFIER=
129
OPR_EXECUTOR_DOCKER_HUB_USERNAME=
1310
OPR_EXECUTOR_DOCKER_HUB_PASSWORD=
1411
OPR_EXECUTOR_RUNTIME_VERSIONS=v2,v5

README.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ services:
5555
- OPR_EXECUTOR_MAINTENANCE_INTERVAL
5656
- OPR_EXECUTOR_NETWORK
5757
- OPR_EXECUTOR_SECRET
58-
- OPR_EXECUTOR_LOGGING_PROVIDER
59-
- OPR_EXECUTOR_LOGGING_CONFIG
6058
- OPR_EXECUTOR_DOCKER_HUB_USERNAME
6159
- OPR_EXECUTOR_DOCKER_HUB_PASSWORD
6260
- OPR_EXECUTOR_RUNTIME_VERSIONS
@@ -85,9 +83,6 @@ OPR_EXECUTOR_INACTIVE_THRESHOLD=60
8583
OPR_EXECUTOR_MAINTENANCE_INTERVAL=60
8684
OPR_EXECUTOR_NETWORK=openruntimes-runtimes
8785
OPR_EXECUTOR_SECRET=executor-secret-key
88-
OPR_EXECUTOR_LOGGING_PROVIDER=
89-
OPR_EXECUTOR_LOGGING_CONFIG=
90-
OPR_EXECUTOR_LOGGING_IDENTIFIER=
9186
OPR_EXECUTOR_DOCKER_HUB_USERNAME=
9287
OPR_EXECUTOR_DOCKER_HUB_PASSWORD=
9388
OPR_EXECUTOR_RUNTIME_VERSIONS=v5
@@ -197,8 +192,6 @@ docker compose down
197192
| OPR_EXECUTOR_MAINTENANCE_INTERVAL| Interval (in seconds) at which the Executor performs maintenance tasks, ex: `60` |
198193
| OPR_EXECUTOR_NETWORK | Network used by the executor for runtimes, ex: `openruntimes-runtimes` |
199194
| OPR_EXECUTOR_SECRET | Secret key used by the executor for authentication |
200-
| OPR_EXECUTOR_LOGGING_PROVIDER | Deprecated: use `OPR_EXECUTOR_LOGGING_CONFIG` with DSN instead. External logging provider used by the executor, ex: `sentry` |
201-
| OPR_EXECUTOR_LOGGING_CONFIG | External logging provider DSN used by the executor, ex: `sentry://PROJECT_ID:SENTRY_API_KEY@SENTRY_HOST/` |
202195
| OPR_EXECUTOR_DOCKER_HUB_USERNAME | Username for Docker Hub authentication (if applicable) |
203196
| OPR_EXECUTOR_DOCKER_HUB_PASSWORD | Password for Docker Hub authentication (if applicable) |
204197
| OPR_EXECUTOR_RUNTIME_VERSIONS | Version tag for runtime environments, ex: `v5` |

app/controllers.php

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use OpenRuntimes\Executor\Exception;
66
use OpenRuntimes\Executor\BodyMultipart;
77
use OpenRuntimes\Executor\Runner\Adapter as Runner;
8-
use Utopia\Logger\Log;
98
use Utopia\System\System;
109
use Utopia\Http\Http;
1110
use Utopia\Http\Request;
@@ -25,15 +24,14 @@
2524
->param('runtimeId', '', new Text(64), 'Runtime unique ID.')
2625
->param('timeout', '600', new Text(16), 'Maximum logs timeout.', true)
2726
->inject('response')
28-
->inject('log')
2927
->inject('runner')
30-
->action(function (string $runtimeId, string $timeoutStr, Response $response, Log $log, Runner $runner) {
28+
->action(function (string $runtimeId, string $timeoutStr, Response $response, Runner $runner) {
3129
$timeout = \intval($timeoutStr);
3230

3331
$response->sendHeader('Content-Type', 'text/event-stream');
3432
$response->sendHeader('Cache-Control', 'no-cache');
3533

36-
$runner->getLogs($runtimeId, $timeout, $response, $log);
34+
$runner->getLogs($runtimeId, $timeout, $response);
3735

3836
$response->end();
3937
});
@@ -69,9 +67,8 @@
6967
->param('version', 'v5', new WhiteList(\explode(',', System::getEnv('OPR_EXECUTOR_RUNTIME_VERSIONS', 'v5') ?? 'v5')), 'Runtime Open Runtime version.', true)
7068
->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)
7169
->inject('response')
72-
->inject('log')
7370
->inject('runner')
74-
->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) {
71+
->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) {
7572
$secret = \bin2hex(\random_bytes(16));
7673

7774
/**
@@ -105,7 +102,7 @@
105102

106103
$variables = array_map(fn ($v) => strval($v), $variables);
107104

108-
$container = $runner->createRuntime($runtimeId, $secret, $image, $entrypoint, $source, $destination, $variables, $runtimeEntrypoint, $command, $timeout, $remove, $cpus, $memory, $version, $restartPolicy, $log);
105+
$container = $runner->createRuntime($runtimeId, $secret, $image, $entrypoint, $source, $destination, $variables, $runtimeEntrypoint, $command, $timeout, $remove, $cpus, $memory, $version, $restartPolicy);
109106
$response->setStatusCode(Response::STATUS_CODE_CREATED)->json($container);
110107
});
111108

@@ -134,10 +131,9 @@
134131
->desc('Delete a runtime')
135132
->param('runtimeId', '', new Text(64), 'Runtime unique ID.')
136133
->inject('response')
137-
->inject('log')
138134
->inject('runner')
139-
->action(function (string $runtimeId, Response $response, Log $log, Runner $runner) {
140-
$runner->deleteRuntime($runtimeId, $log);
135+
->action(function (string $runtimeId, Response $response, Runner $runner) {
136+
$runner->deleteRuntime($runtimeId);
141137
$response->setStatusCode(Response::STATUS_CODE_OK)->send();
142138
});
143139

@@ -165,7 +161,6 @@
165161
->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)
166162
->inject('response')
167163
->inject('request')
168-
->inject('log')
169164
->inject('runner')
170165
->action(
171166
function (
@@ -187,7 +182,6 @@ function (
187182
string $restartPolicy,
188183
Response $response,
189184
Request $request,
190-
Log $log,
191185
Runner $runner
192186
) {
193187
// Extra parsers and validators to support both JSON and multipart
@@ -258,7 +252,6 @@ function (
258252
$runtimeEntrypoint,
259253
$logging,
260254
$restartPolicy,
261-
$log
262255
);
263256

264257
// Backwards compatibility for headers

app/error.php

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,14 @@
11
<?php
22

33
use OpenRuntimes\Executor\Exception;
4-
use Utopia\Console;
54
use Utopia\Http\Http;
6-
use Utopia\Logger\Log;
7-
use Utopia\Logger\Logger;
85
use Utopia\Http\Response;
96
use Utopia\System\System;
107

11-
function logError(Log $log, Throwable $error, ?Logger $logger = null): void
12-
{
13-
Console::error('[Error] Type: ' . get_class($error));
14-
Console::error('[Error] Message: ' . $error->getMessage());
15-
Console::error('[Error] File: ' . $error->getFile());
16-
Console::error('[Error] Line: ' . $error->getLine());
17-
18-
if ($logger === null) {
19-
return;
20-
}
21-
22-
// Log everything, except those explicitly marked as not loggable
23-
if ($error instanceof Exception && !$error->isPublishable()) {
24-
return;
25-
}
26-
27-
try {
28-
$log->setType(Log::TYPE_ERROR);
29-
$log->setMessage($error->getMessage());
30-
$log->setAction("httpError");
31-
$log->addTag('code', \strval($error->getCode()));
32-
$log->addTag('verboseType', get_class($error));
33-
$log->addExtra('file', $error->getFile());
34-
$log->addExtra('line', $error->getLine());
35-
$log->addExtra('trace', $error->getTraceAsString());
36-
37-
$status = $logger->addLog($log);
38-
39-
Console::info("Pushed log with response status code: $status");
40-
} catch (\Throwable $e) {
41-
Console::error("Failed to push log: {$e->getMessage()}");
42-
}
43-
}
44-
458
Http::error()
469
->inject('error')
47-
->inject('logger')
4810
->inject('response')
49-
->inject('log')
50-
->action(function (Throwable $error, ?Logger $logger, Response $response, Log $log) {
51-
logError($log, $error, $logger);
52-
11+
->action(function (Throwable $error, Response $response) {
5312
// Show all Executor\Exceptions, or everything if in development
5413
$public = $error instanceof Exception || Http::isDevelopment();
5514
$exception = $public ? $error : new Exception(Exception::GENERAL_UNKNOWN);

app/init.php

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,8 @@
11
<?php
22

33
use Utopia\Config\Config;
4-
use Utopia\Logger\Log;
5-
use Utopia\Logger\Logger;
6-
use Utopia\Logger\Adapter\AppSignal;
7-
use Utopia\Logger\Adapter\LogOwl;
8-
use Utopia\Logger\Adapter\Raygun;
9-
use Utopia\Logger\Adapter\Sentry;
10-
use Utopia\DSN\DSN;
11-
use Utopia\Http\Http;
12-
use Utopia\Http\Route;
13-
use Utopia\Registry\Registry;
14-
use Utopia\System\System;
154

165
const MAX_LOG_SIZE = 5 * 1024 * 1024;
176
const MAX_BUILD_LOG_SIZE = 1 * 1000 * 1000;
187

198
Config::load('errors', __DIR__ . '/config/errors.php');
20-
21-
// Setup Registry
22-
$register = new Registry();
23-
24-
$register->set('logger', function () {
25-
$providerName = System::getEnv('OPR_EXECUTOR_LOGGING_PROVIDER', '');
26-
$providerConfig = System::getEnv('OPR_EXECUTOR_LOGGING_CONFIG', '');
27-
28-
try {
29-
$loggingProvider = new DSN($providerConfig ?? '');
30-
31-
$providerName = $loggingProvider->getScheme();
32-
$providerConfig = match ($providerName) {
33-
'sentry' => ['key' => $loggingProvider->getPassword(), 'projectId' => $loggingProvider->getUser() ?? '', 'host' => 'https://' . $loggingProvider->getHost()],
34-
'logowl' => ['ticket' => $loggingProvider->getUser() ?? '', 'host' => $loggingProvider->getHost()],
35-
default => ['key' => $loggingProvider->getHost()],
36-
};
37-
} catch (Throwable) {
38-
$configChunks = \explode(";", ($providerConfig ?? ''));
39-
40-
$providerConfig = match ($providerName) {
41-
'sentry' => ['key' => $configChunks[0], 'projectId' => $configChunks[1] ?? '', 'host' => '',],
42-
'logowl' => ['ticket' => $configChunks[0] ?? '', 'host' => ''],
43-
default => ['key' => $providerConfig],
44-
};
45-
}
46-
47-
$logger = null;
48-
49-
if (!empty($providerName) && is_array($providerConfig) && Logger::hasProvider($providerName)) {
50-
$adapter = match ($providerName) {
51-
'sentry' => new Sentry($providerConfig['projectId'] ?? '', $providerConfig['key'] ?? '', $providerConfig['host'] ?? ''),
52-
'logowl' => new LogOwl($providerConfig['ticket'] ?? '', $providerConfig['host'] ?? ''),
53-
'raygun' => new Raygun($providerConfig['key'] ?? ''),
54-
'appsignal' => new AppSignal($providerConfig['key'] ?? ''),
55-
default => throw new Exception('Provider "' . $providerName . '" not supported.')
56-
};
57-
58-
$logger = new Logger($adapter);
59-
}
60-
61-
return $logger;
62-
});
63-
64-
/** Resources */
65-
Http::setResource('log', function (?Route $route) {
66-
$log = new Log();
67-
68-
$log->setNamespace("executor");
69-
$log->setEnvironment(Http::isProduction() ? Log::ENVIRONMENT_PRODUCTION : Log::ENVIRONMENT_STAGING);
70-
71-
$version = (string) System::getEnv('OPR_EXECUTOR_VERSION', 'UNKNOWN');
72-
$log->setVersion($version);
73-
74-
$server = System::getEnv('OPR_EXECUTOR_LOGGING_IDENTIFIER', \gethostname() ?: 'UNKNOWN');
75-
$log->setServer($server);
76-
77-
if ($route) {
78-
$log->addTag('method', $route->getMethod());
79-
$log->addTag('url', $route->getPath());
80-
}
81-
82-
return $log;
83-
}, ['route']);
84-
85-
Http::setResource('register', fn () => $register);
86-
87-
Http::setResource('logger', fn (Registry $register) => $register->get('logger'), ['register']);

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
"utopia-php/dsn": "0.2.*",
2626
"utopia-php/fetch": "0.4.*",
2727
"utopia-php/framework": "0.34.*",
28-
"utopia-php/logger": "0.6.*",
2928
"utopia-php/orchestration": "0.19.*",
3029
"utopia-php/preloader": "0.2.*",
3130
"utopia-php/registry": "0.5.*",

composer.lock

Lines changed: 1 addition & 55 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docker-compose.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ services:
4646
- OPR_EXECUTOR_MAINTENANCE_INTERVAL
4747
- OPR_EXECUTOR_NETWORK
4848
- OPR_EXECUTOR_SECRET
49-
- OPR_EXECUTOR_LOGGING_PROVIDER
50-
- OPR_EXECUTOR_LOGGING_CONFIG
5149
- OPR_EXECUTOR_DOCKER_HUB_USERNAME
5250
- OPR_EXECUTOR_DOCKER_HUB_PASSWORD
5351
- OPR_EXECUTOR_RUNTIME_VERSIONS

0 commit comments

Comments
 (0)