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:
95
src/Framework/Telemetry/Config/ExporterConfig.php
Normal file
95
src/Framework/Telemetry/Config/ExporterConfig.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Framework\Telemetry\Config;
|
||||
|
||||
/**
|
||||
* Configuration for a telemetry exporter
|
||||
*/
|
||||
final class ExporterConfig
|
||||
{
|
||||
/**
|
||||
* @param string $endpoint Endpoint URL for the exporter
|
||||
* @param string $protocol Protocol to use (http, file, etc.)
|
||||
* @param array<string, mixed> $options Additional options for the exporter
|
||||
*/
|
||||
public function __construct(
|
||||
private readonly string $endpoint,
|
||||
private readonly string $protocol = 'http',
|
||||
private readonly array $options = [],
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get endpoint URL
|
||||
*/
|
||||
public function getEndpoint(): string
|
||||
{
|
||||
return $this->endpoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get protocol
|
||||
*/
|
||||
public function getProtocol(): string
|
||||
{
|
||||
return $this->protocol;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all options
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function getOptions(): array
|
||||
{
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a specific option
|
||||
*/
|
||||
public function getOption(string $name, mixed $default = null): mixed
|
||||
{
|
||||
return $this->options[$name] ?? $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an option exists
|
||||
*/
|
||||
public function hasOption(string $name): bool
|
||||
{
|
||||
return isset($this->options[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this is an HTTP exporter
|
||||
*/
|
||||
public function isHttpExporter(): bool
|
||||
{
|
||||
return $this->protocol === 'http' || $this->protocol === 'https';
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this is a file exporter
|
||||
*/
|
||||
public function isFileExporter(): bool
|
||||
{
|
||||
return $this->protocol === 'file';
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance with additional options
|
||||
*
|
||||
* @param array<string, mixed> $options
|
||||
*/
|
||||
public function withOptions(array $options): self
|
||||
{
|
||||
return new self(
|
||||
$this->endpoint,
|
||||
$this->protocol,
|
||||
array_merge($this->options, $options)
|
||||
);
|
||||
}
|
||||
}
|
||||
148
src/Framework/Telemetry/Config/TelemetryConfig.php
Normal file
148
src/Framework/Telemetry/Config/TelemetryConfig.php
Normal file
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Framework\Telemetry\Config;
|
||||
|
||||
/**
|
||||
* Configuration for the Telemetry system
|
||||
*/
|
||||
final class TelemetryConfig
|
||||
{
|
||||
/**
|
||||
* @param string $serviceName Name of the service
|
||||
* @param string $serviceVersion Version of the service
|
||||
* @param string $environment Environment (dev, test, prod)
|
||||
* @param bool $enabled Whether telemetry is enabled
|
||||
* @param float $samplingRatio Sampling ratio (0.0-1.0)
|
||||
* @param array<string, ExporterConfig> $exporters Configured exporters
|
||||
* @param array<string, mixed> $resourceAttributes Additional resource attributes
|
||||
*/
|
||||
public function __construct(
|
||||
private readonly string $serviceName,
|
||||
private readonly string $serviceVersion,
|
||||
private readonly string $environment,
|
||||
private readonly bool $enabled = true,
|
||||
private readonly float $samplingRatio = 1.0,
|
||||
private readonly array $exporters = [],
|
||||
private readonly array $resourceAttributes = [],
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create config from array
|
||||
*/
|
||||
public static function fromArray(array $config): self
|
||||
{
|
||||
$exporters = [];
|
||||
foreach ($config['exporters'] ?? [] as $name => $exporterConfig) {
|
||||
if (isset($exporterConfig['enabled']) && $exporterConfig['enabled']) {
|
||||
$exporters[$name] = new ExporterConfig(
|
||||
$exporterConfig['endpoint'] ?? '',
|
||||
$exporterConfig['protocol'] ?? 'http',
|
||||
$exporterConfig['options'] ?? []
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return new self(
|
||||
$config['service_name'] ?? 'app',
|
||||
$config['service_version'] ?? '1.0.0',
|
||||
$config['environment'] ?? 'dev',
|
||||
$config['enabled'] ?? true,
|
||||
$config['sampling_ratio'] ?? 1.0,
|
||||
$exporters,
|
||||
$config['resource_attributes'] ?? []
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get service name
|
||||
*/
|
||||
public function getServiceName(): string
|
||||
{
|
||||
return $this->serviceName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get service version
|
||||
*/
|
||||
public function getServiceVersion(): string
|
||||
{
|
||||
return $this->serviceVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get environment
|
||||
*/
|
||||
public function getEnvironment(): string
|
||||
{
|
||||
return $this->environment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sampling ratio
|
||||
*/
|
||||
public function getSamplingRatio(): float
|
||||
{
|
||||
return $this->samplingRatio;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get exporters
|
||||
*
|
||||
* @return array<string, ExporterConfig>
|
||||
*/
|
||||
public function getExporters(): array
|
||||
{
|
||||
return $this->exporters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get resource attributes
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function getResourceAttributes(): array
|
||||
{
|
||||
return $this->resourceAttributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if telemetry is enabled
|
||||
*/
|
||||
public function isEnabled(): bool
|
||||
{
|
||||
return $this->enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all resource attributes including standard ones
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function getAllResourceAttributes(): array
|
||||
{
|
||||
return array_merge([
|
||||
'service.name' => $this->serviceName,
|
||||
'service.version' => $this->serviceVersion,
|
||||
'deployment.environment' => $this->environment,
|
||||
], $this->resourceAttributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an exporter is configured
|
||||
*/
|
||||
public function hasExporter(string $name): bool
|
||||
{
|
||||
return isset($this->exporters[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an exporter configuration
|
||||
*/
|
||||
public function getExporter(string $name): ?ExporterConfig
|
||||
{
|
||||
return $this->exporters[$name] ?? null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user