SystemCollector   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 14
c 1
b 0
f 1
dl 0
loc 24
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A collect() 0 22 1
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace Hhxsv5\LaravelS\Components\Prometheus\Collectors;
4
5
use Hhxsv5\LaravelS\Components\MetricCollector;
6
7
class SystemCollector extends MetricCollector
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class SystemCollector
Loading history...
8
{
9
    public function collect(array $params = [])
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function collect()
Loading history...
10
    {
11
        $load = sys_getloadavg();
12
        $metrics = [
13
            [
14
                'name'  => 'system_load_average_1m',
15
                'type'  => 'gauge',
16
                'value' => $load[0],
17
            ],
18
            [
19
                'name'  => 'system_load_average_5m',
20
                'type'  => 'gauge',
21
                'value' => $load[1],
22
            ],
23
            [
24
                'name'  => 'system_load_average_15m',
25
                'type'  => 'gauge',
26
                'value' => $load[2],
27
            ],
28
        ];
29
        $key = implode($this->config['apcu_key_separator'], [$this->config['apcu_key_prefix'], 'system_stats', '', '']);
30
        apcu_store($key, $metrics, $this->config['apcu_key_max_age']);
31
    }
32
}