-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
23 changed files
with
236 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ phpunit.xml | |
composer.lock | ||
bin/ | ||
var/ | ||
.phpunit.result.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# Upgrade from 1.x to 2.0 | ||
The `sentry/sentry-symfony` package is updated to ^4.0 which requires changes in the configuration if you use the recommended configuration: | ||
|
||
- Remove `sentry.monolog` configuration option | ||
|
||
Before: | ||
```yaml | ||
sentry: | ||
dsn: '%env(SENTRY_DSN)%' | ||
register_error_listener: false | ||
monolog: | ||
error_handler: | ||
enabled: true | ||
level: error | ||
options: | ||
environment: '%kernel.environment%' | ||
release: '%env(VERSION)%' # your app version, optional | ||
send_attempts: 1 | ||
``` | ||
After: | ||
```yaml | ||
sentry: | ||
dsn: '%env(SENTRY_DSN)%' | ||
register_error_listener: false | ||
options: | ||
environment: '%kernel.environment%' | ||
release: '%env(VERSION)%' # your app version, optional | ||
send_attempts: 1 | ||
``` | ||
- Update the sentry monolog handler to `paysera_logging_extra.sentry_handler` | ||
|
||
Before: | ||
```yaml | ||
monolog: | ||
handlers: | ||
... | ||
sentry: | ||
type: service | ||
id: Sentry\Monolog\Handler | ||
... | ||
``` | ||
|
||
After: | ||
```yaml | ||
monolog: | ||
handlers: | ||
... | ||
sentry: | ||
type: service | ||
id: paysera_logging_extra.sentry_handler | ||
... | ||
``` | ||
|
||
- Due to a bug in all versions below 6.0 of the SensioFrameworkExtraBundle bundle, you will likely receive an error during the building of symfony container related to the missing `Nyholm\Psr7\Factory\Psr17Factory` class. To workaround the issue, if you are not using the PSR-7 bridge, please change the configuration of that bundle as follows: | ||
|
||
```yaml | ||
sensio_framework_extra: | ||
psr_message: | ||
enabled: false | ||
``` | ||
|
||
For more details about the issue see https://github.com/sensiolabs/SensioFrameworkExtraBundle/pull/710. | ||
|
||
- The version of `sentry/sentry` was upgraded to ^3.0. If you're using self-hosted Sentry version < v20.6.0 then you should disable the tracing as it uses the envelope endpoint which requires Sentry version >= v20.6.0 to work. | ||
|
||
```yaml | ||
sentry: | ||
tracing: | ||
enabled: false | ||
``` | ||
|
||
Check the [UPGRADE-3.0.md](https://github.com/getsentry/sentry-php/blob/master/UPGRADE-3.0.md) file of `sentry/sentry` for other notable updates. | ||
Check the [UPGRADE-4.0.md](https://github.com/getsentry/sentry-symfony/blob/4.6.0/UPGRADE-4.0.md) file of `sentry/sentry-symfony` for other notable updates. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" ?> | ||
|
||
<container xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
|
||
<services> | ||
<service id="paysera_logging_extra.handler.sentry" | ||
class="Paysera\LoggingExtraBundle\Service\Handler\SentryExtraInformationHandler"> | ||
<argument type="service"> | ||
<service class="Sentry\Monolog\Handler"> | ||
<argument type="service" id="Sentry\State\HubInterface"/> | ||
<argument type="constant">Monolog\Logger::ERROR</argument> | ||
</service> | ||
</argument> | ||
</service> | ||
</services> | ||
</container> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Paysera\LoggingExtraBundle\Service\Handler; | ||
|
||
use Monolog\Handler\HandlerWrapper; | ||
use Monolog\Handler\ProcessableHandlerTrait; | ||
use Sentry\State\Scope; | ||
use function Sentry\withScope; | ||
|
||
final class SentryExtraInformationHandler extends HandlerWrapper | ||
{ | ||
use ProcessableHandlerTrait; | ||
|
||
public function handle(array $record): bool | ||
{ | ||
if (!$this->isHandling($record)) { | ||
return false; | ||
} | ||
|
||
$result = false; | ||
$record = $this->processRecord($record); | ||
|
||
$record['formatted'] = $this->getFormatter()->format($record); | ||
|
||
withScope(function (Scope $scope) use ($record, &$result): void { | ||
if (isset($record['context']['extra']) && \is_array($record['context']['extra'])) { | ||
foreach ($record['context']['extra'] as $key => $value) { | ||
$scope->setExtra((string) $key, $value); | ||
} | ||
} | ||
|
||
if (isset($record['context']['tags']) && \is_array($record['context']['tags'])) { | ||
foreach ($record['context']['tags'] as $key => $value) { | ||
$scope->setTag($key, $value); | ||
} | ||
} | ||
|
||
$result = $this->handler->handle($record); | ||
}); | ||
|
||
return $result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.