Compare commits
2 Commits
acd9bfc2b3
...
cf08d21e50
Author | SHA1 | Date | |
---|---|---|---|
cf08d21e50 | |||
a618f27890 |
4
.env
4
.env
@ -18,3 +18,7 @@
|
|||||||
APP_ENV=dev
|
APP_ENV=dev
|
||||||
APP_SECRET=f27f6cb11fb594fcb5ab4591ec0aac77
|
APP_SECRET=f27f6cb11fb594fcb5ab4591ec0aac77
|
||||||
###< symfony/framework-bundle ###
|
###< symfony/framework-bundle ###
|
||||||
|
|
||||||
|
###> sentry/sentry-symfony ###
|
||||||
|
SENTRY_DSN=
|
||||||
|
###< sentry/sentry-symfony ###
|
||||||
|
@ -3,3 +3,4 @@ TODO:
|
|||||||
- [ ] Chybí speciální slovník nebo vypnutí slovníku pro testy
|
- [ ] Chybí speciální slovník nebo vypnutí slovníku pro testy
|
||||||
- [ ] V reálný aplikaci bych použil Mockery, nicméně tady mě to přijde zbytečný
|
- [ ] V reálný aplikaci bych použil Mockery, nicméně tady mě to přijde zbytečný
|
||||||
- [ ] Nastavení cache ideálně v memcached/redis etc.
|
- [ ] Nastavení cache ideálně v memcached/redis etc.
|
||||||
|
- [ ] Vylepsit OTEL logs
|
||||||
|
@ -13,11 +13,13 @@
|
|||||||
"nyholm/psr7": "*",
|
"nyholm/psr7": "*",
|
||||||
"open-telemetry/exporter-otlp": "^1.0",
|
"open-telemetry/exporter-otlp": "^1.0",
|
||||||
"open-telemetry/opentelemetry-auto-symfony": "^1.0@beta",
|
"open-telemetry/opentelemetry-auto-symfony": "^1.0@beta",
|
||||||
|
"open-telemetry/opentelemetry-logger-monolog": "^1.0",
|
||||||
"open-telemetry/opentelemetry-propagation-server-timing": "^0.0.1",
|
"open-telemetry/opentelemetry-propagation-server-timing": "^0.0.1",
|
||||||
"open-telemetry/opentelemetry-propagation-traceresponse": "^0.0.2",
|
"open-telemetry/opentelemetry-propagation-traceresponse": "^0.0.2",
|
||||||
"open-telemetry/sdk": "^1.0",
|
"open-telemetry/sdk": "^1.0",
|
||||||
"open-telemetry/transport-grpc": "^1.0",
|
"open-telemetry/transport-grpc": "^1.0",
|
||||||
"php-http/httplug": "*",
|
"php-http/httplug": "*",
|
||||||
|
"sentry/sentry-symfony": "^4.13",
|
||||||
"symfony/asset": "7.0.*",
|
"symfony/asset": "7.0.*",
|
||||||
"symfony/asset-mapper": "7.0.*",
|
"symfony/asset-mapper": "7.0.*",
|
||||||
"symfony/cache": "7.0.*",
|
"symfony/cache": "7.0.*",
|
||||||
|
1192
composer.lock
generated
1192
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -6,4 +6,5 @@ return [
|
|||||||
Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true],
|
Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true],
|
||||||
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
|
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
|
||||||
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
|
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
|
||||||
|
Sentry\SentryBundle\SentryBundle::class => ['prod' => true],
|
||||||
];
|
];
|
||||||
|
@ -5,6 +5,10 @@ monolog:
|
|||||||
when@dev:
|
when@dev:
|
||||||
monolog:
|
monolog:
|
||||||
handlers:
|
handlers:
|
||||||
|
otel:
|
||||||
|
type: service
|
||||||
|
id: App\Bridge\Monolog\Handler\SymfonyOtelHandler
|
||||||
|
|
||||||
main:
|
main:
|
||||||
type: stream
|
type: stream
|
||||||
path: "%kernel.logs_dir%/%kernel.environment%.log"
|
path: "%kernel.logs_dir%/%kernel.environment%.log"
|
||||||
|
26
config/packages/sentry.yaml
Normal file
26
config/packages/sentry.yaml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
when@prod:
|
||||||
|
sentry:
|
||||||
|
dsn: '%env(SENTRY_DSN)%'
|
||||||
|
# this hooks into critical paths of the framework (and vendors) to perform
|
||||||
|
# automatic instrumentation (there might be some performance penalty)
|
||||||
|
# https://docs.sentry.io/platforms/php/guides/symfony/performance/instrumentation/automatic-instrumentation/
|
||||||
|
tracing:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
# If you are using Monolog, you also need this additional configuration to log the errors correctly:
|
||||||
|
# https://docs.sentry.io/platforms/php/guides/symfony/#monolog-integration
|
||||||
|
# register_error_listener: false
|
||||||
|
# register_error_handler: false
|
||||||
|
|
||||||
|
# monolog:
|
||||||
|
# handlers:
|
||||||
|
# sentry:
|
||||||
|
# type: sentry
|
||||||
|
# level: !php/const Monolog\Logger::ERROR
|
||||||
|
# hub_id: Sentry\State\HubInterface
|
||||||
|
|
||||||
|
# Uncomment these lines to register a log message processor that resolves PSR-3 placeholders
|
||||||
|
# https://docs.sentry.io/platforms/php/guides/symfony/#monolog-integration
|
||||||
|
# services:
|
||||||
|
# Monolog\Processor\PsrLogMessageProcessor:
|
||||||
|
# tags: { name: monolog.processor, handler: sentry }
|
@ -45,6 +45,7 @@ services:
|
|||||||
$innerGenerator: '@App\Service\Remote\UsetrenoQRCodeProvider'
|
$innerGenerator: '@App\Service\Remote\UsetrenoQRCodeProvider'
|
||||||
$cacheDuration: 'PT60S'
|
$cacheDuration: 'PT60S'
|
||||||
|
|
||||||
|
|
||||||
App\Service\CurrencyListerInterface: '@App\Service\StaticCurrencyLister'
|
App\Service\CurrencyListerInterface: '@App\Service\StaticCurrencyLister'
|
||||||
App\Service\QRCodeQROptionsProviderInterface: '@App\Service\QRCodeQROptionsDefaultProvider'
|
App\Service\QRCodeQROptionsProviderInterface: '@App\Service\QRCodeQROptionsDefaultProvider'
|
||||||
App\Service\QRCodeGeneratorInterface: '@App\Service\CachedQRCodeGenerator'
|
App\Service\QRCodeGeneratorInterface: '@App\Service\CachedQRCodeGenerator'
|
||||||
|
@ -11,22 +11,40 @@ processors:
|
|||||||
actions:
|
actions:
|
||||||
- action: insert
|
- action: insert
|
||||||
key: loki.attribute.labels
|
key: loki.attribute.labels
|
||||||
value: log.file, log.line, log.module_path, http.request_id, http.uri
|
value: context, code.filepath, code.namespace, code.function, code.lineno, http.request.method, http.request.body.size, url.full, url.scheme, url.path, http.route, http.response.status_code
|
||||||
- action: insert
|
- action: insert
|
||||||
from_attribute: log.file
|
from_attribute: context
|
||||||
key: log.file
|
key: context
|
||||||
- action: insert
|
- action: insert
|
||||||
from_attribute: log.line
|
from_attribute: code.namespace
|
||||||
key: log.line
|
key: code.namespace
|
||||||
- action: insert
|
- action: insert
|
||||||
from_attribute: log.module_path
|
from_attribute: code.function
|
||||||
key: log.module_path
|
key: code.function
|
||||||
- action: insert
|
- action: insert
|
||||||
from_attribute: http.request_id
|
from_attribute: code.lineno
|
||||||
key: http.request_id
|
key: code.lineno
|
||||||
- action: insert
|
- action: insert
|
||||||
from_attribute: http.uri
|
from_attribute: http.request.method
|
||||||
key: http.uri
|
key: http.request.method
|
||||||
|
- action: insert
|
||||||
|
from_attribute: http.request.body.size
|
||||||
|
key: http.request.body.size
|
||||||
|
- action: insert
|
||||||
|
from_attribute: http.response.status_code
|
||||||
|
key: http.response.status_code
|
||||||
|
- action: insert
|
||||||
|
from_attribute: url.full
|
||||||
|
key: url.full
|
||||||
|
- action: insert
|
||||||
|
from_attribute: url.scheme
|
||||||
|
key: url.scheme
|
||||||
|
- action: insert
|
||||||
|
from_attribute: url.path
|
||||||
|
key: url.path
|
||||||
|
- action: insert
|
||||||
|
from_attribute: http.route
|
||||||
|
key: http.route
|
||||||
- action: insert
|
- action: insert
|
||||||
key: loki.format
|
key: loki.format
|
||||||
value: raw
|
value: raw
|
||||||
|
33
src/Bridge/Monolog/Handler/SymfonyOtelHandler.php
Normal file
33
src/Bridge/Monolog/Handler/SymfonyOtelHandler.php
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Bridge\Monolog\Handler;
|
||||||
|
|
||||||
|
use Monolog\Formatter\FormatterInterface;
|
||||||
|
use Monolog\Formatter\JsonFormatter;
|
||||||
|
use Monolog\Handler\AbstractHandler;
|
||||||
|
use Monolog\Handler\FormattableHandlerTrait;
|
||||||
|
use Monolog\LogRecord;
|
||||||
|
use OpenTelemetry\API\Globals;
|
||||||
|
use OpenTelemetry\Contrib\Logs\Monolog\Handler;
|
||||||
|
use Psr\Log\LogLevel;
|
||||||
|
use Symfony\Bridge\Monolog\Formatter\VarDumperFormatter;
|
||||||
|
|
||||||
|
final class SymfonyOtelHandler extends AbstractHandler
|
||||||
|
{
|
||||||
|
protected readonly Handler $innerHandler;
|
||||||
|
|
||||||
|
public function __construct() {
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
$this->innerHandler = new Handler(
|
||||||
|
Globals::loggerProvider(),
|
||||||
|
LogLevel::INFO, //or `Logger::INFO`, or `Level::Info` depending on monolog version
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handle(LogRecord $record): bool
|
||||||
|
{
|
||||||
|
return $this->innerHandler->handle($record);
|
||||||
|
}
|
||||||
|
}
|
17
src/Controller/ExceptionController.php
Normal file
17
src/Controller/ExceptionController.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used for testing error handling (sentry...)
|
||||||
|
*/
|
||||||
|
class ExceptionController extends AbstractController
|
||||||
|
{
|
||||||
|
#[Route("give-me-error-please/exception")]
|
||||||
|
public function makeException() {
|
||||||
|
throw new \InvalidArgumentException("There is exception");
|
||||||
|
}
|
||||||
|
}
|
12
symfony.lock
12
symfony.lock
@ -49,6 +49,18 @@
|
|||||||
"tests/bootstrap.php"
|
"tests/bootstrap.php"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"sentry/sentry-symfony": {
|
||||||
|
"version": "4.13",
|
||||||
|
"recipe": {
|
||||||
|
"repo": "github.com/symfony/recipes-contrib",
|
||||||
|
"branch": "main",
|
||||||
|
"version": "4.6",
|
||||||
|
"ref": "153de5f041f7e8a9c19f3674b800b76be0e6fd90"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"config/packages/sentry.yaml"
|
||||||
|
]
|
||||||
|
},
|
||||||
"symfony/asset-mapper": {
|
"symfony/asset-mapper": {
|
||||||
"version": "7.0",
|
"version": "7.0",
|
||||||
"recipe": {
|
"recipe": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user