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