Skip to content

Latest commit

 

History

History
40 lines (29 loc) · 1.21 KB

README.md

File metadata and controls

40 lines (29 loc) · 1.21 KB

appoptics-api-java

Java language bindings for the AppOptics Metrics API.

Maven Dependency

Find the latest version here.

<dependency>
    <groupId>com.appoptics.metrics</groupId>
    <artifactId>appoptics-api-java</artifactId>
    <version>1.0.2</version>
</dependency>

Setup

You must first initialize the client:

AppopticsClient client = AppopticsClient.builder(apiToken)
    // these are optional
    .setConnectTimeout(new Duration(5, SECONDS))
    .setReadTimeout(new Duration(5, SECONDS))
    .setAgentIdentifier("my app name")
    // and finally build
    .build();

Once your client has been built, you can submit measures to the AppOptics API:

PostMeasuresResult result = client.postMeasures(new Measures()
    .add(new Measure(name, value, tag, tag))
    .add(new Measure(name, sum, count, min, max, tag, tag ,tag)));

for (PostResult postResult : result.results) {
    if (result.isError()) {
        log.error(result.toString);
    }
}