public class BlockingStatsDEventClient extends Object
Upon instantiation, this client will establish a socket connection to a StatsD instance running on the specified host and port. Events are then sent over this connection as they are received by the client.
Six key methods are provided for the submission of events for the application under scrutiny:
event(String, String)event(String, String, AlertType)event(String, String, long)event(String, String, Priority)event(String, String, String...)event(String, String, long, String, Priority, String, AlertType, String...)As part of a clean system shutdown, the stop() method should be invoked
on any StatsD clients.
| Modifier and Type | Field and Description |
|---|---|
protected DatagramSocket |
clientSocket |
protected String[] |
constantTags |
protected StatsDClientErrorHandler |
handler |
protected String |
hostname |
| Constructor and Description |
|---|
BlockingStatsDEventClient(String hostname,
int port)
Create a new StatsD client communicating with a StatsD instance on the
specified host and port.
|
BlockingStatsDEventClient(String hostname,
int port,
String[] constantTags)
Create a new StatsD client communicating with a StatsD instance on the
specified host and port.
|
BlockingStatsDEventClient(String hostname,
int port,
String[] constantTags,
StatsDClientErrorHandler errorHandler)
Create a new StatsD client communicating with a StatsD instance on the
specified host and port.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
blockingSend(String message) |
void |
event(String title,
String message)
Submit event with title and message
|
void |
event(String title,
String message,
AlertType alertType)
Submit event with title, message and alter type
|
void |
event(String title,
String message,
long dateHappened)
Submit event with title, message and a time
|
void |
event(String title,
String message,
long dateHappened,
String aggregationKey,
Priority priority,
String sourceTypeName,
AlertType alterType,
String... tags)
Reports an event to the datadog agent
|
void |
event(String title,
String message,
Priority priority)
Submit event with title, message and priority for the message
|
void |
event(String title,
String message,
String... tags)
Submit message with title, message and tags
|
protected String |
prepareMessage(String title,
String message,
long dateHappened,
String aggregationKey,
Priority priority,
String sourceTypeName,
AlertType alterType,
String... tags) |
void |
stop()
Cleanly shut down this StatsD client.
|
protected String |
tagString(String[] tags)
Generate a suffix conveying the given tag list to the client
|
protected final DatagramSocket clientSocket
protected final StatsDClientErrorHandler handler
protected final String[] constantTags
protected final String hostname
public BlockingStatsDEventClient(String hostname, int port) throws StatsDClientException
hostname - the host name of the targeted StatsD serverport - the port of the targeted StatsD serverStatsDClientException - if the client could not be startedpublic BlockingStatsDEventClient(String hostname, int port, String[] constantTags) throws StatsDClientException
hostname - the host name of the targeted StatsD serverport - the port of the targeted StatsD serverconstantTags - tags to be added to all content sent (each of them should be in the format key:value)StatsDClientException - if the client could not be startedpublic BlockingStatsDEventClient(String hostname, int port, String[] constantTags, StatsDClientErrorHandler errorHandler) throws StatsDClientException
prefix - the prefix to apply to keys sent via this clienthostname - the host name of the targeted StatsD serverport - the port of the targeted StatsD serverconstantTags - tags to be added to all content sent (each of them should be in the format key:value)errorHandler - handler to use when an exception occurs during usageStatsDClientException - if the client could not be startedpublic void stop()
protected String tagString(String[] tags)
tags - public void event(String title, String message)
title - message - public void event(String title, String message, long dateHappened)
title - message - dateHappened - - It should be in secondspublic void event(String title, String message, Priority priority)
title - message - priority - public void event(String title, String message, AlertType alertType)
title - message - alertType - public void event(String title, String message, String... tags)
title - message - tags - public void event(String title, String message, long dateHappened, String aggregationKey, Priority priority, String sourceTypeName, AlertType alterType, String... tags)
title - message - dateHappened - aggregationKey - priority - sourceTypeName - alterType - tags - -> Each item in this array should in the format key:valueprotected String prepareMessage(String title, String message, long dateHappened, String aggregationKey, Priority priority, String sourceTypeName, AlertType alterType, String... tags)
protected void blockingSend(String message)
Copyright © 2016. All rights reserved.