feat: add sentry

This commit is contained in:
Ondrej Vlach 2024-01-18 18:48:58 +01:00
parent a618f27890
commit 2940accc34
Signed by: ovlach
GPG Key ID: 4FF1A23B4914DE70
7 changed files with 1194 additions and 1 deletions

4
.env
View File

@ -18,3 +18,7 @@
APP_ENV=dev
APP_SECRET=f27f6cb11fb594fcb5ab4591ec0aac77
###< symfony/framework-bundle ###
###> sentry/sentry-symfony ###
SENTRY_DSN=https://ae24268aecd2759193ac7cced34bf543@o4506593513635840.ingest.sentry.io/4506593517830144
###< sentry/sentry-symfony ###

View File

@ -19,6 +19,7 @@
"open-telemetry/sdk": "^1.0",
"open-telemetry/transport-grpc": "^1.0",
"php-http/httplug": "*",
"sentry/sentry-symfony": "^4.13",
"symfony/asset": "7.0.*",
"symfony/asset-mapper": "7.0.*",
"symfony/cache": "7.0.*",

1134
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -6,4 +6,5 @@ return [
Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
Sentry\SentryBundle\SentryBundle::class => ['prod' => true],
];

View 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 }

View 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");
}
}

View File

@ -49,6 +49,18 @@
"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": {
"version": "7.0",
"recipe": {