| Install | |
|---|---|
composer require grazulex/laravel-chronotrace |
|
| Latest Version: | v0.0.4 |
| PHP: | ^8.3 |
⏱️ Record and replay Laravel requests deterministically — capture all database queries, cache operations, HTTP calls, and queue jobs for debugging and analysis.
Laravel ChronoTrace is a powerful debugging and monitoring tool for Laravel applications that allows you to:
Perfect for debugging hard-to-reproduce issues, performance analysis, and understanding complex application flows.
composer require --dev grazulex/laravel-chronotrace
Requirements:
composer require --dev grazulex/laravel-chronotrace
php artisan chronotrace:install
Edit config/chronotrace.php or set environment variables:
CHRONOTRACE_ENABLED=true
CHRONOTRACE_MODE=record_on_error # always | sample | record_on_error | targeted
CHRONOTRACE_STORAGE=local # local | s3
For debugging real application issues:
# Record a specific endpoint
php artisan chronotrace:record /api/users
# Record with POST data
php artisan chronotrace:record /api/users \
--method=POST \
--data='{"name":"John","email":"john@example.com"}'
# Record with custom headers
php artisan chronotrace:record /api/protected \
--method=GET \
--headers='{"Authorization":"Bearer token123"}'
For testing ChronoTrace configuration:
# Test that ChronoTrace captures internal operations
php artisan chronotrace:test-internal
# Test specific operation types
php artisan chronotrace:test-internal --with-db --with-cache
💡 Key Difference:
chronotrace:recordcaptures real HTTP requests for debugging actual issues, whilechronotrace:test-internalvalidates that ChronoTrace is properly configured and working.
# List all traces
php artisan chronotrace:list
# List with full trace IDs
php artisan chronotrace:list --full-id
# Replay a specific trace (use ID from list command)
php artisan chronotrace:replay abc12345-def6-7890-abcd-ef1234567890
# View only database queries
php artisan chronotrace:replay {trace-id} --db
# View only cache operations
php artisan chronotrace:replay {trace-id} --cache
# View only HTTP requests
php artisan chronotrace:replay {trace-id} --http
# View only queue jobs
php artisan chronotrace:replay {trace-id} --jobs
# View detailed information with context, headers, and content
php artisan chronotrace:replay {trace-id} --detailed
# Show SQL query bindings for debugging
php artisan chronotrace:replay {trace-id} --db --bindings
# Generate Pest tests from traces
php artisan chronotrace:replay {trace-id} --generate-test
# Generate tests in custom directory
php artisan chronotrace:replay {trace-id} --generate-test --test-path=tests/Integration
# Output as JSON for programmatic processing
php artisan chronotrace:replay {trace-id} --format=json
storage/chronotrace/{date}/{trace-id}/Each trace includes comprehensive information:
=== TRACE INFORMATION ===
🆔 Trace ID: abc12345-def6-7890-abcd-ef1234567890
🕒 Timestamp: 2024-01-15 14:30:22
🌍 Environment: production
🔗 Request URL: https://app.example.com/api/users
📊 Response Status: 200
⏱️ Duration: 245ms
💾 Memory Usage: 18.45 KB
=== CAPTURED EVENTS ===
📊 DATABASE EVENTS
🔍 Query: SELECT * FROM users WHERE active = ? (15ms)
🔍 Query: SELECT * FROM roles WHERE user_id IN (?, ?) (8ms)
🗄️ CACHE EVENTS
❌ Cache MISS: users:list (store: redis)
💾 Cache WRITE: users:list (store: redis)
🌐 HTTP EVENTS
📤 HTTP Request: GET https://api.external.com/validation
📥 HTTP Response: 200 (1,234 bytes)
⚙️ JOB EVENTS
🔄 Job STARTED: ProcessUserRegistration
✅ Job COMPLETED: ProcessUserRegistration
chronotrace:record – Record real HTTP requests for debugging actual application issueschronotrace:list – List stored traces with metadata and filtering optionschronotrace:replay – Replay and analyze captured traces with advanced filtering and output formatschronotrace:purge – Remove old traces based on retention policychronotrace:install – Install and configure ChronoTrace middlewarechronotrace:test-internal – Test ChronoTrace configuration with internal Laravel operationschronotrace:test-middleware – Test middleware installation and activationchronotrace:diagnose – Diagnose configuration and potential issues with comprehensive checks# Installation and setup
chronotrace:install --force
# Validate ChronoTrace is working
chronotrace:test-internal --with-db --with-cache
# Record real application traces
chronotrace:record /api/users --method=GET
chronotrace:record /checkout --method=POST --data='{"cart_id": 123}'
chronotrace:record /api/protected --headers='{"Authorization":"Bearer token"}'
# Advanced recording with timeout
chronotrace:record /api/slow-endpoint --timeout=60
# List and analyze traces
chronotrace:list --limit=10 --full-id
chronotrace:replay {trace-id} --db --cache --bindings
chronotrace:replay {trace-id} --detailed --context --headers
chronotrace:replay {trace-id} --generate-test --test-path=tests/Integration
# Output in different formats
chronotrace:replay {trace-id} --format=json
chronotrace:replay {trace-id} --format=raw
# Diagnostics and testing
chronotrace:diagnose
chronotrace:test-middleware
# Test internal operations when chronotrace:record doesn't capture internal events
chronotrace:test-internal --with-db --with-cache --with-events
chronotrace:test-internal --with-db # Test only database operations
# Maintenance and cleanup
chronotrace:purge --days=7 --confirm
We welcome contributions! See CONTRIBUTING.md for details.
Pour une documentation complète et détaillée, consultez notre Wiki officiel :
Laravel ChronoTrace is open-sourced software licensed under the MIT license.
Made with ❤️ for the Laravel community