@@ -30,7 +30,7 @@ |
||
| 30 | 30 | */ |
| 31 | 31 | public static function new(array $metrics, callable $worker, int $period = 5) : string |
| 32 | 32 | { |
| 33 | - $idg = sprintf('tw-%d', self::$idg ++); |
|
| 33 | + $idg = sprintf('tw-%d', self::$idg++); |
|
| 34 | 34 | |
| 35 | 35 | (self::$worker ?? self::$worker = new TWorker) |
| 36 | 36 | ->adding($idg, $metrics, $worker, $period) |
@@ -43,12 +43,12 @@ |
||
| 43 | 43 | { |
| 44 | 44 | foreach ($this->bounds as $idx => $bound) { |
| 45 | 45 | if ($v < $bound) { |
| 46 | - $this->buckets[$idx] ++; |
|
| 46 | + $this->buckets[$idx]++; |
|
| 47 | 47 | break; |
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - $this->count ++; |
|
| 51 | + $this->count++; |
|
| 52 | 52 | $this->sum += $v; |
| 53 | 53 | } |
| 54 | 54 | } |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | count($this->samples) > $this->threshold && $this->compress(); |
| 73 | 73 | |
| 74 | - $this->count ++; |
|
| 74 | + $this->count++; |
|
| 75 | 75 | $this->sum += $v; |
| 76 | 76 | } |
| 77 | 77 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | $desired = intval($quantile * $this->count); |
| 87 | 87 | |
| 88 | - for ($i = 1; $i < count($this->samples); $i ++) { |
|
| 88 | + for ($i = 1; $i < count($this->samples); $i++) { |
|
| 89 | 89 | $sp = $this->samples[$i - 1]; |
| 90 | 90 | $sc = $this->samples[$i]; |
| 91 | 91 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | private function compress() : void |
| 103 | 103 | { |
| 104 | - for ($i = 0; $i < count($this->samples) - 1; $i ++) { |
|
| 104 | + for ($i = 0; $i < count($this->samples) - 1; $i++) { |
|
| 105 | 105 | $sa = $this->samples[$i]; |
| 106 | 106 | $sb = $this->samples[$i + 1]; |
| 107 | 107 | |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | return $ik; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - $this->timers[$ik] = Timer::loop($period * 1000, static function () use ($ik, $do) { |
|
| 34 | + $this->timers[$ik] = Timer::loop($period * 1000, static function() use ($ik, $do) { |
|
| 35 | 35 | call_user_func($do, $ik); |
| 36 | 36 | }); |
| 37 | 37 | |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | { |
| 35 | 35 | $bounds = []; |
| 36 | 36 | |
| 37 | - for ($i = 0; $i < $count; $i ++) { |
|
| 37 | + for ($i = 0; $i < $count; $i++) { |
|
| 38 | 38 | $bounds[] = $start; |
| 39 | 39 | $start += $width; |
| 40 | 40 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | { |
| 53 | 53 | $bounds = []; |
| 54 | 54 | |
| 55 | - for ($i = 0; $i < $count; $i ++) { |
|
| 55 | + for ($i = 0; $i < $count; $i++) { |
|
| 56 | 56 | $bounds[] = $start; |
| 57 | 57 | $start *= $factor; |
| 58 | 58 | } |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | try { |
| 84 | 84 | ($this->httpd = Server::httpd( |
| 85 | 85 | $listen, |
| 86 | - function (Connection $conn) { |
|
| 86 | + function(Connection $conn) { |
|
| 87 | 87 | switch ($conn->request()->getUri()->getPath()) { |
| 88 | 88 | case '/metrics': |
| 89 | 89 | $conn->reply(new Response( |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | goto END; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - $this->pushd = Timer::loop(self::ACT_PUSH_INV, co(function () use ($listen, $push) { |
|
| 115 | + $this->pushd = Timer::loop(self::ACT_PUSH_INV, co(function() use ($listen, $push) { |
|
| 116 | 116 | yield $this->pushing(Client::post( |
| 117 | 117 | $this->gate = sprintf( |
| 118 | 118 | 'http://%s:%d/metrics/job/%s/instance/%s', |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | public function stop() : void |
| 139 | 139 | { |
| 140 | 140 | $this->httpd && $this->httpd->shutdown(); |
| 141 | - $this->pushd && Timer::clear($this->pushd) && co(function () { |
|
| 141 | + $this->pushd && Timer::clear($this->pushd) && co(function() { |
|
| 142 | 142 | $this->gate && yield $this->pushing(Client::delete($this->gate), 'removing'); |
| 143 | 143 | })(); |
| 144 | 144 | } |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | */ |
| 169 | 169 | private function exporting(bool $push = false) : string |
| 170 | 170 | { |
| 171 | - $now = $push ? 0 : (int)(microtime(true) * 1000); |
|
| 171 | + $now = $push ? 0 : (int) (microtime(true) * 1000); |
|
| 172 | 172 | |
| 173 | 173 | $lines = $types = []; |
| 174 | 174 | |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | |
| 239 | 239 | $labeling = []; |
| 240 | 240 | |
| 241 | - array_walk($merged, function (string $v, string $k) use (&$labeling) { |
|
| 241 | + array_walk($merged, function(string $v, string $k) use (&$labeling) { |
|
| 242 | 242 | $labeling[] = sprintf('%s="%s"', $k, $v); |
| 243 | 243 | }); |
| 244 | 244 | |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | public function __construct() |
| 21 | 21 | { |
| 22 | - Ticker::new([Metrics::gauge()->named('memory.usage.bytes')], static function (Gauge $memory) { |
|
| 22 | + Ticker::new([Metrics::gauge()->named('memory.usage.bytes')], static function(Gauge $memory) { |
|
| 23 | 23 | $memory->set(memory_get_usage()); |
| 24 | 24 | }); |
| 25 | 25 | } |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | Metrics::gauge()->named('pool.conn.busy')->labels($labels), |
| 38 | 38 | Metrics::gauge()->named('pool.select.wait')->labels($labels), |
| 39 | 39 | ], |
| 40 | - static function (Gauge $idle, Gauge $busy, Gauge $wait) use ($pool) { |
|
| 40 | + static function(Gauge $idle, Gauge $busy, Gauge $wait) use ($pool) { |
|
| 41 | 41 | $idle->set($pool->stats()->cIdling()); |
| 42 | 42 | $busy->set($pool->stats()->cBusying()); |
| 43 | 43 | $wait->set($pool->stats()->sPending()); |
@@ -107,7 +107,7 @@ |
||
| 107 | 107 | 'system', |
| 108 | 108 | '', |
| 109 | 109 | [], |
| 110 | - ['value' => ++ $this->crashed] |
|
| 110 | + ['value' => ++$this->crashed] |
|
| 111 | 111 | ); |
| 112 | 112 | } |
| 113 | 113 | } |