-
Notifications
You must be signed in to change notification settings - Fork 136
Expand file tree
/
Copy pathStatsDClient.java
More file actions
287 lines (258 loc) · 10.2 KB
/
StatsDClient.java
File metadata and controls
287 lines (258 loc) · 10.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
package com.timgroup.statsd;
/**
* Describes a client connection to a StatsD server, which may be used to post metrics
* in the form of counters, timers, and gauges.
*
* <p>Four key methods are provided for the submission of data-points for the application under
* scrutiny:
* <ul>
* <li>{@link #incrementCounter} - adds one to the value of the specified named counter</li>
* <li>{@link #recordGaugeValue} - records the latest fixed value for the specified named gauge</li>
* <li>{@link #recordExecutionTime} - records an execution time in milliseconds for the specified named operation</li>
* <li>{@link #recordSetEvent} - records an occurrence of the specified named event</li>
* </ul>
*
* @author Tom Denley
*
*/
public interface StatsDClient {
/**
* Cleanly shut down this StatsD client. This method may throw an exception if
* the socket cannot be closed.
*/
void stop();
/**
* Adjusts the specified counter by a given delta.
*
* <p>This method is non-blocking and is guaranteed not to throw an exception.</p>
*
* @param aspect
* the name of the counter to adjust
* @param delta
* the amount to adjust the counter by
*/
void count(String aspect, long delta);
/**
* Adjusts the specified counter by a given delta.
*
* <p>This method is non-blocking and is guaranteed not to throw an exception.</p>
*
* @param aspect
* the name of the counter to adjust
* @param delta
* the amount to adjust the counter by
* @param sampleRate
* the sampling rate being employed. For example, a rate of 0.1 would tell StatsD that this counter is being sent
* sampled every 1/10th of the time.
*/
void count(String aspect, long delta, double sampleRate);
/**
* Adjusts the specified counter by a given delta.
*
* <p>This method is non-blocking and is guaranteed not to throw an exception.</p>
*
* @param aspect
* the name of the counter to adjust
* @param delta
* the amount to adjust the counter by
* @param sampleRate
* the sampling rate being employed. For example, a rate of 0.1 would tell StatsD that this counter is being sent
* sampled every 1/10th of the time.
* @param tags
* A string array containing one or more tags. Each tag can be in the format of key:value, e.g. key1:value1. Or it can be just a key, e.g. key3.
*/
void count(String aspect, long delta, double sampleRate, String[] tags);
/**
* Increments the specified counter by one.
*
* <p>This method is non-blocking and is guaranteed not to throw an exception.</p>
*
* @param aspect
* the name of the counter to increment
*/
void incrementCounter(String aspect);
/**
* Convenience method equivalent to {@link #incrementCounter(String)}.
*/
void increment(String aspect);
/**
* Decrements the specified counter by one.
*
* <p>This method is non-blocking and is guaranteed not to throw an exception.</p>
*
* @param aspect
* the name of the counter to decrement
*/
void decrementCounter(String aspect);
/**
* Convenience method equivalent to {@link #decrementCounter(String)}.
*/
void decrement(String aspect);
/**
* Records the latest fixed value for the specified named gauge.
*
* <p>This method is non-blocking and is guaranteed not to throw an exception.</p>
*
* @param aspect
* the name of the gauge
* @param value
* the new reading of the gauge
*/
void recordGaugeValue(String aspect, long value);
/**
* Convenience method equivalent to {@link #recordGaugeValue(String, long)} but for double values.
*/
void recordGaugeValue(String aspect, double value);
/**
* Records a change in the value of the specified named gauge.
*
* <p>This method is non-blocking and is guaranteed not to throw an exception.</p>
*
* @param aspect
* the name of the gauge
* @param delta
* the +/- delta to apply to the gauge
*/
void recordGaugeDelta(String aspect, long delta);
/**
* Convenience method equivalent to {@link #recordGaugeDelta(String, long)} but for double deltas.
*/
void recordGaugeDelta(String aspect, double delta);
/**
* Records the latest fixed value for the specified named gauge.
*
* <p>This method is non-blocking and is guaranteed not to throw an exception.</p>
*
* @param aspect
* the name of the gauge
* @param value
* the new reading of the gauge
* @param tags
* A string array containing one or more tags. Each tag can be in the format of key:value, e.g. key1:value1. Or it can be just a key, e.g. key3.
*/
void recordGaugeValue(String aspect, long value, String[] tags);
/**
* Convenience method equivalent to {@link #recordGaugeValue(String, long, String[])} but for double values.
*/
void recordGaugeValue(String aspect, double value, String[] tags);
/**
* Records a change in the value of the specified named gauge.
*
* <p>This method is non-blocking and is guaranteed not to throw an exception.</p>
*
* @param aspect
* the name of the gauge
* @param delta
* the +/- delta to apply to the gauge
* @param tags
* A string array containing one or more tags. Each tag can be in the format of key:value, e.g. key1:value1. Or it can be just a key, e.g. key3.
*/
void recordGaugeDelta(String aspect, long delta, String[] tags);
/**
* Convenience method equivalent to {@link #recordGaugeDelta(String, long, String[])} but for double deltas.
*/
void recordGaugeDelta(String aspect, double delta, String[] tags);
/**
* Convenience method equivalent to {@link #recordGaugeValue(String, long, String[])}.
*/
void gauge(String aspect, long value);
/**
* Convenience method equivalent to {@link #recordGaugeValue(String, double)}.
*/
void gauge(String aspect, double value);
/**
* StatsD supports counting unique occurrences of events between flushes, Call this method to records an occurrence
* of the specified named event.
*
* <p>This method is non-blocking and is guaranteed not to throw an exception.</p>
*
* @param aspect
* the name of the set
* @param eventName
* the value to be added to the set
*/
void recordSetEvent(String aspect, String eventName);
/**
* StatsD supports counting unique occurrences of events between flushes, Call this method to records an occurrence
* of the specified named event.
*
* <p>This method is non-blocking and is guaranteed not to throw an exception.</p>
*
* @param aspect
* the name of the set
* @param eventName
* the value to be added to the set
* @param tags
* A string array containing one or more tags. Each tag can be in the format of key:value, e.g. key1:value1. Or it can be just a key, e.g. key3.
*/
void recordSetEvent(String aspect, String eventName, String[] tags);
/**
* Convenience method equivalent to {@link #recordSetEvent(String, String)}.
*/
void set(String aspect, String eventName);
/**
* Records an execution time in milliseconds for the specified named operation.
*
* <p>This method is non-blocking and is guaranteed not to throw an exception.</p>
*
* @param aspect
* the name of the timed operation
* @param timeInMs
* the time in milliseconds
*/
void recordExecutionTime(String aspect, long timeInMs);
/**
* Adjusts the specified counter by a given delta.
*
* <p>This method is non-blocking and is guaranteed not to throw an exception.</p>
*
* @param aspect
* the name of the counter to adjust
* @param delta
* the amount to adjust the counter by
* @param sampleRate
* the sampling rate being employed. For example, a rate of 0.1 would tell StatsD that this timer is being sent
* sampled every 1/10th of the time, so that it updates its timer_counters appropriately.
*/
void recordExecutionTime(String aspect, long timeInMs, double sampleRate);
/**
* Adjusts the specified counter by a given delta.
*
* <p>This method is non-blocking and is guaranteed not to throw an exception.</p>
*
* @param aspect
* the name of the counter to adjust
* @param delta
* the amount to adjust the counter by
* @param sampleRate
* the sampling rate being employed. For example, a rate of 0.1 would tell StatsD that this timer is being sent
* sampled every 1/10th of the time, so that it updates its timer_counters appropriately.
* @param tags
* A string array containing one or more tags. Each tag can be in the format of key:value, e.g. key1:value1. Or it can be just a key, e.g. key3.
*/
void recordExecutionTime(String aspect, long timeInMs, double sampleRate, String[] tags);
/**
* Records an execution time in milliseconds for the specified named operation. The execution
* time is calculated as the delta between the specified start time and the current system
* time (using {@link System#currentTimeMillis()})
*
* <p>This method is non-blocking and is guaranteed not to throw an exception.</p>
*
* @param aspect
* the name of the timed operation
* @param timeInMs
* the system time, in millis, at the start of the operation that has just completed
*/
void recordExecutionTimeToNow(String aspect, long systemTimeMillisAtStart);
/**
* Convenience method equivalent to {@link #recordExecutionTime(String, long)}.
*/
void time(String aspect, long value);
/**
* Set tags at the client level. These tags will be added to all metrics.
*
* @param tags
* A string array containing one or more tags. Each tag can be in the format of key:value, e.g. key1:value1. Or it can be just a key, e.g. key3.
*/
void setClientTags(String[] tags);
}