<?php

declare(strict_types=1);

namespace App\Shared\Infrastructure\Monitoring;

use Prometheus\Storage\Redis;

/**
 * Factory to create Prometheus Redis storage from REDIS_URL.
 */
final readonly class PrometheusStorageFactory
{
    public static function createRedisStorage(string $redisUrl): Redis
    {
        $parsed = parse_url($redisUrl);

        return new Redis([
            'host' => $parsed['host'] ?? 'redis',
            'port' => $parsed['port'] ?? 6379,
        ]);
    }
}
