- Add comprehensive health check system with multiple endpoints - Add Prometheus metrics endpoint - Add production logging configurations (5 strategies) - Add complete deployment documentation suite: * QUICKSTART.md - 30-minute deployment guide * DEPLOYMENT_CHECKLIST.md - Printable verification checklist * DEPLOYMENT_WORKFLOW.md - Complete deployment lifecycle * PRODUCTION_DEPLOYMENT.md - Comprehensive technical reference * production-logging.md - Logging configuration guide * ANSIBLE_DEPLOYMENT.md - Infrastructure as Code automation * README.md - Navigation hub * DEPLOYMENT_SUMMARY.md - Executive summary - Add deployment scripts and automation - Add DEPLOYMENT_PLAN.md - Concrete plan for immediate deployment - Update README with production-ready features All production infrastructure is now complete and ready for deployment.
76 lines
2.6 KiB
PHP
76 lines
2.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
require __DIR__ . '/../../vendor/autoload.php';
|
|
|
|
use App\Framework\ErrorAggregation\ErrorEvent;
|
|
use App\Framework\ErrorAggregation\Storage\InMemoryErrorStorage;
|
|
use App\Framework\DateTime\Clock;
|
|
use App\Framework\Core\ValueObjects\Timestamp;
|
|
use App\Framework\Exception\Core\DatabaseErrorCode;
|
|
use App\Framework\Exception\FrameworkException;
|
|
use App\Framework\Exception\ExceptionContext;
|
|
use App\Framework\Exception\RequestContext;
|
|
use App\Framework\Exception\SystemContext;
|
|
use App\Framework\Exception\ErrorHandlerContext;
|
|
|
|
// Create test clock
|
|
$clock = new class implements Clock {
|
|
public function now(): \DateTimeImmutable { return new \DateTimeImmutable(); }
|
|
public function fromTimestamp(Timestamp $timestamp): \DateTimeImmutable { return $timestamp->toDateTime(); }
|
|
public function fromString(string $dateTime, ?string $format = null): \DateTimeImmutable { return new \DateTimeImmutable($dateTime); }
|
|
public function today(): \DateTimeImmutable { return new \DateTimeImmutable('today'); }
|
|
public function yesterday(): \DateTimeImmutable { return new \DateTimeImmutable('yesterday'); }
|
|
public function tomorrow(): \DateTimeImmutable { return new \DateTimeImmutable('tomorrow'); }
|
|
public function time(): Timestamp { return Timestamp::now(); }
|
|
};
|
|
|
|
echo "Creating ErrorEvent directly...\n";
|
|
|
|
$exception = FrameworkException::create(
|
|
DatabaseErrorCode::QUERY_FAILED,
|
|
'Test database query failed'
|
|
);
|
|
|
|
$exceptionContext = ExceptionContext::empty()
|
|
->withOperation('test_operation', 'TestComponent')
|
|
->withData(['test_key' => 'test_value']);
|
|
|
|
$requestContext = RequestContext::fromGlobals();
|
|
$systemContext = SystemContext::current();
|
|
|
|
$errorHandlerContext = ErrorHandlerContext::create(
|
|
$exceptionContext,
|
|
$requestContext,
|
|
$systemContext,
|
|
['http_status' => 500]
|
|
);
|
|
|
|
$errorEvent = ErrorEvent::fromErrorHandlerContext($errorHandlerContext, $clock);
|
|
|
|
echo "ErrorEvent created successfully\n";
|
|
echo " ID: " . (string) $errorEvent->id . "\n";
|
|
echo " Service: " . $errorEvent->service . "\n";
|
|
echo " Component: " . $errorEvent->component . "\n";
|
|
|
|
echo "\nCreating InMemoryErrorStorage...\n";
|
|
$storage = new InMemoryErrorStorage();
|
|
|
|
echo "Storing event...\n";
|
|
$storage->storeEvent($errorEvent);
|
|
|
|
echo "Getting recent events...\n";
|
|
$recentEvents = $storage->getRecentEvents(10);
|
|
|
|
echo "Recent events count: " . count($recentEvents) . "\n";
|
|
|
|
if (count($recentEvents) > 0) {
|
|
echo "SUCCESS: Event was stored!\n";
|
|
$event = $recentEvents[0];
|
|
echo " Event ID: " . (string) $event->id . "\n";
|
|
echo " Message: " . $event->errorMessage . "\n";
|
|
} else {
|
|
echo "ERROR: Event was NOT stored!\n";
|
|
}
|