Metrics in Hoplin.io

Hoplin does not have any dependencies on any existing metrics libraries but rather it provides a way to hook into the underlying metrics via MetricsPublisher interface. Metrics expose a number of key/value pairs that are updated and send to metrics consumers.

Depending on which client we use the metrics key will be different and it is up to the consumer to normalize the name. Data is packed into a Map<String, Map<String,String>> structure, this allows us to add metrics easily without breaking any API.

Sample Payload
{exchange.rpc.logs-rpc.request.log={received.size=211, sent.size=204, received.count=1, sent.count=1}}

Metrics Key = exchange.rpc.logs-rpc.request.log
received.size = Amount of data received by this client
received.count = Number of messages received

sent.size = Amount of data sent by this client
sent.count = Number of messages sent

Instantiating metrics consumer

FunctionMetricsPublisher
	.consumer(EmitLogTopic::metrics)
	.withInterval(1, TimeUnit.SECONDS)
	.withResetOnReporting(false)
	.build()
	.start();

private static void metrics(final Map<String, Map<String, String>> stat)
{
  System.out.println("Metrics Info : " + stat);
}

Leave a Comment

Your email address will not be published. Required fields are marked *