@@ -23,7 +23,7 @@ |
||
23 | 23 | $actual = count($labels); |
24 | 24 | |
25 | 25 | if ($expected !== $actual) { |
26 | - throw new LabelException("Expected {$expected} label values but {$actual} were given."); |
|
26 | + throw new LabelException("expected {$expected} label values but {$actual} were given."); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | return new Collection([ |
@@ -89,9 +89,11 @@ discard block |
||
89 | 89 | } |
90 | 90 | |
91 | 91 | return $builder->samples(); |
92 | - } catch (LabelException $e) { |
|
92 | + } |
|
93 | + catch (LabelException $e) { |
|
93 | 94 | throw $e; |
94 | - } catch (Exception $e) { |
|
95 | + } |
|
96 | + catch (Exception $e) { |
|
95 | 97 | $class = get_class($metric); |
96 | 98 | |
97 | 99 | throw new StorageException("Failed to collect the samples of [{$class}]: {$e->getMessage()}", 0, $e); |
@@ -109,9 +111,11 @@ discard block |
||
109 | 111 | $this->labeled($metric, $labels)->toJson(), |
110 | 112 | $value |
111 | 113 | ); |
112 | - } catch (LabelException $e) { |
|
114 | + } |
|
115 | + catch (LabelException $e) { |
|
113 | 116 | throw $e; |
114 | - } catch (Exception $e) { |
|
117 | + } |
|
118 | + catch (Exception $e) { |
|
115 | 119 | $class = get_class($metric); |
116 | 120 | |
117 | 121 | throw new StorageException("Failed to increment [{$class}] by `{$value}`: {$e->getMessage()}", 0, $e); |
@@ -129,9 +133,11 @@ discard block |
||
129 | 133 | $this->labeled($metric, $labels)->toJson(), |
130 | 134 | $value |
131 | 135 | ); |
132 | - } catch (LabelException $e) { |
|
136 | + } |
|
137 | + catch (LabelException $e) { |
|
133 | 138 | throw $e; |
134 | - } catch (Exception $e) { |
|
139 | + } |
|
140 | + catch (Exception $e) { |
|
135 | 141 | $class = get_class($metric); |
136 | 142 | |
137 | 143 | throw new StorageException("Failed to decrement [{$class}] by `{$value}`: {$e->getMessage()}", 0, $e); |
@@ -146,9 +152,11 @@ discard block |
||
146 | 152 | try { |
147 | 153 | $this->binding(self::OBSERVER_BINDING_KEY, $metric) |
148 | 154 | ($metric, $this->labeled($metric, $labels), $value); |
149 | - } catch (LabelException $e) { |
|
155 | + } |
|
156 | + catch (LabelException $e) { |
|
150 | 157 | throw $e; |
151 | - } catch (Exception $e) { |
|
158 | + } |
|
159 | + catch (Exception $e) { |
|
152 | 160 | $class = get_class($metric); |
153 | 161 | |
154 | 162 | throw new StorageException("Failed to observe [{$class}] with `{$value}`: {$e->getMessage()}", 0, $e); |
@@ -166,9 +174,11 @@ discard block |
||
166 | 174 | $this->labeled($metric, $labels)->toJson(), |
167 | 175 | $value |
168 | 176 | ); |
169 | - } catch (LabelException $e) { |
|
177 | + } |
|
178 | + catch (LabelException $e) { |
|
170 | 179 | throw $e; |
171 | - } catch (Exception $e) { |
|
180 | + } |
|
181 | + catch (Exception $e) { |
|
172 | 182 | $class = get_class($metric); |
173 | 183 | |
174 | 184 | throw new StorageException("Failed to set [{$class}] to `{$value}`: {$e->getMessage()}", 0, $e); |
@@ -81,7 +81,7 @@ |
||
81 | 81 | public function unregister(Metric $metric): self |
82 | 82 | { |
83 | 83 | $this->collector($metric) |
84 | - ->forget(get_class($metric)); |
|
84 | + ->forget(get_class($metric)); |
|
85 | 85 | |
86 | 86 | return $this; |
87 | 87 | } |
@@ -15,7 +15,8 @@ discard block |
||
15 | 15 | public function enabled(): MetricFamilySamples |
16 | 16 | { |
17 | 17 | return $this->sampled( |
18 | - new class extends Gauge { |
|
18 | + new class extends Gauge |
|
19 | + { |
|
19 | 20 | protected $namespace = 'php_opcache'; |
20 | 21 | protected $name = 'enabled'; |
21 | 22 | protected $description = 'Indicator if opcache is enabled.'; |
@@ -30,7 +31,8 @@ discard block |
||
30 | 31 | public function oom(): MetricFamilySamples |
31 | 32 | { |
32 | 33 | return $this->sampled( |
33 | - new class extends Gauge { |
|
34 | + new class extends Gauge |
|
35 | + { |
|
34 | 36 | protected $namespace = 'php_opcache'; |
35 | 37 | protected $name = 'out_of_memory'; |
36 | 38 | protected $description = 'Indicator if cache is full.'; |
@@ -45,7 +47,8 @@ discard block |
||
45 | 47 | public function restarts(): MetricFamilySamples |
46 | 48 | { |
47 | 49 | return $this->sampled( |
48 | - new class extends Gauge { |
|
50 | + new class extends Gauge |
|
51 | + { |
|
49 | 52 | protected $namespace = 'php_opcache'; |
50 | 53 | protected $name = 'restart_pending'; |
51 | 54 | protected $description = 'Indicator if a restart is pending'; |
@@ -60,7 +63,8 @@ discard block |
||
60 | 63 | public function restarting(): MetricFamilySamples |
61 | 64 | { |
62 | 65 | return $this->sampled( |
63 | - new class extends Gauge { |
|
66 | + new class extends Gauge |
|
67 | + { |
|
64 | 68 | protected $namespace = 'php_opcache'; |
65 | 69 | protected $name = 'is_restarting'; |
66 | 70 | protected $description = 'Indicator if a restart is in progress.'; |
@@ -75,7 +79,8 @@ discard block |
||
75 | 79 | public function consumed(): MetricFamilySamples |
76 | 80 | { |
77 | 81 | return $this->sampled( |
78 | - new class extends Gauge { |
|
82 | + new class extends Gauge |
|
83 | + { |
|
79 | 84 | protected $namespace = 'php_opcache'; |
80 | 85 | protected $name = 'memory_used_bytes'; |
81 | 86 | protected $description = 'The amount of memory consumed.'; |
@@ -90,7 +95,8 @@ discard block |
||
90 | 95 | public function free(): MetricFamilySamples |
91 | 96 | { |
92 | 97 | return $this->sampled( |
93 | - new class extends Gauge { |
|
98 | + new class extends Gauge |
|
99 | + { |
|
94 | 100 | protected $namespace = 'php_opcache'; |
95 | 101 | protected $name = 'memory_free_bytes'; |
96 | 102 | protected $description = 'The amount of memory available for consumption.'; |
@@ -105,7 +111,8 @@ discard block |
||
105 | 111 | public function wasted(): MetricFamilySamples |
106 | 112 | { |
107 | 113 | return $this->sampled( |
108 | - new class extends Gauge { |
|
114 | + new class extends Gauge |
|
115 | + { |
|
109 | 116 | protected $namespace = 'php_opcache'; |
110 | 117 | protected $name = 'memory_wasted_bytes'; |
111 | 118 | protected $description = 'The amount of memory wasted.'; |
@@ -120,7 +127,8 @@ discard block |
||
120 | 127 | public function wastePercentage(): MetricFamilySamples |
121 | 128 | { |
122 | 129 | return $this->sampled( |
123 | - new class extends Gauge { |
|
130 | + new class extends Gauge |
|
131 | + { |
|
124 | 132 | protected $namespace = 'php_opcache'; |
125 | 133 | protected $name = 'memory_wasted_percent'; |
126 | 134 | protected $description = 'The percentage of currently wasted memory.'; |
@@ -135,7 +143,8 @@ discard block |
||
135 | 143 | public function stringsBuffer(): MetricFamilySamples |
136 | 144 | { |
137 | 145 | return $this->sampled( |
138 | - new class extends Counter { |
|
146 | + new class extends Counter |
|
147 | + { |
|
139 | 148 | protected $namespace = 'php_opcache'; |
140 | 149 | protected $name = 'strings_buffer_size_bytes'; |
141 | 150 | protected $description = 'The buffer size of interned strings.'; |
@@ -150,7 +159,8 @@ discard block |
||
150 | 159 | public function stringsMemoryConsumed(): MetricFamilySamples |
151 | 160 | { |
152 | 161 | return $this->sampled( |
153 | - new class extends Gauge { |
|
162 | + new class extends Gauge |
|
163 | + { |
|
154 | 164 | protected $namespace = 'php_opcache'; |
155 | 165 | protected $name = 'strings_memory_used_bytes'; |
156 | 166 | protected $description = 'The amount of memory used by interned strings.'; |
@@ -165,7 +175,8 @@ discard block |
||
165 | 175 | public function stringsMemoryFree(): MetricFamilySamples |
166 | 176 | { |
167 | 177 | return $this->sampled( |
168 | - new class extends Gauge { |
|
178 | + new class extends Gauge |
|
179 | + { |
|
169 | 180 | protected $namespace = 'php_opcache'; |
170 | 181 | protected $name = 'strings_memory_free_bytes'; |
171 | 182 | protected $description = 'The amount of memory available for interned strings.'; |
@@ -180,7 +191,8 @@ discard block |
||
180 | 191 | public function strings(): MetricFamilySamples |
181 | 192 | { |
182 | 193 | return $this->sampled( |
183 | - new class extends Counter { |
|
194 | + new class extends Counter |
|
195 | + { |
|
184 | 196 | protected $namespace = 'php_opcache'; |
185 | 197 | protected $name = 'strings_count'; |
186 | 198 | protected $description = 'The amount of used interned strings'; |
@@ -195,7 +207,8 @@ discard block |
||
195 | 207 | public function scripts(): MetricFamilySamples |
196 | 208 | { |
197 | 209 | return $this->sampled( |
198 | - new class extends Counter { |
|
210 | + new class extends Counter |
|
211 | + { |
|
199 | 212 | protected $namespace = 'php_opcache'; |
200 | 213 | protected $name = 'cache_scripts_count'; |
201 | 214 | protected $description = 'The amount of cached scripts.'; |
@@ -210,7 +223,8 @@ discard block |
||
210 | 223 | public function keys(): MetricFamilySamples |
211 | 224 | { |
212 | 225 | return $this->sampled( |
213 | - new class extends Counter { |
|
226 | + new class extends Counter |
|
227 | + { |
|
214 | 228 | protected $namespace = 'php_opcache'; |
215 | 229 | protected $name = 'cache_keys_count'; |
216 | 230 | protected $description = 'The amount of hash table keys.'; |
@@ -225,7 +239,8 @@ discard block |
||
225 | 239 | public function maxCachedKeys(): MetricFamilySamples |
226 | 240 | { |
227 | 241 | return $this->sampled( |
228 | - new class extends Gauge { |
|
242 | + new class extends Gauge |
|
243 | + { |
|
229 | 244 | protected $namespace = 'php_opcache'; |
230 | 245 | protected $name = 'cache_max_keys_count'; |
231 | 246 | protected $description = 'The maximum amount of hash table keys.'; |
@@ -240,7 +255,8 @@ discard block |
||
240 | 255 | public function hits(): MetricFamilySamples |
241 | 256 | { |
242 | 257 | return $this->sampled( |
243 | - new class extends Counter { |
|
258 | + new class extends Counter |
|
259 | + { |
|
244 | 260 | protected $namespace = 'php_opcache'; |
245 | 261 | protected $name = 'cache_hits_count'; |
246 | 262 | protected $description = 'The amount of cache hits.'; |
@@ -255,7 +271,8 @@ discard block |
||
255 | 271 | public function started(): MetricFamilySamples |
256 | 272 | { |
257 | 273 | return $this->sampled( |
258 | - new class extends Counter { |
|
274 | + new class extends Counter |
|
275 | + { |
|
259 | 276 | protected $namespace = 'php_opcache'; |
260 | 277 | protected $name = 'started'; |
261 | 278 | protected $description = 'The timestamp opcache has been started.'; |
@@ -270,7 +287,8 @@ discard block |
||
270 | 287 | public function restart(): MetricFamilySamples |
271 | 288 | { |
272 | 289 | return $this->sampled( |
273 | - new class extends Counter { |
|
290 | + new class extends Counter |
|
291 | + { |
|
274 | 292 | protected $namespace = 'php_opcache'; |
275 | 293 | protected $name = 'last_restart'; |
276 | 294 | protected $description = 'The last timestamp opcache has been restarted.'; |
@@ -285,7 +303,8 @@ discard block |
||
285 | 303 | public function oomRestarts(): MetricFamilySamples |
286 | 304 | { |
287 | 305 | return $this->sampled( |
288 | - new class extends Counter { |
|
306 | + new class extends Counter |
|
307 | + { |
|
289 | 308 | protected $namespace = 'php_opcache'; |
290 | 309 | protected $name = 'restarts_oom_count'; |
291 | 310 | protected $description = 'The amount of out of memory restarts.'; |
@@ -300,7 +319,8 @@ discard block |
||
300 | 319 | public function hashRestarts(): MetricFamilySamples |
301 | 320 | { |
302 | 321 | return $this->sampled( |
303 | - new class extends Counter { |
|
322 | + new class extends Counter |
|
323 | + { |
|
304 | 324 | protected $namespace = 'php_opcache'; |
305 | 325 | protected $name = 'restarts_hash_count'; |
306 | 326 | protected $description = 'The amount of hash table overflow restarts.'; |
@@ -315,7 +335,8 @@ discard block |
||
315 | 335 | public function manualRestarts(): MetricFamilySamples |
316 | 336 | { |
317 | 337 | return $this->sampled( |
318 | - new class extends Counter { |
|
338 | + new class extends Counter |
|
339 | + { |
|
319 | 340 | protected $namespace = 'php_opcache'; |
320 | 341 | protected $name = 'restarts_manual_count'; |
321 | 342 | protected $description = 'The amount of manual restarts.'; |
@@ -330,7 +351,8 @@ discard block |
||
330 | 351 | public function misses(): MetricFamilySamples |
331 | 352 | { |
332 | 353 | return $this->sampled( |
333 | - new class extends Counter { |
|
354 | + new class extends Counter |
|
355 | + { |
|
334 | 356 | protected $namespace = 'php_opcache'; |
335 | 357 | protected $name = 'cache_misses_count'; |
336 | 358 | protected $description = 'The amount of cache misses.'; |
@@ -345,7 +367,8 @@ discard block |
||
345 | 367 | public function blacklistMisses(): MetricFamilySamples |
346 | 368 | { |
347 | 369 | return $this->sampled( |
348 | - new class extends Counter { |
|
370 | + new class extends Counter |
|
371 | + { |
|
349 | 372 | protected $namespace = 'php_opcache'; |
350 | 373 | protected $name = 'cache_blacklist_misses_count'; |
351 | 374 | protected $description = 'The amount of blacklist cache misses.'; |
@@ -360,7 +383,8 @@ discard block |
||
360 | 383 | public function blacklistMissRatio(): MetricFamilySamples |
361 | 384 | { |
362 | 385 | return $this->sampled( |
363 | - new class extends Gauge { |
|
386 | + new class extends Gauge |
|
387 | + { |
|
364 | 388 | protected $namespace = 'php_opcache'; |
365 | 389 | protected $name = 'cache_blacklist_misses_percent'; |
366 | 390 | protected $description = 'The percentage of blacklist cache misses. '; |
@@ -375,7 +399,8 @@ discard block |
||
375 | 399 | public function hitRatio(): MetricFamilySamples |
376 | 400 | { |
377 | 401 | return $this->sampled( |
378 | - new class extends Gauge { |
|
402 | + new class extends Gauge |
|
403 | + { |
|
379 | 404 | protected $namespace = 'php_opcache'; |
380 | 405 | protected $name = 'cache_hit_percent'; |
381 | 406 | protected $description = 'The percentage of cache hits.'; |
@@ -17,7 +17,8 @@ discard block |
||
17 | 17 | public function uptime(): MetricFamilySamples |
18 | 18 | { |
19 | 19 | return $this->sampled( |
20 | - new class extends Counter { |
|
20 | + new class extends Counter |
|
21 | + { |
|
21 | 22 | protected $namespace = 'php_fpm'; |
22 | 23 | protected $name = 'uptime_seconds'; |
23 | 24 | protected $description = 'The number of seconds since FPM has started.'; |
@@ -36,7 +37,8 @@ discard block |
||
36 | 37 | public function connections(): MetricFamilySamples |
37 | 38 | { |
38 | 39 | return $this->sampled( |
39 | - new class extends Counter { |
|
40 | + new class extends Counter |
|
41 | + { |
|
40 | 42 | protected $namespace = 'php_fpm'; |
41 | 43 | protected $name = 'connections_total'; |
42 | 44 | protected $description = 'The number of requests accepted.'; |
@@ -55,7 +57,8 @@ discard block |
||
55 | 57 | public function queued(): MetricFamilySamples |
56 | 58 | { |
57 | 59 | return $this->sampled( |
58 | - new class extends Gauge { |
|
60 | + new class extends Gauge |
|
61 | + { |
|
59 | 62 | protected $namespace = 'php_fpm'; |
60 | 63 | protected $name = 'connections_queued_count'; |
61 | 64 | protected $description = 'The number of request in the queue of pending connections.'; |
@@ -74,7 +77,8 @@ discard block |
||
74 | 77 | public function maxQueued(): MetricFamilySamples |
75 | 78 | { |
76 | 79 | return $this->sampled( |
77 | - new class extends Counter { |
|
80 | + new class extends Counter |
|
81 | + { |
|
78 | 82 | protected $namespace = 'php_fpm'; |
79 | 83 | protected $name = 'connections_max_queued_count'; |
80 | 84 | protected $description = 'The maximum number of requests in the queue of pending connections.'; |
@@ -93,7 +97,8 @@ discard block |
||
93 | 97 | public function queue(): MetricFamilySamples |
94 | 98 | { |
95 | 99 | return $this->sampled( |
96 | - new class extends Gauge { |
|
100 | + new class extends Gauge |
|
101 | + { |
|
97 | 102 | protected $namespace = 'php_fpm'; |
98 | 103 | protected $name = 'connections_queue_size'; |
99 | 104 | protected $description = 'The size of the socket queue for pending connections.'; |
@@ -112,7 +117,8 @@ discard block |
||
112 | 117 | public function idle(): MetricFamilySamples |
113 | 118 | { |
114 | 119 | return $this->sampled( |
115 | - new class extends Gauge { |
|
120 | + new class extends Gauge |
|
121 | + { |
|
116 | 122 | protected $namespace = 'php_fpm'; |
117 | 123 | protected $name = 'processes_idle_count'; |
118 | 124 | protected $description = 'The number of idle processes.'; |
@@ -131,7 +137,8 @@ discard block |
||
131 | 137 | public function active(): MetricFamilySamples |
132 | 138 | { |
133 | 139 | return $this->sampled( |
134 | - new class extends Gauge { |
|
140 | + new class extends Gauge |
|
141 | + { |
|
135 | 142 | protected $namespace = 'php_fpm'; |
136 | 143 | protected $name = 'processes_active_count'; |
137 | 144 | protected $description = 'The number of active processes.'; |
@@ -150,7 +157,8 @@ discard block |
||
150 | 157 | public function total(): MetricFamilySamples |
151 | 158 | { |
152 | 159 | return $this->sampled( |
153 | - new class extends Gauge { |
|
160 | + new class extends Gauge |
|
161 | + { |
|
154 | 162 | protected $namespace = 'php_fpm'; |
155 | 163 | protected $name = 'processes_total'; |
156 | 164 | protected $description = 'The number of idle and active processes.'; |
@@ -169,7 +177,8 @@ discard block |
||
169 | 177 | public function maxActive(): MetricFamilySamples |
170 | 178 | { |
171 | 179 | return $this->sampled( |
172 | - new class extends Counter { |
|
180 | + new class extends Counter |
|
181 | + { |
|
173 | 182 | protected $namespace = 'php_fpm'; |
174 | 183 | protected $name = 'processes_max_active_count'; |
175 | 184 | protected $description = 'The maximum number of active processes since FPM has started.'; |
@@ -188,7 +197,8 @@ discard block |
||
188 | 197 | public function maxSpawned(): MetricFamilySamples |
189 | 198 | { |
190 | 199 | return $this->sampled( |
191 | - new class extends Counter { |
|
200 | + new class extends Counter |
|
201 | + { |
|
192 | 202 | protected $namespace = 'php_fpm'; |
193 | 203 | protected $name = 'processes_limit_reached_count'; |
194 | 204 | protected $description = 'The number of times the process limit has been reached when trying to start more children.'; |
@@ -207,7 +217,8 @@ discard block |
||
207 | 217 | public function slow(): MetricFamilySamples |
208 | 218 | { |
209 | 219 | return $this->sampled( |
210 | - new class extends Counter { |
|
220 | + new class extends Counter |
|
221 | + { |
|
211 | 222 | protected $namespace = 'php_fpm'; |
212 | 223 | protected $name = 'connections_slow_count'; |
213 | 224 | protected $description = 'The number of requests exceeding the configured \'request_slowlog_timeout\' value.'; |
@@ -234,7 +245,8 @@ discard block |
||
234 | 245 | |
235 | 246 | return new Collection([ |
236 | 247 | $this->sampled( |
237 | - new class extends Counter { |
|
248 | + new class extends Counter |
|
249 | + { |
|
238 | 250 | protected $namespace = 'php_fpm'; |
239 | 251 | protected $name = 'process_requests_total'; |
240 | 252 | protected $description = 'The number of requests the process has served.'; |
@@ -248,7 +260,8 @@ discard block |
||
248 | 260 | ), |
249 | 261 | |
250 | 262 | $this->sampled( |
251 | - new class extends Gauge { |
|
263 | + new class extends Gauge |
|
264 | + { |
|
252 | 265 | protected $namespace = 'php_fpm'; |
253 | 266 | protected $name = 'process_requests_duration_microseconds'; |
254 | 267 | protected $description = 'The duration in microseconds of the requests.'; |
@@ -262,7 +275,8 @@ discard block |
||
262 | 275 | ), |
263 | 276 | |
264 | 277 | $this->sampled( |
265 | - new class extends Gauge { |
|
278 | + new class extends Gauge |
|
279 | + { |
|
266 | 280 | protected $namespace = 'php_fpm'; |
267 | 281 | protected $name = 'process_last_cpu_percent'; |
268 | 282 | protected $description = 'The percentage of cpu the last request consumed.'; |
@@ -276,7 +290,8 @@ discard block |
||
276 | 290 | ), |
277 | 291 | |
278 | 292 | $this->sampled( |
279 | - new class extends Gauge { |
|
293 | + new class extends Gauge |
|
294 | + { |
|
280 | 295 | protected $namespace = 'php_fpm'; |
281 | 296 | protected $name = 'process_last_memory_bytes'; |
282 | 297 | protected $description = 'The amount of memory the last request consumed.'; |
@@ -36,7 +36,7 @@ |
||
36 | 36 | ::parse() |
37 | 37 | ->flatMap(function (array $item) use ($quantiles) { |
38 | 38 | ['name' => $name, |
39 | - 'labels' => $labels] = $item; |
|
39 | + 'labels' => $labels] = $item; |
|
40 | 40 | |
41 | 41 | $values = !$item['value'] instanceof Collection |
42 | 42 | ? new Collection |