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,118 @@
<?php
declare(strict_types=1);
namespace App\Framework\CircuitBreaker\SlidingWindow;
use App\Framework\CircuitBreaker\CircuitBreakerConfig;
use App\Framework\Core\ValueObjects\Timestamp;
use App\Framework\SlidingWindow\Aggregator\BooleanResult;
use App\Framework\SlidingWindow\SlidingWindow;
/**
* Circuit Breaker specific sliding window wrapper
*/
final readonly class CircuitBreakerSlidingWindow
{
public function __construct(
private SlidingWindow $slidingWindow,
) {
}
/**
* Record a successful operation
*/
public function recordSuccess(?Timestamp $timestamp = null): void
{
$timestamp ??= Timestamp::now();
$this->slidingWindow->record(true, $timestamp);
}
/**
* Record a failed operation
*/
public function recordFailure(?Timestamp $timestamp = null): void
{
$timestamp ??= Timestamp::now();
$this->slidingWindow->record(false, $timestamp);
}
/**
* Check if failure threshold is exceeded
*/
public function isFailureThresholdExceeded(CircuitBreakerConfig $config): bool
{
$stats = $this->slidingWindow->getStats();
$booleanData = $stats->getAggregatedValue('boolean');
if (! $booleanData instanceof BooleanResult) {
return false;
}
// Check minimum requests threshold
if (! $booleanData->hasMinimumRequests($config->successThreshold)) {
return false;
}
// Calculate failure threshold as percentage
$failureThreshold = $config->failureThreshold / 100.0; // Convert to 0.0-1.0 range
return $booleanData->isFailureRateExceeded($failureThreshold);
}
/**
* Get current failure rate
*/
public function getFailureRate(): float
{
$stats = $this->slidingWindow->getStats();
$booleanData = $stats->getAggregatedValue('boolean');
if (! $booleanData instanceof BooleanResult) {
return 0.0;
}
return $booleanData->failureRate;
}
/**
* Get success rate
*/
public function getSuccessRate(): float
{
$stats = $this->slidingWindow->getStats();
$booleanData = $stats->getAggregatedValue('boolean');
if (! $booleanData instanceof BooleanResult) {
return 0.0;
}
return $booleanData->successRate;
}
/**
* Get total request count in window
*/
public function getTotalRequests(): int
{
$stats = $this->slidingWindow->getStats();
return $stats->totalCount;
}
/**
* Clear the sliding window
*/
public function clear(): void
{
$this->slidingWindow->clear();
}
/**
* Get the underlying sliding window
*/
public function getSlidingWindow(): SlidingWindow
{
return $this->slidingWindow;
}
}