sentry/sentry-laravel
Official Sentry SDK for Laravel. Automatically capture and report unhandled exceptions and performance data to Sentry, with seamless Laravel integration and configuration. Supports modern Laravel versions and includes tooling for monitoring errors in production.
The Sentry SDK team is happy to announce the immediate availability of Sentry Laravel SDK v4.25.0.
OTLPIntegration. (#1122)SentryTracesSampleRate job middleware to control trace sampling for individual jobs. (#1114)withExceptions(..) callbacks for unhandled console exceptions. (#1125)The Sentry SDK team is happy to announce the immediate availability of Sentry Laravel SDK v4.23.0.
strict_trace_continuation support to only continue incoming traces when the upstream baggage org_id matches the SDK org ID. (#1106)4.22.0 (#1106)The Sentry SDK team is happy to announce the immediate availability of Sentry Laravel SDK v4.21.1.
The Sentry SDK team is happy to announce the immediate availability of Sentry Laravel SDK v4.21.0.
sentry-trace and baggage headers (#1091)preg_quote for environment variables (#1093)4.21.0 (#1095)The Sentry SDK team is happy to announce the immediate availability of Sentry Laravel SDK v4.20.1.
symfony/psr-http-message-bridge dependency (#1076)The Sentry SDK team is happy to announce the immediate availability of Sentry Laravel SDK v4.20.0.
// Counter metric
\Sentry\trace_metrics()->count('test-counter', 10, ['my-attribute' => 'foo']);
// Gauge metric
\Sentry\trace_metrics()->gauge('test-gauge', 50.0, ['my-attribute' => 'foo'], \Sentry\Unit::millisecond());
// Distribution metric
\Sentry\trace_metrics()->distribution('test-distribution', 20.0, ['my-attribute' => 'foo'], \Sentry\Unit::kilobyte());
The Sentry SDK team is happy to announce the immediate availability of Sentry Laravel SDK v4.19.0.
Add Laravel Pennant feature flags (#1061)
The SDK will now automatically capture feature flags resolved using Laravel Pennant and attach them to events and spans.
The Sentry SDK team is happy to announce the immediate availability of Sentry Laravel SDK v4.18.0.
The Sentry SDK team is happy to announce the immediate availability of Sentry Laravel SDK v4.17.0.
Configuring the channel is no longer required. To enable logs for Sentry, the following environment variables need to be configured:
LOG_CHANNEL=stack
LOG_STACK=single,sentry_logs
SENTRY_ENABLE_LOGS=true
Sentry will use LOG_LEVEL to determine the minimum log level, but it's possible to overwrite it just for Sentry
using SENTRY_LOG_LEVEL.
LOG_LEVEL=info
SENTRY_LOG_LEVEL=warning
sentry.origin attribute to LogsHandler. (#1041)The Sentry SDK team is happy to announce the immediate availability of Sentry Laravel SDK v4.16.0.
The Sentry SDK team is happy to announce the immediate availability of Sentry Laravel SDK v4.15.3.
The Sentry SDK team is happy to announce the immediate availability of Sentry Laravel SDK v4.15.1.
4.14.1 (#1013)The Sentry SDK team is happy to announce the immediate availability of Sentry Laravel SDK v4.15.0.
Add support for Sentry Structured Logs (#1000)
To enable this feature, add the sentry_logs log channel in your config/logging.php configuration:
'channels' => [
...
'sentry_logs' => [
'driver' => 'sentry_logs',
'level' => env('LOG_LEVEL', 'info'),
],
...
],
Add SENTRY_ENABLE_LOGS=true to your .env file.
Use the Log facade to sent your logs to Sentry. To learn more, head over to the Laravel docs.
use Illuminate\Support\Facades\Log;
Log::channel('sentry_logs')->info('User {id} failed to login.', ['id' => $user->id]);
To learn more, head over to our docs.
The Sentry SDK team is happy to announce the immediate availability of Sentry Laravel SDK v4.14.1.
Ensure there is a newline before writing env variables (#1002)
Fixed an issue where the php artisan sentry:publish command might not properly add newlines when writing environment variables to the .env file.
The Sentry SDK team is happy to announce the immediate availability of Sentry Laravel SDK v4.14.0.
Fix tracing when using Laravel Octane (#997)
When using Laravel Octane, the SDK now correctly cleans up it's state after each request, ensuring that traces are correctly reported.
Add sentry prefix to publish group name (#992)
When running php artisan vendor:publish, the Sentry package exports are now prefixed with sentry, making it easier to distinguish from other packages.
Remove support for traceparent header (#994)
The W3C's traceparent header is no longer automatically picked up and emitted by the SDK to prevent non-Sentry SDKs from starting a trace that is unwanted.
The Sentry SDK team is happy to announce the immediate availability of Sentry Laravel SDK v4.13.0.
The Sentry SDK team is happy to announce the immediate availability of Sentry Laravel SDK v4.12.0.
Improve generation of slug for scheduled job cron monitoring (#977)
For scheduled jobs it's no longer needed to manually provide a slug to the ->sentryMonitor() call, it will be derived from the job class name.
Disable scheduled task tracing for backgrounded tasks (#975)
Backgrounded tasks show up a ~1ms transactions right now because we are effectively monitoring the time it takes to start the background process instead of the execution. We are working on a solution to this problem, but in the meantime, we are disabling the monitoring of backgrounded tasks (that was introduces in 4.11.0).
The Sentry SDK team is happy to announce the immediate availability of Sentry Laravel SDK v4.10.2.
php artisan sentry:test (#963)The Sentry SDK team is happy to announce the immediate availability of Sentry Laravel SDK v4.10.1.
The Sentry SDK team is happy to announce the immediate availability of Sentry Laravel SDK v4.7.1.
The Sentry SDK team is happy to announce the immediate availability of Sentry Laravel SDK v4.7.0.
Add support for Cache Insights Module (#914). To learn more about this module, visit https://docs.sentry.io/product/insights/caches/. This feature requires Laravel v11.11.0 or higher.
Cache tracing is enabled by default for new SDK installations. To enable this feature in your existing installation, update your config/sentry.php file with 'cache' => env('SENTRY_TRACE_CACHE_ENABLED', true), under 'tracing'.
The Sentry SDK team is happy to announce the immediate availability of Sentry Laravel SDK v4.6.1.
The Sentry SDK team is happy to announce the immediate availability of Sentry Laravel SDK v4.6.0.
Add support for the Queue Insights Module (#902). To learn more about this module, visit https://docs.sentry.io/product/performance/queue-monitoring/.
Queue tracing is enabled by default for new SDK installations. To enable this feature in your existing installation, update your config/sentry.php file with 'queue_jobs' => env('SENTRY_TRACE_QUEUE_JOBS_ENABLED', true), or set SENTRY_TRACE_QUEUE_JOBS_ENABLED=true in your environment (#903)
Check if a span is sampled before creating child spans (#898)
Always register the console sentryMonitor() macro. This fixes the macro not being available when using Laravel Lumen (#900)
Avoid manipulating the config when resolving disks (#901)
SENTRY_SPOTLIGHT environment variable and not requiring a DSN to be set to use Spotlight (#892)The Sentry SDK team is happy to announce the immediate availability of Sentry Laravel SDK v4.5.1.
The Sentry SDK team is happy to announce the immediate availability of Sentry Laravel SDK v4.5.0.
Limit when SQL query origins are being captured (#881)
We now only capture the origin of a SQL query when the query is slower than 100ms, configurable by the SENTRY_TRACE_SQL_ORIGIN_THRESHOLD_MS environment variable.
Add tracing and breadcrumbs for Notifications (#852)
Add reporter for Model::preventAccessingMissingAttributes() (#824)
Make it easier to enable the debug logger (#880)
You can now enable the debug logger by adding the following to your config/sentry.php file:
'logger' => Sentry\Logger\DebugFileLogger::class, // This will log SDK logs to `storage_path('logs/sentry.log')`
Only use this in development and testing environments, as it can generate a lot of logs.
The Sentry SDK team is happy to announce the immediate availability of Sentry Laravel SDK v4.4.1.
assertExists/assertMissing can throw on the FilesystemDecorator (#877)The Sentry SDK team is happy to announce the immediate availability of Sentry Laravel SDK v4.4.0.
Add support for Laravel 11 Context (#869)
If you are using Laravel 11 and the new "Context" capabilities we now automatically capture that context for you and it will be visible in Sentry. Read more about the feature in the Laravel documentation and how to use it.
The Sentry SDK team is happy to announce the immediate availability of Sentry Laravel SDK v4.3.1.
FilesystemDecorator (#865)The Sentry SDK team is happy to announce the immediate availability of Sentry Laravel SDK v4.3.0.
Add support for Laravel 11.0 (#845)
If you're upgrading an existing Laravel 10 application to the new Laravel 11 directory structure, you must change how Sentry integrates into the exception handler. Update your bootstrap/app.php with:
<?php
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
use Sentry\Laravel\Integration;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__.'/../routes/web.php',
commands: __DIR__.'/../routes/console.php',
health: '/up',
)
->withMiddleware(function (Middleware $middleware) {
//
})
->withExceptions(function (Exceptions $exceptions) {
Integration::handles($exceptions);
})->create();
If you plan to perform up-time checks against the new Laravel 11 /up health URL, ignore this transaction in your config/sentry.php file, as not doing so could consume a substantial amount of your performance unit quota.
// [@see](https://github.com/see): https://docs.sentry.io/platforms/php/guides/laravel/configuration/options/#ignore-transactions
'ignore_transactions' => [
// Ignore Laravel's default health URL
'/up',
],
The Sentry SDK team is happy to announce the immediate availability of Sentry Laravel SDK v4.2.0.
Add new spans, measuring the time taken to queue a job (#833)
Add support for failure_issue_threshold & recovery_threshold for sentryMonitor() method on scheduled commands (#838)
Automatically flush metrics when the application terminates (#841)
Add support for the W3C traceparent header (#834)
Improve php artisan sentry:test to show internal log messages by default (#842)
The Sentry SDK team is happy to announce the immediate availability of Sentry Laravel SDK v4.1.2.
Fix unable to set callable for integrations option (#826)
Fix performance traces not being collected for Laravel Lumen unless missing routes are reported (#822)
Fix configuration options for queue job tracing not applying correctly (#820)
symfony/psr-http-message-bridge dependency (#829)The Sentry SDK team is happy to announce the immediate availability of Sentry Laravel SDK v4.1.0.
Capture SQL query bindings (parameters) in SQL query spans (#804)
To enable this feature, update your config/sentry.php file or set the SENTRY_TRACE_SQL_BINDINGS_ENABLED environment variable to true.
'tracing' => [
'sql_bindings' => true,
],
The Sentry SDK team is thrilled to announce the immediate availability of Sentry Laravel SDK v4.0.0.
This version adds support for the underlying Sentry PHP SDK v4.0. Please refer to the PHP SDK sentry-php/UPGRADE-4.0.md guide for a complete list of breaking changes.
This version exclusively uses the envelope endpoint to send event data to Sentry.
If you are using sentry.io, no action is needed.
If you are using an on-premise/self-hosted installation of Sentry, the minimum requirement is now version >= v20.6.0.
You need to have ext-curl installed to use the SDK.
The IgnoreErrorsIntegration integration was removed. Use the ignore_exceptions option instead.
// config/sentry.php
'ignore_exceptions' => [BadThingsHappenedException::class],
This option performs an is_a check now, so you can also ignore more generic exceptions.
Enable distributed tracing for outgoing HTTP client requests (#797)
This feature is only available on Laravel >= 10.14.
When making a request using the Laravel Http facade, we automatically attach the sentry-trace and baggage headers.
This behaviour can be controlled by setting trace_propagation_targets in your config/sentry.php file.
// config/sentry.php
// All requests will contain the tracing headers. This is the default behaviour.
'trace_propagation_targets' => null,
// To turn this feature off completely, set the option to an empty array.
'trace_propagation_targets' => [],
// To only attach these headers to some requests, you can allow-list certain hosts.
'trace_propagation_targets' => [
'examlpe.com',
'api.examlpe.com',
],
Please make sure to remove any custom code that injected these headers previously.
If you are using the Sentry\Tracing\GuzzleTracingMiddleware provided by our underlying PHP SDK, you must also remove it.
Add support for Laravel Livewire 3 (#798)
The SDK now creates traces and breadcrumbs for Livewire 3 as well. Both the class-based and Volt usage are supported.
// config/sentry.php
'breadcrumbs' => [
// Capture Livewire components in breadcrumbs
'livewire' => true,
],
'tracing' => [
// Capture Livewire components as spans
'livewire' => true,
],
Add new fluent APIs (#1601)
// Before
$spanContext = new SpanContext();
$spanContext->setDescription('myFunction');
$spanContext->setOp('function');
// After
$spanContext = (new SpanContext())
->setDescription('myFunction');
->setOp('function');
Simplify the breadcrumb API (#1603)
// Before
\Sentry\addBreadcrumb(
new \Sentry\Breadcrumb(
\Sentry\Breadcrumb::LEVEL_INFO,
\Sentry\Breadcrumb::TYPE_DEFAULT,
'auth', // category
'User authenticated', // message (optional)
['user_id' => $userId] // data (optional)
)
);
// After
\Sentry\addBreadcrumb(
category: 'auth',
message: 'User authenticated', // optional
metadata: ['user_id' => $userId], // optional
level: Breadcrumb::LEVEL_INFO, // set by default
type: Breadcrumb::TYPE_DEFAULT, // set by default
);
New default cURL HTTP client (#1589)
php-http/message-factory was removed.How can I help you explore Laravel packages today?