These instructions are for Java language bindings. If you are looking to monitor the JVM, we recommend using our JVM integration.
If use the Dropwizard framework please use our Dropwizard Plugin.
- Using Maven.
<dependency>
<groupId>com.librato.metrics</groupId>
<artifactId>librato-java</artifactId>
<version>2.0.5</version>
</dependency>
- Initialize the client:
LibratoClient client = LibratoClient.builder(customer-email@example.com, CUSTOMER_API_KEY)
// these are optional
.setConnectTimeout(new Duration(5, SECONDS))
.setReadTimeout(new Duration(5, SECONDS))
.setAgentIdentifier("my app name")
// and finally build
.build();
- Quick Start for sending metrics.
PostMeasuresResult result = client.postMeasures(new Measures()
.add(new TaggedMeasure(name, value, tag, tag))
.add(new TaggedMeasure(name, sum, count, min, max, tag, tag ,tag)));
for (PostResult postResult : result.results) {
if (result.isError()) {
log.error(result.toString);
}
}