public final class NonBlockingStatsDClient extends ConvenienceMethodProvidingStatsDClient
Upon instantiation, this client will establish a socket connection to a StatsD instance running on the specified host and port. Metrics are then sent over this connection as they are received by the client.
Three key methods are provided for the submission of data-points for the application under scrutiny:
ConvenienceMethodProvidingStatsDClient.incrementCounter(java.lang.String) - adds one to the value of the specified named counterrecordGaugeValue(java.lang.String, long) - records the latest fixed value for the specified named gaugerecordExecutionTime(java.lang.String, long, double) - records an execution time in milliseconds for the specified named operationAs part of a clean system shutdown, the stop() method should be invoked
on any StatsD clients.
| Constructor and Description |
|---|
NonBlockingStatsDClient(java.lang.String prefix,
java.lang.String hostname,
int port)
Create a new StatsD client communicating with a StatsD instance on the
specified host and port.
|
NonBlockingStatsDClient(java.lang.String prefix,
java.lang.String hostname,
int port,
StatsDClientErrorHandler errorHandler)
Create a new StatsD client communicating with a StatsD instance on the
specified host and port.
|
| Modifier and Type | Method and Description |
|---|---|
void |
count(java.lang.String aspect,
long delta,
double sampleRate)
Adjusts the specified counter by a given delta.
|
void |
recordExecutionTime(java.lang.String aspect,
long timeInMs,
double sampleRate)
Records an execution time in milliseconds for the specified named operation.
|
void |
recordGaugeDelta(java.lang.String aspect,
long value)
Records a change in the value of the specified named gauge.
|
void |
recordGaugeValue(java.lang.String aspect,
long value)
Records the latest fixed value for the specified named gauge.
|
void |
recordSetEvent(java.lang.String aspect,
java.lang.String eventName)
StatsD supports counting unique occurrences of events between flushes, Call this method to records an occurrence
of the specified named event.
|
void |
stop()
Cleanly shut down this StatsD client.
|
count, decrement, decrementCounter, gauge, increment, incrementCounter, recordExecutionTime, recordExecutionTimeToNow, set, timepublic NonBlockingStatsDClient(java.lang.String prefix,
java.lang.String hostname,
int port)
throws StatsDClientException
prefix - the prefix to apply to keys sent via this client (can be null or empty for no prefix)hostname - the host name of the targeted StatsD serverport - the port of the targeted StatsD serverStatsDClientException - if the client could not be startedpublic NonBlockingStatsDClient(java.lang.String prefix,
java.lang.String hostname,
int port,
StatsDClientErrorHandler errorHandler)
throws StatsDClientException
prefix - the prefix to apply to keys sent via this client (can be null or empty for no prefix)hostname - the host name of the targeted StatsD serverport - the port of the targeted StatsD servererrorHandler - handler to use when an exception occurs during usageStatsDClientException - if the client could not be startedpublic void stop()
public void count(java.lang.String aspect,
long delta,
double sampleRate)
This method is non-blocking and is guaranteed not to throw an exception.
aspect - the name of the counter to adjustdelta - the amount to adjust the counter bysampleRate - 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.public void recordGaugeValue(java.lang.String aspect,
long value)
This method is non-blocking and is guaranteed not to throw an exception.
aspect - the name of the gaugevalue - the new reading of the gaugepublic void recordGaugeDelta(java.lang.String aspect,
long value)
StatsDClientThis method is non-blocking and is guaranteed not to throw an exception.
aspect - the name of the gaugevalue - the +/- delta to apply to the gaugepublic void recordSetEvent(java.lang.String aspect,
java.lang.String eventName)
This method is non-blocking and is guaranteed not to throw an exception.
aspect - the name of the seteventName - the value to be added to the setpublic void recordExecutionTime(java.lang.String aspect,
long timeInMs,
double sampleRate)
This method is non-blocking and is guaranteed not to throw an exception.
aspect - the name of the timed operationtimeInMs - the time in millisecondssampleRate - 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.