Package com.codahale.metrics.graphite
Class Graphite
java.lang.Object
com.codahale.metrics.graphite.Graphite
- All Implemented Interfaces:
Closeable,AutoCloseable
A client to a Carbon server.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final InetSocketAddressprivate final Charsetprivate intprivate Socketprivate final SocketFactoryprivate static final Charsetprivate static final Patternprivate Writer -
Constructor Summary
ConstructorsConstructorDescriptionGraphite(InetSocketAddress address) Creates a new client which connects to the given address using the defaultSocketFactory.Graphite(InetSocketAddress address, SocketFactory socketFactory) Creates a new client which connects to the given address and socket factory.Graphite(InetSocketAddress address, SocketFactory socketFactory, Charset charset) Creates a new client which connects to the given address and socket factory using the given character set. -
Method Summary
-
Field Details
-
WHITESPACE
-
UTF_8
-
address
-
socketFactory
-
charset
-
socket
-
writer
-
failures
private int failures
-
-
Constructor Details
-
Graphite
Creates a new client which connects to the given address using the defaultSocketFactory.- Parameters:
address- the address of the Carbon server
-
Graphite
Creates a new client which connects to the given address and socket factory.- Parameters:
address- the address of the Carbon serversocketFactory- the socket factory
-
Graphite
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 server
-
-
Method Details
-
connect
Connects to the server.- Throws:
IllegalStateException- if the client is already connectedIOException- if there is an error connecting
-
send
Sends the given measurement to the server.- 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()Returns the number of failed writes to the server.- Returns:
- the number of failed writes to the server
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
sanitize
-