summaryrefslogtreecommitdiff
path: root/vendor/open-telemetry/sdk/Common/Instrumentation/InstrumentationScopeFactory.php
blob: f1ae7c072de109141193bc41e0c436722681900c (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
<?php

declare(strict_types=1);

namespace OpenTelemetry\SDK\Common\Instrumentation;

use OpenTelemetry\SDK\Common\Attribute\AttributesFactoryInterface;

final class InstrumentationScopeFactory implements InstrumentationScopeFactoryInterface
{
    private AttributesFactoryInterface $attributesFactory;

    public function __construct(AttributesFactoryInterface $attributesFactory)
    {
        $this->attributesFactory = $attributesFactory;
    }

    public function create(
        string $name,
        ?string $version = null,
        ?string $schemaUrl = null,
        iterable $attributes = []
    ): InstrumentationScopeInterface {
        return new InstrumentationScope(
            $name,
            $version,
            $schemaUrl,
            $this->attributesFactory->builder($attributes)->build(),
        );
    }
}