1 | <?php |
||
8 | class Factory implements FactoryInterface |
||
9 | { |
||
10 | use LoggerAwareTrait; |
||
11 | |||
12 | /** |
||
13 | * Factory constructor |
||
14 | */ |
||
15 | 21 | public function __construct() |
|
19 | |||
20 | /** |
||
21 | * @param string $key |
||
22 | * @param mixed $value |
||
23 | * @param string $type |
||
24 | * @return Metric|null |
||
25 | */ |
||
26 | 9 | protected function createMetric($key, $value, $type) |
|
34 | |||
35 | 3 | public function counter($key, $delta = 1) |
|
39 | |||
40 | 1 | public function increment($key) |
|
44 | |||
45 | 1 | public function decrement($key) |
|
49 | |||
50 | 2 | public function gauge($key, $value) |
|
54 | |||
55 | 2 | public function timer($key, $time) |
|
59 | |||
60 | 2 | public function set($key, $value) |
|
64 | |||
65 | /** |
||
66 | * Validates the value against the type |
||
67 | * |
||
68 | * Most metrics require a numeric value. If the value is empty, this can cause receivers to think the format of |
||
69 | * the emitted datagrams is invalid. (And, heck, it might be: it's not like etsy/statsd is a formal standard.) |
||
70 | * |
||
71 | * We treat these errors silently: we log a message and return null from createMetric(), excluding the metric from |
||
72 | * being sent via the client. |
||
73 | * |
||
74 | * @param string $key |
||
75 | * @param mixed $value |
||
76 | * @param string $type |
||
77 | * @return bool |
||
78 | */ |
||
79 | 18 | protected function validate($key, $value, $type) |
|
93 | |||
94 | 18 | protected function getNumericMetricTypes() |
|
98 | } |
||
99 |