summaryrefslogtreecommitdiff
path: root/vendor/open-telemetry/sdk/Metrics/MetricRegistration/MultiRegistryRegistration.php
blob: 2472c096f3252d1f348deddc8b26a70ebaaf5383 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php

declare(strict_types=1);

namespace OpenTelemetry\SDK\Metrics\MetricRegistration;

use OpenTelemetry\SDK\Metrics\MetricMetadataInterface;
use OpenTelemetry\SDK\Metrics\MetricRegistrationInterface;
use OpenTelemetry\SDK\Metrics\MetricSourceProviderInterface;
use OpenTelemetry\SDK\Metrics\MetricSourceRegistryInterface;
use OpenTelemetry\SDK\Metrics\StalenessHandlerInterface;

/**
 * @internal
 */
final class MultiRegistryRegistration implements MetricRegistrationInterface
{
    private iterable $registries;
    private StalenessHandlerInterface $stalenessHandler;

    /**
     * @param iterable<MetricSourceRegistryInterface> $registries
     */
    public function __construct(iterable $registries, StalenessHandlerInterface $stalenessHandler)
    {
        $this->registries = $registries;
        $this->stalenessHandler = $stalenessHandler;
    }

    public function register(MetricSourceProviderInterface $provider, MetricMetadataInterface $metadata): void
    {
        foreach ($this->registries as $registry) {
            $registry->add($provider, $metadata, $this->stalenessHandler);
        }
    }
}