composer require andersundsehr/sentry-async
config/packages/sentry.yaml:
sentry:
options:
transport: AUS\SentryAsync\Transport\QueueTransport
%kernel.cache_dir%/sentry_async/).Replace synchronous Sentry calls (e.g., Sentry\captureException()) with the same method calls—they’ll now queue asynchronously:
try {
// Risky operation
} catch (\Exception $e) {
\Sentry\captureException($e); // Queued for async processing
}
Queue-Based Processing:
messenger or a custom script) flushes the queue to Sentry.php bin/console sentry:async:flush
Custom Queue Integration:
# config/services.yaml
AUS\SentryAsync\Transport\QueueTransport:
$queue: '@messenger.default_bus'
AUS\SentryAsync\Queue\QueueInterface for custom backends.Batch Processing:
sentry_async.file_queue.limit (default: 200 entries).sentry_async.file_queue.compress: true) to reduce I/O overhead.HttpKernel or adapt the queue logic to Laravel’s queue system (e.g., database or redis).* * * * * cd /path-to-project && php artisan sentry:async:flush >> /dev/null 2>&1
$this->app->instance(QueueInterface::class, new MockQueue());
Queue Directory Permissions:
%kernel.cache_dir%/sentry_async/ is writable by the web server (e.g., chmod -R 755 var/cache/sentry_async).Permission denied errors in Sentry’s logs or Symfony’s var/log/dev.log.DSN Configuration:
sentry.dsn needed in sentry_async).Background Process Reliability:
Entry Data Limits:
limit or switch to a more scalable queue (e.g., database).Flush Command Output:
-v for verbose logs:
php bin/console sentry:async:flush -v
Queue Inspection:
ls -la var/cache/sentry_async/
QueueInterface::peek() method.Custom Entry Data:
AUS\SentryAsync\Entry\Entry to include metadata (e.g., user context):
sentry_async:
entry_factory:
entry_class: 'App\SentryAsync\CustomEntry'
__toString() to serialize additional fields.Transport Overrides:
QueueTransport entirely by binding a custom class to AUS\SentryAsync\Transport\QueueTransport in services.yaml.Event Listeners:
SentryAsyncEvents::ENTRY_ADDED to filter or modify entries before queuing:
use AUS\SentryAsync\Event\SentryAsyncEvents;
$eventDispatcher->addListener(SentryAsyncEvents::ENTRY_ADDED, function ($entry) {
$entry->setExtra('custom_key', 'value');
});
compress: true for high-volume queues to reduce disk usage.limit for high-throughput apps (test impact on memory usage).messenger:consume for parallel processing:
php bin/console messenger:consume sentry-async -vv
How can I help you explore Laravel packages today?