blob: 6f971e52504315f04fbba681f8a46151fb7685ea (
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
|
<?php
declare(strict_types=1);
namespace OpenTelemetry\API\Trace;
use OpenTelemetry\Context\Context;
use OpenTelemetry\Context\ContextInterface;
use OpenTelemetry\Context\ContextStorageInterface;
final class NoopSpanBuilder implements SpanBuilderInterface
{
private ContextStorageInterface $contextStorage;
/** @var ContextInterface|false|null */
private $parentContext = null;
public function __construct(ContextStorageInterface $contextStorage)
{
$this->contextStorage = $contextStorage;
}
public function setParent($context): SpanBuilderInterface
{
$this->parentContext = $context;
return $this;
}
public function addLink(SpanContextInterface $context, iterable $attributes = []): SpanBuilderInterface
{
return $this;
}
public function setAttribute(string $key, $value): SpanBuilderInterface
{
return $this;
}
public function setAttributes(iterable $attributes): SpanBuilderInterface
{
return $this;
}
public function setStartTimestamp(int $timestampNanos): SpanBuilderInterface
{
return $this;
}
public function setSpanKind(int $spanKind): SpanBuilderInterface
{
return $this;
}
public function startSpan(): SpanInterface
{
$parentContext = Context::resolve($this->parentContext, $this->contextStorage);
$span = Span::fromContext($parentContext);
if ($span->isRecording()) {
$span = Span::wrap($span->getContext());
}
return $span;
}
}
|