@Extension public class DatadogBuildListener extends hudson.model.listeners.RunListener<hudson.model.Run> implements hudson.model.Describable<DatadogBuildListener>
RunListener.
When the user configures the project and runs a build,
Descriptor.newInstance(StaplerRequest) is invoked and a new
DatadogBuildListener is created. The created instance is persisted to the project
configuration XML by using XStream, allowing you to use instance fields
(like link #name) to remember the configuration.
When a build starts, the onStarted(Run, TaskListener) method will be invoked. And
when a build finishes, the onCompleted(Run, TaskListener) method will be invoked.
| Modifier and Type | Class and Description |
|---|---|
static class |
DatadogBuildListener.DescriptorImpl
Descriptor for
DatadogBuildListener. |
| Constructor and Description |
|---|
DatadogBuildListener()
Runs when the
DatadogBuildListener class is created. |
| Modifier and Type | Method and Description |
|---|---|
String |
durationToString(double duration)
Converts from a double to a human readable string, representing a time duration.
|
void |
event(net.sf.json.JSONObject builddata,
net.sf.json.JSONArray tags)
Sends a an event to the Datadog API, including the event payload, and a
set of tags.
|
void |
gauge(String metricName,
net.sf.json.JSONObject builddata,
String key,
net.sf.json.JSONArray tags)
Sends a metric to the Datadog API, including the gauge name, value, and
a set of tags.
|
DatadogBuildListener.DescriptorImpl |
getDescriptor()
Getter function for the
DatadogBuildListener.DescriptorImpl class. |
void |
onCompleted(hudson.model.Run run,
hudson.model.TaskListener listener)
Called when a build is completed.
|
void |
onStarted(hudson.model.Run run,
hudson.model.TaskListener listener)
Called when a build is first started.
|
Boolean |
post(net.sf.json.JSONObject payload,
String type)
Posts a given
JSONObject payload to the DataDog API, using the
user configured apiKey. |
void |
printLog(String message)
Prints a message to the
PrintStream logger. |
void |
serviceCheck(String checkName,
Integer status,
net.sf.json.JSONObject builddata,
net.sf.json.JSONArray tags)
Sends a service check to the Datadog API, including the check name,
status, and a set of tags.
|
public DatadogBuildListener()
DatadogBuildListener class is created.public final void onStarted(hudson.model.Run run,
hudson.model.TaskListener listener)
onStarted in class hudson.model.listeners.RunListener<hudson.model.Run>run - - A Run object representing a particular execution of Job.listener - - A TaskListener object which receives events that happen during some
operation.public final void onCompleted(hudson.model.Run run,
@Nonnull
hudson.model.TaskListener listener)
onCompleted in class hudson.model.listeners.RunListener<hudson.model.Run>run - - A Run object representing a particular execution of Job.listener - - A TaskListener object which receives events that happen during some
operation.public final Boolean post(net.sf.json.JSONObject payload, String type)
JSONObject payload to the DataDog API, using the
user configured apiKey.payload - - A JSONObject containing a specific subset of a builds metadata.type - - A String containing the URL subpath pertaining to the type of API post required.public final void gauge(String metricName, net.sf.json.JSONObject builddata, String key, net.sf.json.JSONArray tags)
metricName - - A String with the name of the metric to record.builddata - - A JSONObject containing a builds metadata.key - - A String with the name of the build metadata to be found in the JSONObject
builddata.tags - - A JSONArray containing a specific subset of tags retrieved from a builds
metadata.public final void serviceCheck(String checkName, Integer status, net.sf.json.JSONObject builddata, net.sf.json.JSONArray tags)
checkName - - A String with the name of the service check to record.status - - An Integer with the status code to record for this service check.builddata - - A JSONObject containing a builds metadata.tags - - A JSONArray containing a specific subset of tags retrieved from a builds
metadata.public final void event(net.sf.json.JSONObject builddata,
net.sf.json.JSONArray tags)
builddata - - A JSONObject containing a builds metadata.tags - - A JSONArray containing a specific subset of tags retrieved from a builds
metadata.public final String durationToString(double duration)
duration - - A Double with a duration in seconds.public final void printLog(String message)
PrintStream logger.message - - A String containing a message to be printed to the PrintStream logger.public final DatadogBuildListener.DescriptorImpl getDescriptor()
DatadogBuildListener.DescriptorImpl class.getDescriptor in interface hudson.model.Describable<DatadogBuildListener>DatadogBuildListener.DescriptorImpl class.Copyright © 2004-2015. All Rights Reserved.