-
Notifications
You must be signed in to change notification settings - Fork 3
/
SpanInterface.php
117 lines (100 loc) · 2.97 KB
/
SpanInterface.php
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
<?php
declare(strict_types=1);
namespace Psr\Tracing;
use Stringable;
use Throwable;
/**
* A span represents a single operation within a trace.
* NOTE: This object is MUTABLE.
*/
interface SpanInterface
{
public const STATUS_UNSET = 0;
public const STATUS_ERROR = 100;
public const STATUS_OK = 200;
/**
* Sets a single attribute on the span.
* NOTE: value MUST be a scalar (or stringable) value, nesting is supported via key "dot notation"
*
* @return $this
*/
public function setAttribute(string $key, null|string|int|float|bool|Stringable $value): SpanInterface;
/**
* Retrieves a single attribute from the span
* nesting is supported via key "dot notation"
*
* @param string $key
*
* @return null|string|int|float|bool|Stringable
*/
public function getAttribute(string $key): null|string|int|float|bool|Stringable;
/**
* Sets multiple attributes on this span.
*
* @param iterable<string, string|int|float|bool|Stringable> $attributes
*
* @return $this
*/
public function setAttributes(iterable $attributes): SpanInterface;
/**
* Gets all attributes on this span.
*
* @return iterable<string, string|int|float|bool|Stringable>
*/
public function getAttributes(): iterable;
/**
* Starts the current span.
*
* @return $this
*/
public function start(): SpanInterface;
/**
* Sets the current span as the "current" span.
* This MUST start the span if not already started.
*
* @return $this
*/
public function activate(): SpanInterface;
/**
* Set the status of this span to one of self::STATUS_*
* Description is optional, and MAY be used to describe an error status.
*
* @return $this
*/
public function setStatus(int $status, ?string $description): SpanInterface;
/**
* Record an exception against this span.
* This MUST NOT modify the span's outcome.
*
* @param Throwable $t
* @return $this
*/
public function addException(Throwable $t): SpanInterface;
/**
* Marks this span as ended (sets the end timestamp) and pops out the
* span re-setting the parent as the active one.
*/
public function finish(): void;
/**
* Create a new child span.
* This is similar to {@see TracerInterface::createSpan}, but MUST set the parent to the current span.
*
* @param string $spanName
* @return SpanInterface
*/
public function createChild(string $spanName): SpanInterface;
/**
* Returns distributed tracing headers, to allow trace correlation across service boundaries.
*/
public function toTraceContextHeaders(): array;
/**
* Returns the parent span
* @return SpanInterface
*/
public function getParent(): SpanInterface;
/**
* Returns the child spans
* @return array<SpanInterface>
*/
public function getChildren(): array;
}