Enable Discovery debug logging for production troubleshooting

- Add DISCOVERY_LOG_LEVEL=debug
- Add DISCOVERY_SHOW_PROGRESS=true
- Temporary changes for debugging InitializerProcessor fixes on production
This commit is contained in:
2025-08-11 20:13:26 +02:00
parent 59fd3dd3b1
commit 55a330b223
3683 changed files with 2956207 additions and 16948 deletions

View File

@@ -0,0 +1,86 @@
<?php
declare(strict_types=1);
namespace App\Framework\ErrorAggregation;
use App\Framework\Cache\Cache;
use App\Framework\Database\ConnectionInterface;
use App\Framework\DateTime\Clock;
use App\Framework\DI\Container;
use App\Framework\DI\Initializer;
use App\Framework\ErrorAggregation\Alerting\AlertManager;
use App\Framework\ErrorAggregation\Alerting\EmailAlertChannel;
use App\Framework\ErrorAggregation\Storage\DatabaseErrorStorage;
use App\Framework\ErrorAggregation\Storage\ErrorStorageInterface;
use App\Framework\Logging\Logger;
use App\Framework\Mail\Transport\TransportInterface;
use App\Framework\Queue\Queue;
/**
* Initializer for Error Aggregation services
*/
final readonly class ErrorAggregationInitializer
{
#[Initializer]
public function initialize(Container $container): void
{
// Storage
$container->bind(ErrorStorageInterface::class, function (Container $container) {
return new DatabaseErrorStorage(
connection: $container->get(ConnectionInterface::class)
);
});
// Error Aggregator
$container->bind(ErrorAggregator::class, function (Container $container) {
return new ErrorAggregator(
storage: $container->get(ErrorStorageInterface::class),
cache: $container->get(Cache::class),
clock: $container->get(Clock::class),
alertQueue: $container->get(Queue::class),
logger: $container->get(Logger::class),
batchSize: (int) ($_ENV['ERROR_AGGREGATION_BATCH_SIZE'] ?? 100),
maxRetentionDays: (int) ($_ENV['ERROR_AGGREGATION_MAX_RETENTION_DAYS'] ?? 90)
);
});
// Alert Manager
$container->bind(AlertManager::class, function (Container $container) {
$channels = [];
// Email channel (if configured)
if (! empty($_ENV['ALERT_EMAIL_RECIPIENTS'])) {
$recipients = explode(',', $_ENV['ALERT_EMAIL_RECIPIENTS']);
$channels[] = new EmailAlertChannel(
transport: $container->get(TransportInterface::class),
recipients: array_map('trim', $recipients),
fromEmail: $_ENV['ALERT_FROM_EMAIL'] ?? 'alerts@example.com',
fromName: $_ENV['ALERT_FROM_NAME'] ?? 'Error Alert System'
);
}
return new AlertManager(
cache: $container->get(Cache::class),
clock: $container->get(Clock::class),
retryQueue: $container->get(Queue::class),
logger: $container->get(Logger::class),
channels: $channels,
throttleConfig: [
'urgent' => (int) ($_ENV['ALERT_THROTTLE_URGENT'] ?? 300),
'high' => (int) ($_ENV['ALERT_THROTTLE_HIGH'] ?? 900),
'medium' => (int) ($_ENV['ALERT_THROTTLE_MEDIUM'] ?? 3600),
'low' => (int) ($_ENV['ALERT_THROTTLE_LOW'] ?? 86400),
]
);
});
// Middleware
$container->bind(ErrorAggregationMiddleware::class, function (Container $container) {
return new ErrorAggregationMiddleware(
errorAggregator: $container->get(ErrorAggregator::class),
enabled: (bool) ($_ENV['ERROR_AGGREGATION_ENABLED'] ?? true)
);
});
}
}