ttrss/vendor/open-telemetry/sdk/Resource/Detectors/Composite.php

33 lines
854 B
PHP
Raw Normal View History

2023-10-20 14:12:29 +00:00
<?php
declare(strict_types=1);
namespace OpenTelemetry\SDK\Resource\Detectors;
use OpenTelemetry\SDK\Resource\ResourceDetectorInterface;
use OpenTelemetry\SDK\Resource\ResourceInfo;
use OpenTelemetry\SDK\Resource\ResourceInfoFactory;
final class Composite implements ResourceDetectorInterface
{
private iterable $resourceDetectors;
/**
* @param iterable<ResourceDetectorInterface> $resourceDetectors
*/
public function __construct(iterable $resourceDetectors)
{
$this->resourceDetectors = $resourceDetectors;
}
public function getResource(): ResourceInfo
{
$resource = ResourceInfoFactory::emptyResource();
foreach ($this->resourceDetectors as $resourceDetector) {
$resource = $resource->merge($resourceDetector->getResource());
}
return $resource;
}
}