Package com.codahale.metrics.graphite
Class GraphiteRabbitMQ
- java.lang.Object
-
- com.codahale.metrics.graphite.GraphiteRabbitMQ
-
- All Implemented Interfaces:
GraphiteSender
,Closeable
,AutoCloseable
public class GraphiteRabbitMQ extends Object implements GraphiteSender
A rabbit-mq client to a Carbon server.
-
-
Constructor Summary
Constructors Constructor Description GraphiteRabbitMQ(com.rabbitmq.client.ConnectionFactory connectionFactory, String exchange)
Creates a new client with a given aConnectionFactory
and an amqp exchangeGraphiteRabbitMQ(String rabbitHost, Integer rabbitPort, String rabbitUsername, String rabbitPassword, String exchange)
Creates a new client given connection detailsGraphiteRabbitMQ(String rabbitHost, Integer rabbitPort, String rabbitUsername, String rabbitPassword, String exchange, Integer rabbitConnectionTimeoutMS, Integer rabbitSocketTimeoutMS, Integer rabbitRequestedHeartbeatInSeconds)
Creates a new client given connection details
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
connect()
Connects to the server.void
flush()
Flushes buffer, if applicableint
getFailures()
Returns the number of failed writes to the server.boolean
isConnected()
Returns true if ready to send dataString
sanitize(String s)
void
send(String name, String value, long timestamp)
Sends the given measurement to the server.
-
-
-
Constructor Detail
-
GraphiteRabbitMQ
public GraphiteRabbitMQ(com.rabbitmq.client.ConnectionFactory connectionFactory, String exchange)
Creates a new client with a given aConnectionFactory
and an amqp exchange- Parameters:
connectionFactory
- theConnectionFactory
used to establish connection and publish to graphite serverexchange
- the amqp exchange
-
GraphiteRabbitMQ
public GraphiteRabbitMQ(String rabbitHost, Integer rabbitPort, String rabbitUsername, String rabbitPassword, String exchange)
Creates a new client given connection details- Parameters:
rabbitHost
- the rabbitmq server hostrabbitPort
- the rabbitmq server portrabbitUsername
- the rabbitmq server usernamerabbitPassword
- the rabbitmq server passwordexchange
- the amqp exchange
-
GraphiteRabbitMQ
public GraphiteRabbitMQ(String rabbitHost, Integer rabbitPort, String rabbitUsername, String rabbitPassword, String exchange, Integer rabbitConnectionTimeoutMS, Integer rabbitSocketTimeoutMS, Integer rabbitRequestedHeartbeatInSeconds)
Creates a new client given connection details- Parameters:
rabbitHost
- the rabbitmq server hostrabbitPort
- the rabbitmq server portrabbitUsername
- the rabbitmq server usernamerabbitPassword
- the rabbitmq server passwordexchange
- the amqp exchangerabbitConnectionTimeoutMS
- the connection timeout in millisecondsrabbitSocketTimeoutMS
- the socket timeout in millisecondsrabbitRequestedHeartbeatInSeconds
- the hearthbeat in seconds
-
-
Method Detail
-
connect
public void connect() throws IllegalStateException, IOException
Description copied from interface:GraphiteSender
Connects to the server.- Specified by:
connect
in interfaceGraphiteSender
- Throws:
IllegalStateException
- if the client is already connectedIOException
- if there is an error connecting
-
isConnected
public boolean isConnected()
Description copied from interface:GraphiteSender
Returns true if ready to send data- Specified by:
isConnected
in interfaceGraphiteSender
-
send
public void send(String name, String value, long timestamp) throws IOException
Description copied from interface:GraphiteSender
Sends the given measurement to the server.- Specified by:
send
in 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
public void flush() throws IOException
Description copied from interface:GraphiteSender
Flushes buffer, if applicable- Specified by:
flush
in interfaceGraphiteSender
- Throws:
IOException
- if there was an error during flushing metrics to the socket
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
getFailures
public int getFailures()
Description copied from interface:GraphiteSender
Returns the number of failed writes to the server.- Specified by:
getFailures
in interfaceGraphiteSender
- Returns:
- the number of failed writes to the server
-
-