1 | <?php |
||
19 | abstract class AbstractStorage { |
||
20 | |||
21 | /** |
||
22 | * @var array |
||
23 | * Holds the available metrics. |
||
24 | */ |
||
25 | protected $availableMetrics; |
||
26 | |||
27 | /** |
||
28 | * AbstractStorage constructor. |
||
29 | */ |
||
30 | public function __construct() { |
||
33 | |||
34 | /** |
||
35 | * Adds a metric to the available ones. |
||
36 | * |
||
37 | * @param string $metric |
||
38 | * the metric itself as delivered by Prometheus |
||
39 | * @param string $label |
||
40 | * the name of the one Prometheus label to categorize the values |
||
41 | * @param string $help |
||
42 | * a helping text for the metric |
||
43 | * @param string $type |
||
44 | * the Prometheus type of the metric |
||
45 | * @param string $defaultValue |
||
46 | * the default value which the metric gets if there is no value stored |
||
47 | */ |
||
48 | public function addAvailableMetric($metric, $label, $help, $type, $defaultValue) { |
||
57 | |||
58 | /** |
||
59 | * Gets all available metrics in an array. |
||
60 | * |
||
61 | * @return array |
||
62 | * the available metrics |
||
63 | */ |
||
64 | public function getAvailableMetrics() { |
||
67 | |||
68 | /** |
||
69 | * Stores a measurement. |
||
70 | * |
||
71 | * @param string $metric |
||
72 | * the name of the metric |
||
73 | * @param string $key |
||
74 | * the key |
||
75 | * @param float $value |
||
76 | * the value |
||
77 | * @return void |
||
78 | */ |
||
79 | abstract public function storeMeasurement($metric, $key, $value); |
||
80 | |||
81 | /** |
||
82 | * Increments a measurement, starting with 1 if it doesn't exist yet. |
||
83 | * @param string $metric |
||
84 | * the name of the metric |
||
85 | * @param string $key |
||
86 | * the key |
||
87 | * @return void |
||
88 | */ |
||
89 | abstract public function incrementMeasurement($metric, $key); |
||
90 | |||
91 | /** |
||
92 | * Gets all measurements. |
||
93 | * |
||
94 | * @param string $metric |
||
95 | * the name of the metric |
||
96 | * @param array $keys |
||
97 | * the keys to retrieve |
||
98 | * @param string $defaultValue |
||
99 | * the default value a key gets if there is no value for it in the storage |
||
100 | * @return array |
||
101 | * the map with the keys and values |
||
102 | */ |
||
103 | abstract public function getMeasurements($metric, array $keys, $defaultValue = 'Nan'); |
||
104 | |||
105 | } |
||
106 |