1 | <?php |
||
8 | class StatsdClient implements StatsdClientInterface |
||
9 | { |
||
10 | /** |
||
11 | * @var Client |
||
12 | */ |
||
13 | private $client; |
||
14 | |||
15 | /** |
||
16 | * @param Connection $connection |
||
17 | * @param string $namespace |
||
18 | */ |
||
19 | public function __construct(Connection $connection, $namespace = '') |
||
23 | |||
24 | /** |
||
25 | * increments the key by 1 |
||
26 | * |
||
27 | * @param string $key |
||
28 | * @param int $sampleRate |
||
29 | * |
||
30 | * @return void |
||
31 | */ |
||
32 | public function increment($key, $sampleRate = 1) |
||
36 | |||
37 | /** |
||
38 | * decrements the key by 1 |
||
39 | * |
||
40 | * @param string $key |
||
41 | * @param int $sampleRate |
||
42 | * |
||
43 | * @return void |
||
44 | */ |
||
45 | public function decrement($key, $sampleRate = 1) |
||
49 | /** |
||
50 | * sends a count to statsd |
||
51 | * |
||
52 | * @param string $key |
||
53 | * @param int $value |
||
54 | * @param int $sampleRate (optional) the default is 1 |
||
55 | * |
||
56 | * @return void |
||
57 | */ |
||
58 | public function count($key, $value, $sampleRate = 1) |
||
62 | |||
63 | /** |
||
64 | * sends a timing to statsd (in ms) |
||
65 | * |
||
66 | * @param string $key |
||
67 | * @param int $value the timing in ms |
||
68 | * @param int $sampleRate the sample rate, if < 1, statsd will send an average timing |
||
69 | * |
||
70 | * @return void |
||
71 | */ |
||
72 | public function timing($key, $value, $sampleRate = 1) |
||
76 | |||
77 | /** |
||
78 | * starts the timing for a key |
||
79 | * |
||
80 | * @param string $key |
||
81 | * |
||
82 | * @return void |
||
83 | */ |
||
84 | public function startTiming($key) |
||
88 | |||
89 | /** |
||
90 | * ends the timing for a key and sends it to statsd |
||
91 | * |
||
92 | * @param string $key |
||
93 | * @param int $sampleRate (optional) |
||
94 | * |
||
95 | * @return void |
||
96 | */ |
||
97 | public function endTiming($key, $sampleRate = 1) |
||
101 | |||
102 | /** |
||
103 | * start memory "profiling" |
||
104 | * |
||
105 | * @param string $key |
||
106 | * |
||
107 | * @return void |
||
108 | */ |
||
109 | public function startMemoryProfile($key) |
||
113 | |||
114 | /** |
||
115 | * ends the memory profiling and sends the value to the server |
||
116 | * |
||
117 | * @param string $key |
||
118 | * @param int $sampleRate |
||
119 | * |
||
120 | * @return void |
||
121 | */ |
||
122 | public function endMemoryProfile($key, $sampleRate = 1) |
||
126 | |||
127 | /** |
||
128 | * report memory usage to statsd. if memory was not given report peak usage |
||
129 | * |
||
130 | * @param string $key |
||
131 | * @param int $memory |
||
132 | * @param int $sampleRate |
||
133 | * |
||
134 | * @return void |
||
135 | */ |
||
136 | public function memory($key, $memory = null, $sampleRate = 1) |
||
140 | |||
141 | /** |
||
142 | * executes a Closure and records it's execution time and sends it to statsd |
||
143 | * returns the value the Closure returned |
||
144 | * |
||
145 | * @param string $key |
||
146 | * @param \Closure $_block |
||
147 | * @param int $sampleRate (optional) default = 1 |
||
148 | * |
||
149 | * @return mixed |
||
150 | */ |
||
151 | public function time($key, \Closure $_block, $sampleRate = 1) |
||
155 | |||
156 | /** |
||
157 | * sends a gauge, an arbitrary value to StatsD |
||
158 | * |
||
159 | * @param string $key |
||
160 | * @param int $value |
||
161 | * |
||
162 | * @return void |
||
163 | */ |
||
164 | public function gauge($key, $value) |
||
168 | |||
169 | /** |
||
170 | * sends a set member |
||
171 | * |
||
172 | * @param string $key |
||
173 | * @param int $value |
||
174 | * |
||
175 | * @return void |
||
176 | */ |
||
177 | public function set($key, $value) |
||
181 | |||
182 | /** |
||
183 | * changes the global key namespace |
||
184 | * |
||
185 | * @param string $namespace |
||
186 | * |
||
187 | * @return void |
||
188 | */ |
||
189 | public function setNamespace($namespace) |
||
193 | |||
194 | /** |
||
195 | * gets the global key namespace |
||
196 | * |
||
197 | * @return string |
||
198 | */ |
||
199 | public function getNamespace() |
||
203 | |||
204 | /** |
||
205 | * is batch processing running? |
||
206 | * |
||
207 | * @return boolean |
||
208 | */ |
||
209 | public function isBatch() |
||
213 | |||
214 | /** |
||
215 | * start batch-send-recording |
||
216 | * |
||
217 | * @return void |
||
218 | */ |
||
219 | public function startBatch() |
||
223 | |||
224 | /** |
||
225 | * ends batch-send-recording and sends the recorded messages to the connection |
||
226 | * |
||
227 | * @return void |
||
228 | */ |
||
229 | public function endBatch() |
||
233 | |||
234 | /** |
||
235 | * stops batch-recording and resets the batch |
||
236 | * |
||
237 | * @return void |
||
238 | */ |
||
239 | public function cancelBatch() |
||
243 | } |
||
244 |