Class StatsdClient
- java.lang.Object
-
- org.deltafi.common.metrics.statsd.StatsdClient
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
@NotThreadSafe public class StatsdClient extends java.lang.Object implements java.io.CloseableClient class for sending metrics to a StatsD server- See Also:
- StatsD
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classStatsdClient.SocketFactorystatic classStatsdClient.StreamFactory
-
Constructor Summary
Constructors Constructor Description StatsdClient(java.lang.String host, int port)Constructs a client for the given host and port.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close the connection to the StatsD servervoidconnect()Creates a socket connection to the statsd servervoidsendCounter(java.lang.String name, java.lang.String value)Sends the given measurement to the server as a countervoidsendGauge(java.lang.String name, java.lang.String value)Sends the given measurement to the server as a gaugebooleansuccess()
-
-
-
Method Detail
-
connect
public void connect() throws java.io.IOExceptionCreates a socket connection to the statsd server- Throws:
java.lang.IllegalStateException- if the client is already connectedjava.io.IOException- if there is an error connecting
-
sendCounter
public void sendCounter(java.lang.String name, java.lang.String value)Sends the given measurement to the server as a counter- Parameters:
name- metric namevalue- metric value
-
sendGauge
public void sendGauge(java.lang.String name, java.lang.String value)Sends the given measurement to the server as a gauge- Parameters:
name- metric namevalue- metric value
-
close
public void close()
Close the connection to the StatsD server- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable
-
success
public boolean success()
- Returns:
- true if the last transmission was successful
-
-