blob: e690791f2dd0916d6792defb6cd32118b083fdd3 (
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
<?php
declare(strict_types=1);
namespace OpenTelemetry\SDK\Trace\SpanProcessor;
use OpenTelemetry\Context\ContextInterface;
use OpenTelemetry\SDK\Common\Future\CancellationInterface;
use OpenTelemetry\SDK\Trace\ReadableSpanInterface;
use OpenTelemetry\SDK\Trace\ReadWriteSpanInterface;
use OpenTelemetry\SDK\Trace\SpanProcessorInterface;
/**
* Class SpanMultiProcessor is a SpanProcessor that forwards all events to an
* array of SpanProcessors.
*/
final class MultiSpanProcessor implements SpanProcessorInterface
{
/** @var list<SpanProcessorInterface> */
private array $processors = [];
public function __construct(SpanProcessorInterface ...$spanProcessors)
{
foreach ($spanProcessors as $processor) {
$this->addSpanProcessor($processor);
}
}
public function addSpanProcessor(SpanProcessorInterface $processor): void
{
$this->processors[] = $processor;
}
/** @return list<SpanProcessorInterface> */
public function getSpanProcessors(): array
{
return $this->processors;
}
/** @inheritDoc */
public function onStart(ReadWriteSpanInterface $span, ContextInterface $parentContext): void
{
foreach ($this->processors as $processor) {
$processor->onStart($span, $parentContext);
}
}
/** @inheritDoc */
public function onEnd(ReadableSpanInterface $span): void
{
foreach ($this->processors as $processor) {
$processor->onEnd($span);
}
}
/** @inheritDoc */
public function shutdown(?CancellationInterface $cancellation = null): bool
{
$result = true;
foreach ($this->processors as $processor) {
$result = $result && $processor->shutdown();
}
return $result;
}
/** @inheritDoc */
public function forceFlush(?CancellationInterface $cancellation = null): bool
{
$result = true;
foreach ($this->processors as $processor) {
$result = $result && $processor->forceFlush();
}
return $result;
}
}
|