|
| 1 | +--- |
| 2 | +title: Integrations |
| 3 | +description: "Learn about the automatic integrations Sentry provides and how to configure them." |
| 4 | +sidebar_order: 500 |
| 5 | +--- |
| 6 | + |
| 7 | +## Default Integrations |
| 8 | + |
| 9 | +These integrations are enabled by default and integrate into the |
| 10 | +standard library or the interpreter itself. They are documented so you can be both aware of what they do and disable them if they cause issues. |
| 11 | + |
| 12 | +To disable system integrations in Symfony, set `options.default_integrations: false` in your bundle configuration: |
| 13 | + |
| 14 | +```yaml {filename:config/packages/sentry.yaml} |
| 15 | +sentry: |
| 16 | + options: |
| 17 | + default_integrations: false |
| 18 | +``` |
| 19 | +
|
| 20 | +### ExceptionListenerIntegration |
| 21 | +
|
| 22 | +This integration catches all global uncaught exceptions and emits events when an error occurs. |
| 23 | +
|
| 24 | +It does this by ensuring that Sentry's `ErrorHandler` is registered, and adds a callback to it as an exception listener. |
| 25 | + |
| 26 | +### ErrorListenerIntegration |
| 27 | + |
| 28 | +This integration hooks into the global PHP `error_handler` and emits events when an error occurs. |
| 29 | + |
| 30 | +It does this by ensuring that Sentry's `ErrorHandler` is registered, and adds a callback to it as an error listener. By default, the `ErrorHandler` reserves 16 KiB of memory to handle fatal errors. When handling out of memory errors, the `ErrorHandler` additionally increases the [`memory_limit`](https://www.php.net/manual/en/ini.core.php#ini.memory-limit) by an additional 5 MiB to have enough room to send the out of memory event to Sentry. This change is only done once and only affects the handling of the out of memory error. |
| 31 | + |
| 32 | +To change the amount of memory reserved for fatal error handling or the amount the `memory_limit` is increased when handling an out of memory error, you can register the fatal error handler yourself before calling `\Sentry\init(...)`: |
| 33 | + |
| 34 | +```php |
| 35 | +// The amount of reserved memory for every request (in bytes), this has to be a positive integer in bytes. Defaults to 16 KiB |
| 36 | +$errorHandler = \Sentry\ErrorHandler::registerOnceFatalErrorHandler(16 * 1024); |
| 37 | +// The amount of memory in bytes to increase the `memory_limit` to when handling an out of memory error. It can also be set to `null` to disable increasing the `memory_limit`. Defaults to 5 MiB |
| 38 | +$errorHandler->setMemoryLimitIncreaseOnOutOfMemoryErrorInBytes(5 * 1024 * 1024); |
| 39 | +``` |
| 40 | + |
| 41 | +For some frameworks or projects, specific integrations are provided both officially and by third-party users that automatically register the error handlers. Please refer to their documentation. |
| 42 | + |
| 43 | +By default, the error*types option defaults to the value returned by the `error_reporting()` function, which can change at runtime. Alternately, you can set the option to a fixed value by setting its value to a bitmask of the PHP `E*\*`constants in`\Sentry\init()`. In this case, Sentry will log only errors of those specific types regardless of the current reporting level. |
| 44 | + |
| 45 | +### FatalErrorListenerIntegration |
| 46 | + |
| 47 | +This integration catches all fatal errors and emits the corresponding events. |
| 48 | + |
| 49 | +It does this by ensuring that Sentry's `ErrorHandler` is registered, and adds a callback to it as a fatal error listener. |
| 50 | + |
| 51 | +### RequestIntegration |
| 52 | + |
| 53 | +This integration adds to the event request data: |
| 54 | + |
| 55 | +- HTTP method |
| 56 | +- URL (including the query string) |
| 57 | +- Body (only if the body is 10Kb or less) |
| 58 | + |
| 59 | +If the <PlatformLink to="/configuration/options/#send_default_pii">send_default_pii option</PlatformLink> is enabled, it will also send the following PII: |
| 60 | + |
| 61 | +- IP address |
| 62 | +- Cookies |
| 63 | +- Headers |
| 64 | + |
| 65 | +### TransactionIntegration |
| 66 | + |
| 67 | +This integration sets the `transaction` attribute of the event to the value found in the raw event payload or to the value of the `PATH_INFO` server var if present. |
| 68 | + |
| 69 | +### FrameContextifierIntegration |
| 70 | + |
| 71 | +This integration reads excerpts of code around the line that originated an error. |
| 72 | + |
| 73 | +### EnvironmentIntegration |
| 74 | + |
| 75 | +This integration fills the event data with PHP runtime and server OS information. |
| 76 | + |
| 77 | +### ModulesIntegration |
| 78 | + |
| 79 | +This integration logs all the versions of the packages installed with Composer with the event details; the root project is also included. |
| 80 | + |
| 81 | +## Custom Integrations |
| 82 | + |
| 83 | +You can customize the list of integrations without disabling the defaults by using the `options.integrations` setting in Symfony. Provide service IDs for classes implementing `\Sentry\Integration\IntegrationInterface`. |
| 84 | + |
| 85 | +```yaml {filename:config/packages/sentry.yaml} |
| 86 | +sentry: |
| 87 | + options: |
| 88 | + integrations: |
| 89 | + - "sentry.integration.my_custom_integration" |
| 90 | +``` |
| 91 | +
|
| 92 | +Register your integration as a service: |
| 93 | +
|
| 94 | +```yaml {filename:config/services.yaml} |
| 95 | +services: |
| 96 | + sentry.integration.my_custom_integration: |
| 97 | + class: App\Sentry\Integration\MyCustomIntegration |
| 98 | +``` |
| 99 | +
|
| 100 | +If you want to remove one or more default integrations, set `options.default_integrations: false` and then explicitly list the integrations you want to enable via `options.integrations`. |
| 101 | + |
| 102 | +### Use a Callback to Customize Integrations |
| 103 | + |
| 104 | +For advanced cases, you can provide a callback (service) instead of a fixed list to customize integrations. See how to reference callables in Symfony configuration here: [Callables in Symfony Options](/platforms/php/guides/symfony/configuration/symfony-options/#callables). |
0 commit comments