blob: c4df8e8782bbcafa712f4d4ec3124ebd9889920f (
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
|
<?php
declare(strict_types=1);
namespace OpenTelemetry\SDK\Metrics\AttributeProcessor;
use OpenTelemetry\Context\ContextInterface;
use OpenTelemetry\SDK\Common\Attribute\Attributes;
use OpenTelemetry\SDK\Common\Attribute\AttributesInterface;
use OpenTelemetry\SDK\Metrics\AttributeProcessorInterface;
/**
* @internal
*/
final class FilteredAttributeProcessor implements AttributeProcessorInterface
{
private array $attributeKeys;
public function __construct(array $attributeKeys)
{
$this->attributeKeys = $attributeKeys;
}
public function process(AttributesInterface $attributes, ContextInterface $context): AttributesInterface
{
$filtered = [];
foreach ($this->attributeKeys as $key) {
$filtered[$key] = $attributes->get($key);
}
return new Attributes($filtered, 0);
}
}
|