blob: 447ffd1a5c599f88f77640f465dbff0160a8b202 (
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
<?php
namespace Jaeger;
use ArrayIterator;
use OpenTracing\SpanContext as OTSpanContext;
class SpanContext implements OTSpanContext
{
private $traceId;
private $spanId;
private $parentId;
private $flags;
/**
* @var array
*/
private $baggage;
private $debugId;
/**
* SpanContext constructor.
*
* @param string $traceId
* @param string $spanId
* @param string $parentId
* @param int|null $flags
* @param array $baggage
* @param int|null $debugId
*/
public function __construct($traceId, $spanId, $parentId, $flags = null, $baggage = [], $debugId = null)
{
$this->traceId = $traceId;
$this->spanId = $spanId;
$this->parentId = $parentId;
$this->flags = $flags;
$this->baggage = is_array($baggage) ? $baggage : [];
$this->debugId = $debugId;
}
/**
* {@inheritdoc}
* @return ArrayIterator
*/
#[\ReturnTypeWillChange]
public function getIterator()
{
return new ArrayIterator($this->baggage);
}
/**
* {@inheritdoc}
*/
public function getBaggageItem(string $key): ?string
{
return array_key_exists($key, $this->baggage) ? $this->baggage[$key] : null;
}
/**
* {@inheritdoc}
*
* @param string $key
* @param string $value
* @return SpanContext
*/
public function withBaggageItem(string $key, string $value): OTSpanContext
{
return new self(
$this->traceId,
$this->spanId,
$this->parentId,
$this->flags,
[$key => $value] + $this->baggage
);
}
public function getTraceId()
{
return $this->traceId;
}
public function getParentId()
{
return $this->parentId;
}
public function getSpanId()
{
return $this->spanId;
}
/**
* Get the span context flags.
*
* @return int|null
*/
public function getFlags()
{
return $this->flags;
}
public function getBaggage()
{
return $this->baggage;
}
public function getDebugId()
{
return $this->debugId;
}
public function isDebugIdContainerOnly(): bool
{
return ($this->traceId === null) && ($this->debugId !== null);
}
}
|