Symfony Options
In addition to the configuration available in the PHP SDK, there are some Symfony-specific options.
All configuration for Symfony is done in config/packages/sentry.yaml
.
config/packages/sentry.yaml
sentry:
dsn: "https://examplePublicKey@o0.ingest.sentry.io/0"
register_error_listener: true
options:
attach_stacktrace: true
before_breadcrumb: "sentry.callback.before_breadcrumb"
before_send: "sentry.callback.before_send"
capture_silenced_errors: false
context_lines: 5
default_integrations: true
enable_compression: true
environment: "%kernel.environment%"
error_types: "E_ALL & ~E_NOTICE"
http_proxy: "10.0.0.12:3456"
in_app_exclude:
- "%kernel.build_dir%"
- "%kernel.cache_dir%"
- "%kernel.project_dir%/vendor"
integrations:
- "sentry.integration.my_custom_integration"
logger: "php"
max_breadcrumbs: 50
max_value_length: 2048
prefixes:
- "/local_dir/"
release: "abcde12345"
sample_rate: 1
traces_sample_rate: 0
traces_sampler: "sentry.callback.traces_sampler"
send_attempts: 3
send_default_pii: false
server_name: "www.example.com"
tags:
tag1: "value1"
tag2: "value2"
The
test
and dev
environments.All the possible configurations under the options
key map directly to the correspondent options from the base SDK;
you can read more about those in the general configuration docs.
Below you can find additional documentation that is specific to the bundle usage, or information about the sensible default values that you can use in some cases.
environment
The environment
option defaults to the same environment of your Symfony application.
in_app_exclude
The in_app_exclude
option is used to mark files as non belonging to your app's source code in events' stack traces.
In this bundle it has three default values:
%kernel.build_dir%
, to exclude Symfony's build dir%kernel.cache_dir%
, to exclude Symfony's cache dir%kernel.project_dir%/vendor
, to exclude Composer's dependencies
Callables
The before_breadcrumb
, before_send
, before_send_transaction
and traces_sampler
options accept a callable
; so, you cannot provide it directly through
a YAML file. The bundle accepts a service reference, which you can build in your DIC container like this:
config/packages/sentry.yaml
sentry:
options:
before_send: 'sentry.callback.before_send'
services:
sentry.callback.before_send:
class: 'App\Service\Sentry'
factory: [ '@App\Service\Sentry', 'getBeforeSend' ]
The service needed for the before_breadcrumb
option can be implemented as follows:
src/Service/Sentry.php
<?php
namespace App\Service;
class Sentry
{
public function getBeforeSend(): callable
{
return function(\Sentry\Event $event, ?\Sentry\EventHint $hint): ?\Sentry\Event {
return $event;
};
}
}
Exclude Some Exceptions
This example shows how to ignore not found exceptions, but you can ignore any exception you want.
- Declare the integrations:
config/packages/sentry.yaml
sentry:
options:
integrations:
- 'Sentry\Integration\IgnoreErrorsIntegration'
- Configure the list of ignored exceptions:
config/services.yaml
services:
Sentry\Integration\IgnoreErrorsIntegration:
arguments:
$options:
ignore_exceptions:
- Symfony\Component\HttpKernel\Exception\NotFoundHttpException
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) to suggesting an update ("yeah, this would be better").
- Package:
- composer:sentry/sentry-symfony
- Version:
- 4.11.0
- Repository:
- https://github.com/getsentry/sentry-symfony