A simple Java client for Khronus.
It works by buffering metrics to send them later in a batch way.
<dependency>
<groupId>com.despegar</groupId>
<artifactId>khronus-java-client</artifactId>
<version>0.0.6</version>
</dependency>
new KhronusClient.Builder()
.withApplicationName("exampleApp")
.withSendIntervalMillis(3000L)
.withMaximumMeasures(500000)
.withHosts("KhronusHost:KhronusPort")
.withEndoint("khronus/metrics")
.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.
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.
client.incrementCounter("pageVisits")
client.shutdown()
-
The send interval should be less or equal than the minor time window configured in Khronus.
-
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.