Laravel Options

All configuration for Laravel is done in config/sentry.php.

The Laravel integration will create breadcrumbs for certain events occurring in the framework, the capture of this information can be configured using the following options:

'breadcrumbs' => [
    // Capture Laravel logs in breadcrumbs
    'logs' => true,

    // Capture Laravel cache events in breadcrumbs
    'cache' => true,

    // Capture Livewire components in breadcrumbs
    'livewire' => true,

    // Capture SQL queries in breadcrumbs
    'sql_queries' => true,

    // Capture bindings on SQL queries logged in breadcrumbs
    'sql_bindings' => true,

    // Capture queue job information in breadcrumbs
    'queue_info' => true,

    // Capture command information in breadcrumbs
    'command_info' => true,

    // Capture HTTP client requests information in breadcrumbs
    'http_client_requests' => true,

Performance Monitoring

To enable performance monitoring, set this to a value greater than 0.0:

// Be sure to lower this in production to prevent quota issues
'traces_sample_rate' => 1.0,

Advanced Sample Rate

If you want more control over which requests are monitored, you can use the traces_sampler option:

'traces_sampler' => function (\Sentry\Tracing\SamplingContext $context): float {
    // We always sample if the front-end indicates it was sampled to have full traces front to back
    if ($context->getParentSampled()) {
        return 1.0;

    if (some_condition()) {
        // Drop this transaction, by setting its sample rate to 0
        return 0.0;

    // Default sample rate for all other transactions
    return 0.25;

More Configuration

You can also configure what is being monitored automatically. These settings have no effect if traces_sample_rate is set to 0.0:

'tracing' => [
    // Trace queue jobs as their own transactions
    'queue_job_transactions' => env('SENTRY_TRACE_QUEUE_ENABLED', false),

    // Capture queue jobs as spans when executed on the sync driver
    'queue_jobs' => true,

    // Capture SQL queries as spans
    'sql_queries' => true,

    // Try to find out where the SQL query originated from and add it to the query spans
    'sql_origin' => true,

    // Capture views as spans
    'views' => true,

    // Capture Livewire components as spans
    'livewire' => true,

    // Capture HTTP client requests as spans
    'http_client_requests' => true,

    // Capture Redis operations as spans (this enables Redis events in Laravel)
    'redis_commands' => env('SENTRY_TRACE_REDIS_COMMANDS', false),

    // Try to find out where the Redis command originated from and add it to the command spans
    'redis_origin' => true,

    // Indicates if the tracing integrations supplied by Sentry should be loaded
    // See all default integration:
    'default_integrations' => true,

    // Indicates that requests without a matching route should be traced
    'missing_routes' => false,

Controller Base Namespace

Performance monitoring and router breadcrumbs can report the controller classname that handled the request.

These names are generally longer than needed, that's why we strip away the base namespace that is the same for all controller classes.

In Laravel this is App\Http\Controllers by default but you can override this using the controllers_base_namespace option:

'controllers_base_namespace' => env('SENTRY_CONTROLLERS_BASE_NAMESPACE', 'App\\Http\\Controllers'),

Closures and Config Caching

Sometimes the SDK requires a closure as an option value. However, this causes problems when using php artisan config:cache, resulting in the Your configuration files are not serializable error.

We can work around that by providing a callable instead of a closure. In this example we are using the traces_sampler option, but this can be used for any other option that accepts a closure:

'traces_sampler' => [App\Exceptions\Sentry::class, 'tracesSampler'],

This callable points to the App\Exceptions\Sentry class and the tracesSampler method:


namespace App\Exceptions;

use Sentry\Tracing\SamplingContext;

class Sentry
    public static function tracesSampler(SamplingContext $context): float
        // The code you would have placed in the closure...
Help improve this content
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").