Skip to content

smagnacco/khronus-java-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java client for Khronus

A simple Java client for Khronus.

It works by buffering metrics to send them later in a batch way.

Maven

<dependency>
    <groupId>com.despegar</groupId>
    <artifactId>khronus-java-client</artifactId>
    <version>0.0.2</version>
</dependency>

How to use it

1) Create the client

new KhronusClient.Builder()
          .withApplicationName("exampleApp")
          .withSendIntervalMillis(3000L)
          .withMaximumMeasures(500000)
          .withHosts("KhronusHost:KhronusPort")
          .build()

The application name is prepend to all metrics names, to guarantee uniqueness in Khronus.

The send interval is how often the metrics are sent to Khronus.

Maximum measures is to avoid excessive memory pressure and potentially OOM.

2) Use it to measure a timer

client.recordTime("pageLoad", 300L)

This will push to Khronus a metric named "exampleApp:pageLoad" with a measured value of 300 milliseconds. If the event occurs previously use an overloaded method to pass the specific timestamp.

3) Use it to measure a counter

client.incrementCounter("pageVisits")

Caveats

  1. The send interval should be less or equal than the minor time window configured in Khronus.

  2. Take in care that the client uses an LinkedBlockingQueue in each measure, who has a penalty in concurrency (minor on most usages) for adding a element.

About

Java client for Khronus

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages