Package com.codahale.metrics.graphite
Class PickledGraphite
java.lang.Object
com.codahale.metrics.graphite.PickledGraphite
- All Implemented Interfaces:
GraphiteSender,Closeable,AutoCloseable
A client to a Carbon server that sends all metrics after they have been pickled in configurable sized batches
-
Constructor Summary
ConstructorsConstructorDescriptionPickledGraphite(String hostname, int port) Creates a new client which connects to the given address using the defaultSocketFactory.PickledGraphite(String hostname, int port, int batchSize) Creates a new client which connects to the given address using the defaultSocketFactory.PickledGraphite(String hostname, int port, SocketFactory socketFactory, int batchSize) Creates a new client which connects to the given address and socket factory.PickledGraphite(String hostname, int port, SocketFactory socketFactory, Charset charset, int batchSize) Creates a new client which connects to the given address and socket factory using the given character set.PickledGraphite(InetSocketAddress address) Creates a new client which connects to the given address using the defaultSocketFactory.PickledGraphite(InetSocketAddress address, int batchSize) Creates a new client which connects to the given address using the defaultSocketFactory.PickledGraphite(InetSocketAddress address, SocketFactory socketFactory, int batchSize) Creates a new client which connects to the given address and socket factory.PickledGraphite(InetSocketAddress address, SocketFactory socketFactory, Charset charset, int batchSize) Creates a new client which connects to the given address and socket factory using the given character set. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidconnect()Connects to the server.voidflush()Flushes buffer, if applicableintReturns the number of failed writes to the server.booleanReturns true if ready to send dataprotected StringvoidConvert the metric to a python tuple of the form:
-
Constructor Details
-
PickledGraphite
Creates a new client which connects to the given address using the defaultSocketFactory. This defaults to a batchSize of 100- Parameters:
address- the address of the Carbon server
-
PickledGraphite
Creates a new client which connects to the given address using the defaultSocketFactory.- Parameters:
address- the address of the Carbon serverbatchSize- how many metrics are bundled into a single pickle request to graphite
-
PickledGraphite
Creates a new client which connects to the given address and socket factory.- Parameters:
address- the address of the Carbon serversocketFactory- the socket factorybatchSize- how many metrics are bundled into a single pickle request to graphite
-
PickledGraphite
public PickledGraphite(InetSocketAddress address, SocketFactory socketFactory, Charset charset, int batchSize) Creates a new client which connects to the given address and socket factory using the given character set.- Parameters:
address- the address of the Carbon serversocketFactory- the socket factorycharset- the character set used by the serverbatchSize- how many metrics are bundled into a single pickle request to graphite
-
PickledGraphite
Creates a new client which connects to the given address using the defaultSocketFactory. This defaults to a batchSize of 100- Parameters:
hostname- the hostname of the Carbon serverport- the port of the Carbon server
-
PickledGraphite
Creates a new client which connects to the given address using the defaultSocketFactory.- Parameters:
hostname- the hostname of the Carbon serverport- the port of the Carbon serverbatchSize- how many metrics are bundled into a single pickle request to graphite
-
PickledGraphite
Creates a new client which connects to the given address and socket factory.- Parameters:
hostname- the hostname of the Carbon serverport- the port of the Carbon serversocketFactory- the socket factorybatchSize- how many metrics are bundled into a single pickle request to graphite
-
PickledGraphite
public PickledGraphite(String hostname, int port, SocketFactory socketFactory, Charset charset, int batchSize) Creates a new client which connects to the given address and socket factory using the given character set.- Parameters:
hostname- the hostname of the Carbon serverport- the port of the Carbon serversocketFactory- the socket factorycharset- the character set used by the serverbatchSize- how many metrics are bundled into a single pickle request to graphite
-
-
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
Convert the metric to a python tuple of the form:(timestamp, (name, value))
And add it to the list of metrics. If we reach the batch size, write them out.
- 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
-
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
-
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
-
sanitize
-