-
-
Notifications
You must be signed in to change notification settings - Fork 1
Installation
Get Laravel ChronoTrace up and running in your Laravel application quickly and easily.
- PHP 8.3+
- Laravel 10.x or 11.x
- Composer
Optional for advanced features:
- Redis (for queue-based async storage)
- AWS S3 or MinIO (for cloud storage)
composer require --dev grazulex/laravel-chronotracephp artisan chronotrace:installThis command will:
- Publish the configuration file to
config/chronotrace.php - Create the storage directory structure
- Set up basic environment variables
- Display configuration recommendations
Add to your .env file:
# Basic configuration
CHRONOTRACE_ENABLED=true
CHRONOTRACE_MODE=record_on_error
# Storage (local by default)
CHRONOTRACE_STORAGE=local
CHRONOTRACE_PATH="${APP_STORAGE_PATH}/chronotrace"
# Retention (15 days by default)
CHRONOTRACE_RETENTION_DAYS=15# Verify installation
php artisan chronotrace:diagnose
# Test with a sample trace
php artisan chronotrace:test-internalChoose when ChronoTrace should record traces:
# Development: Record everything
CHRONOTRACE_MODE=always
# Production: Only errors + sampling
CHRONOTRACE_MODE=record_on_error
CHRONOTRACE_SAMPLE_RATE=0.001 # 0.1% of successful requests
# Testing: Sample all requests
CHRONOTRACE_MODE=sample
CHRONOTRACE_SAMPLE_RATE=0.1 # 10% of all requests
# Selective: Only specific routes
CHRONOTRACE_MODE=targetedControl what events to capture:
# Essential events (recommended for production)
CHRONOTRACE_CAPTURE_DATABASE=true
CHRONOTRACE_CAPTURE_HTTP=true
CHRONOTRACE_CAPTURE_JOBS=true
# Optional events (can be noisy)
CHRONOTRACE_CAPTURE_CACHE=false
CHRONOTRACE_CAPTURE_EVENTS=falseCHRONOTRACE_STORAGE=local
CHRONOTRACE_PATH="${APP_STORAGE_PATH}/chronotrace"CHRONOTRACE_STORAGE=s3
CHRONOTRACE_S3_BUCKET=my-chronotrace-bucket
CHRONOTRACE_S3_REGION=us-east-1
CHRONOTRACE_S3_PREFIX=tracesCHRONOTRACE_STORAGE=s3
CHRONOTRACE_S3_BUCKET=chronotrace
CHRONOTRACE_S3_ENDPOINT=https://minio.example.com
CHRONOTRACE_S3_REGION=us-east-1For better performance, use queues for async trace storage:
-
Configure Queue Driver:
# In .env QUEUE_CONNECTION=redis # or database
-
Run Queue Workers:
php artisan queue:work --queue=chronotrace
-
Enable Async Storage:
# In config/chronotrace.php 'async_storage' => true, 'queue_connection' => 'redis',
Add middleware to specific routes for targeted recording:
// In routes/web.php or routes/api.php
Route::middleware(['chronotrace'])->group(function () {
Route::post('/api/orders', [OrderController::class, 'store']);
Route::put('/api/users/{user}', [UserController::class, 'update']);
});Register a custom storage driver in your AppServiceProvider:
use Grazulex\LaravelChronotrace\Storage\Manager;
public function boot()
{
$this->app->afterResolving(Manager::class, function (Manager $manager) {
$manager->extend('custom', function ($app, $config) {
return new CustomStorageDriver($config);
});
});
}Configure sensitive data scrubbing:
// In config/chronotrace.php
'scrub' => [
'password',
'token',
'secret',
'key',
'email', // Add email scrubbing
'phone', // Add phone scrubbing
'ssn', // Add SSN scrubbing
'credit_card', // Add credit card scrubbing
],
'custom_scrubbers' => [
// Custom regex patterns
'/\b\d{4}-\d{4}-\d{4}-\d{4}\b/' => '****-****-****-****',
'/api_key_\w+/' => 'api_key_[REDACTED]',
],For production, use these security-focused settings:
# Only record errors
CHRONOTRACE_MODE=record_on_error
# Minimal sampling
CHRONOTRACE_SAMPLE_RATE=0.001
# Essential events only
CHRONOTRACE_CAPTURE_CACHE=false
CHRONOTRACE_CAPTURE_EVENTS=false
# Short retention
CHRONOTRACE_RETENTION_DAYS=7
# Scrub everything
CHRONOTRACE_SCRUB_PII=trueAfter installation, ChronoTrace creates this structure:
storage/
βββ chronotrace/
β βββ traces/ # Individual trace files
β βββ indexes/ # Search indexes
β βββ temp/ # Temporary files
β βββ metadata/ # Trace metadata
Ensure proper permissions:
# Set directory permissions
chmod -R 755 storage/chronotrace
chown -R www-data:www-data storage/chronotrace
# For shared hosting
chmod -R 777 storage/chronotrace# Check configuration and system status
php artisan chronotrace:diagnoseExpected output:
β
ChronoTrace Configuration
Enabled: Yes
Mode: record_on_error
Storage: local (/path/to/storage/chronotrace)
β
Storage
Writable: Yes
Free Space: 15.2 GB
β
Dependencies
PHP Version: 8.3.x β
Laravel Version: 11.x β
Required Extensions: β
β οΈ Recommendations
- Enable queue workers for better performance
- Configure Redis for production use
# Generate a test trace
php artisan chronotrace:test-internal
# List traces to verify
php artisan chronotrace:list
# Replay the test trace
php artisan chronotrace:replay {trace-id}# Fix storage permissions
sudo chown -R www-data:www-data storage/chronotrace
sudo chmod -R 755 storage/chronotrace# Install required PHP extensions
sudo apt-get install php8.3-json php8.3-mbstring php8.3-zip# Check disk space
df -h
# Check directory permissions
ls -la storage/# Manually publish configuration
php artisan vendor:publish --provider="Grazulex\LaravelChronotrace\LaravelChronotraceServiceProvider"If you encounter issues:
- Check the Troubleshooting Guide
-
Run diagnostics:
php artisan chronotrace:diagnose -
Check logs:
tail -f storage/logs/laravel.log - Report bugs: GitHub Issues
Now that ChronoTrace is installed:
- Basic Usage - Learn the fundamentals
- Your First Trace - Step-by-step walkthrough
- Configuration - Detailed configuration options
- Commands - Complete command reference
Installation complete! Start making requests to your application and use php artisan chronotrace:list to see captured traces.
- Getting Started - Install and configure ChronoTrace
- Examples - Real-world debugging scenarios
- Production Guide - Deploy safely in production
- Troubleshooting - Solve common issues
| Section | Page | Description |
|---|---|---|
| π Basics | Your First Trace | Step-by-step beginner guide |
| ποΈ Config | Recording Modes | Choose when to record traces |
| π‘οΈ Security | Security & PII | Protect sensitive data |
| π§ Tools | Commands | Complete command reference |
- π¬ GitHub Discussions - Community support
- π Report Issues - Bug reports & feature requests
- π§ Contact - Direct support
- π‘ Feature Requests - Suggest improvements
ChronoTrace helps Laravel developers debug applications faster with intelligent request tracing.
Made with β€οΈ by Grazulex β’ Documentation updated August 2024