Package io.dropwizard.metrics5.graphite
Class GraphiteUDP
java.lang.Object
io.dropwizard.metrics5.graphite.GraphiteUDP
- All Implemented Interfaces:
GraphiteSender,Closeable,AutoCloseable
public class GraphiteUDP extends Object implements GraphiteSender
A client to a Carbon server using unconnected UDP
-
Constructor Summary
Constructors Constructor Description GraphiteUDP(String hostname, int port)Creates a new client which sends data to given address using UDPGraphiteUDP(InetSocketAddress address)Creates a new client which sends data to given address using UDP -
Method Summary
Modifier and Type Method Description voidclose()voidconnect()Connects to the server.voidflush()Flushes buffer, if applicableintgetFailures()Returns the number of failed writes to the server.booleanisConnected()Returns true if ready to send dataprotected Stringsanitize(String s)voidsend(String name, String value, long timestamp)Sends the given measurement to the server.
-
Constructor Details
-
GraphiteUDP
Creates a new client which sends data to given address using UDP- Parameters:
hostname- The hostname of the Carbon serverport- The port of the Carbon server
-
GraphiteUDP
Creates a new client which sends data to given address using UDP- Parameters:
address- the address of the Carbon server
-
-
Method Details
-
connect
Description copied from interface:GraphiteSenderConnects to the server.- Specified by:
connectin interfaceGraphiteSender- Throws:
IllegalStateException- if the client is already connectedIOException- if there is an error connecting
-
isConnected
public boolean isConnected()Description copied from interface:GraphiteSenderReturns true if ready to send data- Specified by:
isConnectedin interfaceGraphiteSender
-
send
Description copied from interface:GraphiteSenderSends the given measurement to the server.- Specified by:
sendin interfaceGraphiteSender- Parameters:
name- the name of the metricvalue- the value of the metrictimestamp- the timestamp of the metric- Throws:
IOException- if there was an error sending the metric
-
getFailures
public int getFailures()Description copied from interface:GraphiteSenderReturns the number of failed writes to the server.- Specified by:
getFailuresin interfaceGraphiteSender- Returns:
- the number of failed writes to the server
-
flush
Description copied from interface:GraphiteSenderFlushes buffer, if applicable- Specified by:
flushin interfaceGraphiteSender- Throws:
IOException- if there was an error during flushing metrics to the socket
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
sanitize
-