public final class NonBlockingStatsDClient extends Object implements StatsDClient
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:
incrementCounter(java.lang.String, java.lang.String...) - adds one to the value of the specified named counterrecordGaugeValue(java.lang.String, double, java.lang.String...) - records the latest fixed value for the specified named gaugerecordExecutionTime(java.lang.String, long, java.lang.String...) - records an execution time in milliseconds for the specified named operationrecordHistogramValue(java.lang.String, double, java.lang.String...) - records a value, to be tracked with average, maximum, and percentilesAs part of a clean system shutdown, the stop() method should be invoked
on any StatsD clients.
| Constructor and Description |
|---|
NonBlockingStatsDClient(String prefix,
String hostname,
int port)
Create a new StatsD client communicating with a StatsD instance on the
specified host and port.
|
NonBlockingStatsDClient(String prefix,
String hostname,
int port,
String... constantTags)
Create a new StatsD client communicating with a StatsD instance on the
specified host and port.
|
NonBlockingStatsDClient(String prefix,
String hostname,
int port,
String[] constantTags,
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(String aspect,
long delta,
String... tags)
Adjusts the specified counter by a given delta.
|
void |
decrement(String aspect,
String... tags)
Convenience method equivalent to
decrementCounter(String, String[]). |
void |
decrementCounter(String aspect,
String... tags)
Decrements the specified counter by one.
|
void |
gauge(String aspect,
double value,
String... tags)
Convenience method equivalent to
recordGaugeValue(String, double, String[]). |
void |
gauge(String aspect,
long value,
String... tags)
Convenience method equivalent to
recordGaugeValue(String, long, String[]). |
void |
histogram(String aspect,
double value,
String... tags)
Convenience method equivalent to
recordHistogramValue(String, double, String[]). |
void |
histogram(String aspect,
long value,
String... tags)
Convenience method equivalent to
recordHistogramValue(String, long, String[]). |
void |
increment(String aspect,
String... tags)
Convenience method equivalent to
incrementCounter(String, String[]). |
void |
incrementCounter(String aspect,
String... tags)
Increments the specified counter by one.
|
void |
recordExecutionTime(String aspect,
long timeInMs,
String... tags)
Records an execution time in milliseconds for the specified named operation.
|
void |
recordGaugeValue(String aspect,
double value,
String... tags)
Records the latest fixed value for the specified named gauge.
|
void |
recordGaugeValue(String aspect,
long value,
String... tags)
Records the latest fixed value for the specified named gauge.
|
void |
recordHistogramValue(String aspect,
double value,
String... tags)
Records a value for the specified named histogram.
|
void |
recordHistogramValue(String aspect,
long value,
String... tags)
Records a value for the specified named histogram.
|
void |
recordServiceCheckRun(ServiceCheck sc)
Records a run status for the specified named service check.
|
void |
serviceCheck(ServiceCheck sc)
Convenience method equivalent to
recordServiceCheckRun(ServiceCheck sc). |
void |
stop()
Cleanly shut down this StatsD client.
|
void |
time(String aspect,
long value,
String... tags)
Convenience method equivalent to
recordExecutionTime(String, long, String[]). |
public NonBlockingStatsDClient(String prefix, String hostname, int port) throws StatsDClientException
prefix - the prefix to apply to keys sent via this clienthostname - the host name of the targeted StatsD serverport - the port of the targeted StatsD serverStatsDClientException - if the client could not be startedpublic NonBlockingStatsDClient(String prefix, String hostname, int port, String... constantTags) throws StatsDClientException
prefix - the prefix to apply to keys sent via this clienthostname - the host name of the targeted StatsD serverport - the port of the targeted StatsD serverconstantTags - tags to be added to all content sentStatsDClientException - if the client could not be startedpublic NonBlockingStatsDClient(String prefix, String hostname, int port, String[] constantTags, StatsDClientErrorHandler errorHandler) throws StatsDClientException
prefix - the prefix to apply to keys sent via this clienthostname - the host name of the targeted StatsD serverport - the port of the targeted StatsD serverconstantTags - tags to be added to all content senterrorHandler - handler to use when an exception occurs during usageStatsDClientException - if the client could not be startedpublic void stop()
stop in interface StatsDClientpublic void count(String aspect, long delta, String... tags)
This method is non-blocking and is guaranteed not to throw an exception.
count in interface StatsDClientaspect - the name of the counter to adjustdelta - the amount to adjust the counter bytags - array of tags to be added to the datapublic void incrementCounter(String aspect, String... tags)
This method is non-blocking and is guaranteed not to throw an exception.
incrementCounter in interface StatsDClientaspect - the name of the counter to incrementtags - array of tags to be added to the datapublic void increment(String aspect, String... tags)
incrementCounter(String, String[]).increment in interface StatsDClientpublic void decrementCounter(String aspect, String... tags)
This method is non-blocking and is guaranteed not to throw an exception.
decrementCounter in interface StatsDClientaspect - the name of the counter to decrementtags - array of tags to be added to the datapublic void decrement(String aspect, String... tags)
decrementCounter(String, String[]).decrement in interface StatsDClientpublic void recordGaugeValue(String aspect, double value, String... tags)
This method is non-blocking and is guaranteed not to throw an exception.
recordGaugeValue in interface StatsDClientaspect - the name of the gaugevalue - the new reading of the gaugetags - array of tags to be added to the datapublic void gauge(String aspect, double value, String... tags)
recordGaugeValue(String, double, String[]).gauge in interface StatsDClientpublic void recordGaugeValue(String aspect, long value, String... tags)
This method is non-blocking and is guaranteed not to throw an exception.
recordGaugeValue in interface StatsDClientaspect - the name of the gaugevalue - the new reading of the gaugetags - array of tags to be added to the datapublic void gauge(String aspect, long value, String... tags)
recordGaugeValue(String, long, String[]).gauge in interface StatsDClientpublic void recordExecutionTime(String aspect, long timeInMs, String... tags)
This method is non-blocking and is guaranteed not to throw an exception.
recordExecutionTime in interface StatsDClientaspect - the name of the timed operationtimeInMs - the time in millisecondstags - array of tags to be added to the datapublic void time(String aspect, long value, String... tags)
recordExecutionTime(String, long, String[]).time in interface StatsDClientpublic void recordHistogramValue(String aspect, double value, String... tags)
This method is non-blocking and is guaranteed not to throw an exception.
recordHistogramValue in interface StatsDClientaspect - the name of the histogramvalue - the value to be incorporated in the histogramtags - array of tags to be added to the datapublic void histogram(String aspect, double value, String... tags)
recordHistogramValue(String, double, String[]).histogram in interface StatsDClientpublic void recordHistogramValue(String aspect, long value, String... tags)
This method is non-blocking and is guaranteed not to throw an exception.
recordHistogramValue in interface StatsDClientaspect - the name of the histogramvalue - the value to be incorporated in the histogramtags - array of tags to be added to the datapublic void histogram(String aspect, long value, String... tags)
recordHistogramValue(String, long, String[]).histogram in interface StatsDClientpublic void recordServiceCheckRun(ServiceCheck sc)
This method is a DataDog extension, and may not work with other servers.
This method is non-blocking and is guaranteed not to throw an exception.
recordServiceCheckRun in interface StatsDClientsc - the service check objectpublic void serviceCheck(ServiceCheck sc)
recordServiceCheckRun(ServiceCheck sc).serviceCheck in interface StatsDClientCopyright © 2015. All rights reserved.