|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace ZoiloMora\ElasticAPM\Events\Metadata; |
|
4
|
|
|
|
|
5
|
|
|
use ZoiloMora\ElasticAPM\Configuration\CoreConfiguration; |
|
6
|
|
|
use ZoiloMora\ElasticAPM\Events\Common\Process; |
|
7
|
|
|
use ZoiloMora\ElasticAPM\Events\Common\System; |
|
8
|
|
|
use ZoiloMora\ElasticAPM\Events\Common\Tags; |
|
9
|
|
|
use ZoiloMora\ElasticAPM\Events\Common\User; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Metadata concerning the other objects in the stream. |
|
13
|
|
|
*/ |
|
14
|
|
|
final class Metadata implements \JsonSerializable |
|
15
|
|
|
{ |
|
16
|
|
|
/** |
|
17
|
|
|
* @var Service |
|
18
|
|
|
*/ |
|
19
|
|
|
private $service; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @var Process|null |
|
23
|
|
|
*/ |
|
24
|
|
|
private $process; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @var System|null |
|
28
|
|
|
*/ |
|
29
|
|
|
private $system; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Describes the authenticated User for a request. |
|
33
|
|
|
* |
|
34
|
|
|
* @var User|null |
|
35
|
|
|
*/ |
|
36
|
|
|
private $user; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @var Tags|null |
|
40
|
|
|
*/ |
|
41
|
|
|
private $labels; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @param Service $service |
|
45
|
|
|
* @param Process|null $process |
|
46
|
|
|
* @param System|null $system |
|
47
|
|
|
* @param User|null $user |
|
48
|
|
|
* @param Tags|null $labels |
|
49
|
|
|
*/ |
|
50
|
12 |
|
public function __construct( |
|
51
|
|
|
Service $service, |
|
52
|
|
|
Process $process = null, |
|
53
|
|
|
System $system = null, |
|
54
|
|
|
User $user = null, |
|
55
|
|
|
Tags $labels = null |
|
56
|
|
|
) { |
|
57
|
12 |
|
$this->service = $service; |
|
58
|
12 |
|
$this->process = $process; |
|
59
|
12 |
|
$this->system = $system; |
|
60
|
12 |
|
$this->user = $user; |
|
61
|
12 |
|
$this->labels = $labels; |
|
62
|
12 |
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @return Service |
|
66
|
|
|
*/ |
|
67
|
1 |
|
public function service() |
|
68
|
|
|
{ |
|
69
|
1 |
|
return $this->service; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @return Process|null |
|
74
|
|
|
*/ |
|
75
|
2 |
|
public function process() |
|
76
|
1 |
|
{ |
|
77
|
2 |
|
return $this->process; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* @return System|null |
|
82
|
|
|
*/ |
|
83
|
1 |
|
public function system() |
|
84
|
|
|
{ |
|
85
|
1 |
|
return $this->system; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* @return User|null |
|
90
|
|
|
*/ |
|
91
|
1 |
|
public function user() |
|
92
|
|
|
{ |
|
93
|
1 |
|
return $this->user; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* @return Tags|null |
|
98
|
|
|
*/ |
|
99
|
1 |
|
public function labels() |
|
100
|
|
|
{ |
|
101
|
1 |
|
return $this->labels; |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* @param CoreConfiguration $coreConfiguration |
|
106
|
|
|
* |
|
107
|
|
|
* @return Metadata |
|
108
|
|
|
*/ |
|
109
|
10 |
|
public static function create(CoreConfiguration $coreConfiguration) |
|
110
|
|
|
{ |
|
111
|
10 |
|
return new self( |
|
112
|
10 |
|
Service::create($coreConfiguration), |
|
113
|
10 |
|
Process::discover(), |
|
114
|
10 |
|
System::discover() |
|
115
|
10 |
|
); |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
/** |
|
119
|
|
|
* @return array |
|
120
|
|
|
*/ |
|
121
|
1 |
|
public function jsonSerialize() |
|
122
|
|
|
{ |
|
123
|
|
|
return [ |
|
124
|
|
|
'metadata' => [ |
|
125
|
1 |
|
'service' => $this->service, |
|
126
|
1 |
|
'process' => $this->process, |
|
127
|
1 |
|
'system' => $this->system, |
|
128
|
1 |
|
'user' => $this->user, |
|
129
|
1 |
|
'labels' => $this->labels, |
|
130
|
|
|
] |
|
131
|
1 |
|
]; |
|
132
|
|
|
} |
|
133
|
|
|
} |
|
134
|
|
|
|