amarc-sudo/sentry-enhanced-tracing
composer require amarc-sudo/sentry-enhanced-tracing
Add to config/bundles.php:
<?php
return [
// ... other bundles
AmarcSudo\SentryEnhancedTracing\SentryEnhancedTracingBundle::class => ['all' => true],
];
Make sure you have Sentry properly configured:
# config/packages/sentry.yaml
sentry:
dsn: '%env(SENTRY_DSN)%'
options:
# Enhanced tracing options
traces_sample_rate: 1.0
profiles_sample_rate: 1.0
max_breadcrumbs: 100
attach_stacktrace: true
send_default_pii: true
max_request_body_size: 'medium'
context_lines: 7
integrations:
- 'Sentry\Integration\RequestIntegration'
- 'Sentry\Integration\TransactionIntegration'
- 'Sentry\Integration\FrameContextifierIntegration'
For breadcrumbs and enhanced logging:
# config/packages/monolog.yaml
monolog:
handlers:
sentry_breadcrumbs:
type: sentry
level: info
hub_id: Sentry\State\HubInterface
fill_extra_context: true
sentry_events:
type: sentry
level: warning
hub_id: Sentry\State\HubInterface
You can customize which event phases are tracked:
# config/packages/sentry_enhanced_tracing.yaml
sentry_enhanced_tracing:
tracked_events:
- 'kernel.request'
- 'kernel.controller'
- 'kernel.view'
- 'kernel.response'
- 'kernel.exception'
Customize performance categorization:
sentry_enhanced_tracing:
performance_thresholds:
kernel.request: 0.05 # 50ms
kernel.controller: 0.1 # 100ms
kernel.view: 0.02 # 20ms
kernel.response: 0.05 # 50ms
Configure user context capture:
sentry_enhanced_tracing:
user_context:
capture_user_id: true
capture_username: true
capture_email: false # PII - be careful!
capture_ip: true
capture_user_agent: true
Set these in your .env file:
# Required
SENTRY_DSN=https://your-sentry-dsn@sentry.io/project-id
# Optional - for enhanced tracing
SENTRY_TRACES_SAMPLE_RATE=1.0
SENTRY_PROFILES_SAMPLE_RATE=1.0
SENTRY_SEND_DEFAULT_PII=false
After installation, you should see in your Sentry dashboard:
traces_sample_rate is > 0bundles.phptraces_sample_rate in productionmax_breadcrumbs if neededtraces_sample_rate: 0.1)traces_sample_rate: 1.0)queue.publish span is created on dispatch, and a queue.process transaction is started per message on the worker.SentryTraceStamp to link producer/consumer.SentryUserStamp (id, username, email if available). To disable:# config/services.yaml
parameters:
sentry_enhanced_tracing.messenger.propagate_user: false
messaging.message.id (TransportMessageIdStamp/UuidStamp)messaging.destination.name (transport or bus)messaging.message.body.size (JSON/serialize estimation)messaging.message.retry.count (RedeliveryStamp)messaging.message.receive.latency (ms, based on publish_time)// Dispatch
$bus->dispatch(new EmailJob($payload));
// Worker (standard messenger:consume)
php bin/console messenger:consume async
Transactions appear in Sentry > Performance > Queues, linked to parent HTTP requests or producer jobs through the injected traceparent/baggage.
How can I help you explore Laravel packages today?