Skip to content

Refactor the bundle configuration and add support for XML format #401

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jan 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
- [BC BREAK] Removed the `options.project_root` configuration option. Instead of setting it, use a combination of `options.in_app_include` and `options.in_app_exclude` (#385)
- [BC BREAK] Removed the `options.excluded_exceptions` configuration option. Instead of setting it, configure the `IgnoreErrorsIntegration` integration (#385)
- [BC BREAK] Refactorized the `ConsoleCommandListener`, `ErrorListener`, `RequestListener` and `SubRequestListener` event listeners (#387)
- CLI commands registration policy changed to lazy load
- Registered the CLI commands as lazy services (#373)
- [BC BREAK] Refactorized the configuration tree and the definitions of some container services (#401)
- Support the XML format for the bundle configuration (#401)
- PHP 8 support (#399, thanks to @Yozhef)

## 3.5.3 (2020-10-13)
Expand Down
42 changes: 7 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,44 +159,16 @@ composer require pugx/sentry-sdk
```

## Maintained versions
* 3.x is actively maintained and developed on the master branch, and uses Sentry SDK 2.0;
* 2.x is supported only for fixes; from this version onwards it requires Symfony 3+ and PHP 7.1+;

* 4.x is actively maintained and developed on the master branch, and uses Sentry SDK 3.0;
* 3.x is supported only for fixes and uses Sentry SDK 2.0;
* 2.x is no longer maintained; from this version onwards it requires Symfony 3+ and PHP 7.1+;
* 1.x is no longer maintained; you can use it for Symfony < 2.8 and PHP 5.6/7.0;
* 0.8.x is no longer maintained.

### Upgrading to 3.0
The 3.0 version of the bundle uses the newest version (2.x) of the underlying Sentry SDK. If you need to migrate from previous versions, please check the `UPGRADE-3.0.md` document.

## Customization

The Sentry 2.0 SDK uses the Unified API, hence it uses the concept of `Scope`s to hold information about the current
state of the app, and attach it to any event that is reported. This bundle has three listeners (`RequestListener`,
`SubRequestListener` and `ConsoleListener`) that adds some easy default information. Since 3.5, a fourth listener has been added to handle the case of Messenger Workers: `MessengerListener`.

Those listeners normally are executed with a priority of `1` to allow easier customization with custom listener, that by
default run with a lower priority of `0`.

Those listeners are `final` so not extendable, but you can look at those to know how to add more information to the
current `Scope` and enrich you Sentry events.


#### Services configuration
### Upgrading to 4.0

Services registered by the bundle (the `ClientBuilder` in the example below) can be configured in several ways, one of them is by using a [compiler pass](https://symfony.com/doc/current/service_container/compiler_passes.html):

```php
final class SentryCustomizationCompilerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $containerBuilder): void
{
// Example - setting own serializer to Sentry\ClientBuilder
$containerBuilder->getDefinition(ClientBuilderInterface::class)
->addMethodCall('setSerializer', [
new Reference(MyCustomSerializer::class),
]);
}
}
```
The 4.0 version of the bundle uses the newest version (3.x) of the underlying Sentry SDK. If you need to migrate from previous versions, please check the `UPGRADE-4.0.md` document.

#### Custom serializers

Expand All @@ -205,7 +177,7 @@ The option class_serializers can be used to send customized objects serializatio
sentry:
options:
class_serializers:
YourValueObject: '@ValueObjectSerializer'
YourValueObject: 'ValueObjectSerializer'
```

Several serializers can be added and the serializable check is done using **instanceof**. The serializer must implements the `__invoke` method returning an **array** with the information to send to sentry (class name is always sent).
Expand Down
121 changes: 120 additions & 1 deletion UPGRADE-4.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
- Renamed the `RequestListener::onKernelController` method to `RequestListener::handleKernelControllerEvent`.
- Renamed the `SubRequestListener::onKernelRequest` method to `SubRequestListener::handleKernelRequestEvent`.
- Renamed the `SubRequestListener::onKernelFinishRequest` method to `SubRequestListener::handleKernelFinishRequestEvent`.
- Removed the `sentry.listener_priorities.console` configuration option.
- Removed the `Sentry\FlushableClientInterface` service alias.
- Removed the `sentry.options.excluded_exceptions` configuration option.

Expand Down Expand Up @@ -41,3 +40,123 @@

- Changed the default value of the `sentry.listener_priorities.console_error` configuration option to `-64`.
- Changed the default value of the `sentry.listener_priorities.console` configuration option to `128`.
- Changed the default value of the `sentry.listener_priorities.worker_error` configuration option to `50`.
- Changed the type of the `sentry.options.before_send` configuration option from `scalar` to `string`. The value must always be the name of the container service to call without the `@` prefix.

Before

```yaml
sentry:
options:
before_send: '@app.sentry.before_send'
```

```yaml
sentry:
options:
before_send: 'App\Sentry\BeforeSend::__invoke'
```

```yaml
sentry:
options:
before_send: ['App\Sentry\BeforeSend', '__invoke']
```

After

```yaml
sentry:
options:
before_send: 'app.sentry.before_send'
```

- Changed the type of the `sentry.options.before_breadcrumb` configuration option from `scalar` to `string`. The value must always be the name of the container service to call without the `@` prefix.

Before

```yaml
sentry:
options:
before_breadcrumb: '@app.sentry.before_breadcrumb'
```

```yaml
sentry:
options:
before_breadcrumb: 'App\Sentry\BeforeBreadcrumb::__invoke'
```

```yaml
sentry:
options:
before_breadcrumb: ['App\Sentry\BeforeBreadcrumb', '__invoke']
```

After

```yaml
sentry:
options:
before_send: 'app.sentry.before_breadcrumb'
```

- Changed the type of the `sentry.options.class_serializers` configuration option from an array of `scalar` values to an array of `string` values. The value must always be the name of the container service to call without the `@` prefix.

Before

```yaml
sentry:
options:
class_serializers:
App\FooClass: '@app.sentry.foo_class_serializer'
```

```yaml
sentry:
options:
class_serializers:
App\FooClass: 'App\Sentry\FooClassSerializer::__invoke'
```

```yaml
sentry:
options:
class_serializers:
App\FooClass: ['App\Sentry\FooClassSerializer', 'invoke']
```

After

```yaml
sentry:
options:
class_serializers:
App\FooClass: 'app.sentry.foo_class_serializer'
```

- Changed the type of the `sentry.options.integrations` configuration option from an array of `scalar` values to an array of `string` values. The value must always be the name of the container service to call without the `@` prefix.

Before

```yaml
sentry:
options:
integrations:
- '@app.sentry.foo_integration'
```

After

```yaml
sentry:
options:
integrations:
- 'app.sentry.foo_integration'
```

- Removed the `ClientBuilderConfigurator` class.
- Removed the `SentryBundle::getSdkVersion()` method.
- Removed `SentryBundle::getCurrentHub()` method, use `SentrySdk::getCurrentHub()` instead.
- Removed the `Sentry\ClientBuilderInterface` and `Sentry\Options` services.
- Refactorized the `ErrorTypesParser` class and made it `@internal`.
23 changes: 12 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@
"require": {
"php": "^7.2||^8.0",
"jean85/pretty-package-versions": "^1.5",
"sentry/sdk": "^3.0",
"symfony/config": "^3.4||^4.0||^5.0",
"symfony/console": "^3.4||^4.0||^5.0",
"symfony/dependency-injection": "^3.4||^4.0||^5.0",
"symfony/event-dispatcher": "^3.4||^4.0||^5.0",
"symfony/http-kernel": "^3.4||^4.0||^5.0",
"symfony/security-core": "^3.4||^4.0||^5.0"
"php-http/discovery": "^1.11",
"sentry/sdk": "^3.1",
"symfony/config": "^3.4.43||^4.4.11||^5.0.11",
"symfony/console": "^3.4.43||^4.4.11||^5.0.11",
"symfony/dependency-injection": "^3.4.43||^4.4.11||^5.0.11",
"symfony/event-dispatcher": "^3.4.43||^4.4.11||^5.0.11",
"symfony/http-kernel": "^3.4.43||^4.4.11||^5.0.11",
"symfony/security-core": "^3.4.43||^4.4.11||^5.0.11"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.16",
Expand All @@ -39,12 +40,12 @@
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
"phpunit/phpunit": "^8.5||^9.0",
"symfony/browser-kit": "^3.4||^4.0||^5.0",
"symfony/framework-bundle": "^3.4.23||^4.0||^5.0",
"symfony/messenger": "^4.3||^5.0",
"symfony/browser-kit": "^3.4.43||^4.4.11||^5.0.11",
"symfony/framework-bundle": "^3.4.43||^4.4.11||^5.0.11",
"symfony/messenger": "^4.4.11||^5.0.11",
"symfony/monolog-bundle": "^3.4",
"symfony/phpunit-bridge": "^5.0",
"symfony/yaml": "^3.4||^4.0||^5.0"
"symfony/yaml": "^3.4.43||^4.4.11||^5.0.11"
},
"suggest": {
"monolog/monolog": "Allow sending log messages to Sentry by using the included Monolog handler."
Expand Down
Loading