Integrations
Learn about the automatic integrations Sentry provides and how to configure them.
These integrations are enabled by default and integrate into the 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.
To disable system integrations in Symfony, set options.default_integrations: false
in your bundle configuration:
config/packages/sentry.yaml
sentry:
options:
default_integrations: false
This integration catches all global uncaught exceptions and emits events when an error occurs.
To do so, it ensures that Sentry's ErrorHandler
is registered, and adds a callback to it as an exception listener.
This integration hooks into the global PHP error_handler
and emits events when an error occurs.
To do so, it ensures 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
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.
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(...)
:
// The amount of reserved memory every request (in bytes), this has to be a positive integer amount of bytes. Defaults to 16 KiB
$errorHandler = \Sentry\ErrorHandler::registerOnceFatalErrorHandler(16 * 1024);
// The amount of memory in bytes to increase the `memory_limit` to when handling a out of memory error, can also be set to `null` to disable increasing the `memory_limit`. Defaults to 5 MiB
$errorHandler->setMemoryLimitIncreaseOnOutOfMemoryErrorInBytes(5 * 1024 * 1024);
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.
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.
This integration catches all fatal errors and emits the corresponding events.
To do so, it ensures that Sentry's ErrorHandler
is registered, and adds a callback to it as a fatal error listener.
This integration adds to the event request data:
- HTTP method
- URL (including the query string)
- Body (by default only if the body is 10Kb or less)
If the send_default_pii option is enabled, it will also send the following PII:
- IP address
- Cookies
- Headers
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.
This integration reads excerpts of code around the line that originated an error.
This integration fills the event data with PHP runtime and server OS information.
This integration logs all the versions of the packages installed with Composer with the event details; the root project is also included.
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
.
config/packages/sentry.yaml
sentry:
options:
integrations:
- "sentry.integration.my_custom_integration"
Register your integration as a service:
config/services.yaml
services:
sentry.integration.my_custom_integration:
class: App\Sentry\Integration\MyCustomIntegration
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
.
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.
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").