-
-
Notifications
You must be signed in to change notification settings - Fork 1
Storage
ChronoTrace supports multiple storage backends for storing trace data. This guide covers configuration and management of different storage options.
Configuration:
'storage' => 'local',
'path' => storage_path('chronotrace'),Pros:
- Simple setup, no external dependencies
- Fast access for development
- No additional costs
Cons:
- Not scalable across multiple servers
- Limited by local disk space
- No built-in backup/replication
Best for: Development and single-server deployments
Configuration:
'storage' => 's3',
's3' => [
'bucket' => 'my-chronotrace-bucket',
'region' => 'us-east-1',
'path_prefix' => 'traces',
],Pros:
- Highly scalable and reliable
- Built-in backup and versioning
- Cost-effective for large volumes
- Multi-region support
Cons:
- Network latency for access
- Requires AWS/cloud setup
- Additional costs
Best for: Production deployments and multi-server setups
// config/chronotrace.php
'storage' => 'local',
'local' => [
'path' => storage_path('chronotrace'),
'create_directories' => true,
'permissions' => [
'file' => 0644,
'dir' => 0755,
],
],storage/chronotrace/
βββ traces/ # Individual trace files
βββ indexes/ # Search indexes for fast lookup
βββ temp/ # Temporary files during processing
βββ metadata/ # Trace metadata and statistics
# Set proper permissions
chmod -R 755 storage/chronotrace
chown -R www-data:www-data storage/chronotrace
# Verify permissions
ls -la storage/chronotrace/For detailed S3 configuration, see the S3 & MinIO Storage guide.
// config/chronotrace.php
'storage' => 's3',
's3' => [
'bucket' => env('CHRONOTRACE_S3_BUCKET'),
'region' => env('CHRONOTRACE_S3_REGION', 'us-east-1'),
'path_prefix' => env('CHRONOTRACE_S3_PREFIX', 'traces'),
'storage_class' => 'STANDARD_IA',
'server_side_encryption' => 'AES256',
],# .env
CHRONOTRACE_STORAGE=s3
CHRONOTRACE_S3_BUCKET=my-app-chronotrace
CHRONOTRACE_S3_REGION=us-east-1
CHRONOTRACE_S3_PREFIX=production/traces
AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_keyEnable compression to reduce storage usage:
// config/chronotrace.php
'compression' => [
'enabled' => true,
'level' => 6, // 1-9, higher = better compression
'threshold' => 1024, // Only compress files > 1KB
'format' => 'gzip', // gzip or brotli
],Compression benefits:
- 60-80% size reduction typically
- Lower storage costs
- Faster transfers (for S3)
Configure automatic cleanup:
// config/chronotrace.php
'retention_days' => 15,
'auto_purge' => true,
'purge_schedule' => 'daily',
'retention_policies' => [
'error_traces' => 30, // Keep errors longer
'slow_traces' => 21, // Keep slow requests longer
'success_traces' => 7, // Clean up successful requests sooner
],Organize traces efficiently:
// config/chronotrace.php
'partitioning' => [
'strategy' => 'date', // date, size, hash
'date_format' => 'Y/m/d', // Creates YYYY/MM/DD structure
'max_files_per_directory' => 1000,
],Results in structure like:
traces/
βββ 2024/08/06/
β βββ trace_001.json
β βββ trace_002.json
β βββ ...
βββ 2024/08/07/
β βββ ...
# Check storage statistics
php artisan chronotrace:storage-stats
# Expected output:
ββ STORAGE STATISTICS βββββββββββββββββββββββββββββββββββββββββ
β Storage Type: Local β
β Location: /app/storage/chronotrace β
β β
β π Usage: β
β Total Traces: 1,234 β
β Total Size: 156 MB β
β Average Size: 126 KB β
β Compressed: 89% reduction β
β β
β π
Age Distribution: β
β Last 24h: 89 traces (12 MB) β
β Last 7 days: 567 traces (78 MB) β
β Older: 578 traces (66 MB) β
β β
β πΎ Available Space: 2.1 GB β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ// Monitor storage health
class StorageHealthMonitor
{
public function checkStorageHealth()
{
$stats = [
'total_size' => $this->getTotalStorageSize(),
'available_space' => $this->getAvailableSpace(),
'trace_count' => $this->getTraceCount(),
'average_size' => $this->getAverageTraceSize(),
];
// Alert if storage > 80% full
if ($stats['total_size'] / $this->getTotalSpace() > 0.8) {
$this->sendStorageAlert($stats);
}
return $stats;
}
}# Migration script
php artisan chronotrace:migrate-storage --from=local --to=s3 --verify
# Expected output:
Migrating traces from local to S3...
β Migrated trace_001.json (125 KB)
β Migrated trace_002.json (89 KB)
β Migrated trace_003.json (156 KB)
...
β Migration complete: 1,234 traces migrated (156 MB total)
β Verification: All traces accessible in S3
β Local cleanup: 156 MB freed// config/chronotrace.php
'migration' => [
'batch_size' => 100, // Process 100 traces at a time
'verify_uploads' => true, // Verify each upload
'cleanup_source' => true, // Remove from source after successful migration
'preserve_metadata' => true, // Keep original timestamps
],// app/Storage/CustomStorageDriver.php
class CustomStorageDriver implements StorageDriverInterface
{
public function store(string $traceId, array $data): bool
{
// Implement custom storage logic
return $this->writeToCustomBackend($traceId, $data);
}
public function retrieve(string $traceId): ?array
{
// Implement custom retrieval logic
return $this->readFromCustomBackend($traceId);
}
public function delete(string $traceId): bool
{
// Implement custom deletion logic
return $this->deleteFromCustomBackend($traceId);
}
public function exists(string $traceId): bool
{
// Check if trace exists
return $this->checkCustomBackend($traceId);
}
}// app/Providers/AppServiceProvider.php
public function boot()
{
$this->app->afterResolving(StorageManager::class, function (StorageManager $manager) {
$manager->extend('custom', function ($app, $config) {
return new CustomStorageDriver($config);
});
});
}// config/chronotrace.php
'storage' => 'custom',
'custom' => [
'endpoint' => 'https://my-storage-api.com',
'api_key' => env('CUSTOM_STORAGE_API_KEY'),
'timeout' => 30,
],// config/chronotrace.php
'encryption' => [
'enabled' => true,
'key' => env('CHRONOTRACE_ENCRYPTION_KEY'),
'cipher' => 'AES-256-GCM',
],// Implement access control for trace storage
class TraceAccessControl
{
public function canAccessTrace(User $user, string $traceId): bool
{
// Implement your access logic
return $user->hasRole('admin') ||
$this->tracebelongsToUser($user, $traceId);
}
}// config/chronotrace.php
'backup' => [
'enabled' => true,
'schedule' => 'daily',
'retention' => 30, // Keep backups for 30 days
'destination' => 's3', // Backup to S3
'encryption' => true,
],# Create manual backup
php artisan chronotrace:backup --destination=s3://backup-bucket/chronotrace
# Restore from backup
php artisan chronotrace:restore --source=s3://backup-bucket/chronotrace/2024-08-06// Use queues for storage operations
'async_storage' => true,
'queue_connection' => 'redis',
'queue_name' => 'chronotrace-storage',// Optimize storage connections
'storage_options' => [
'pool_size' => 10,
'timeout' => 30,
'retry_attempts' => 3,
],// Cache frequently accessed traces
'cache' => [
'enabled' => true,
'driver' => 'redis',
'ttl' => 3600, // Cache for 1 hour
'max_size' => 100, // Cache max 100 traces
],# Check available space
df -h storage/chronotrace
# Clean up old traces
php artisan chronotrace:purge --days=7
# Move to S3 storage
php artisan chronotrace:migrate-storage --to=s3# Fix permissions
sudo chown -R www-data:www-data storage/chronotrace
sudo chmod -R 755 storage/chronotrace# Test S3 connectivity
php artisan chronotrace:test-storage --driver=s3
# Check credentials
aws s3 ls s3://your-bucket --profile your-profile- S3 & MinIO Storage - Detailed cloud storage setup
- Configuration - Complete configuration options
- Production Monitoring - Storage monitoring in production
- Troubleshooting - Storage troubleshooting guide
Choose the right storage backend for your needs! Start with local storage for development, then scale to cloud storage for production deployments.
- 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