Micrometer metrics not printing histogram values

186 views
Skip to first unread message

Himanshu Gupta

unread,
Aug 29, 2022, 7:03:40 AM8/29/22
to vert.x
I have enabled the percentile using 

.config().meterFilter(
new MeterFilter() {
@Override
public DistributionStatisticConfig configure(Meter.Id id, DistributionStatisticConfig config) {
return DistributionStatisticConfig.builder()
.percentilesHistogram(true)
.percentiles(0, 0.50, 0.90, 0.95, 0.99)
.build()
.merge(config);
}
});

But I am not seeing the percentile metrics

MetricsService metricsService = MetricsService.create(vertx);
vertx.setPeriodic(1000, t -> {
log.info(metricsService.getMetricsSnapshot("vertx.http.client").encode());
});

{"vertx.http.client.active.connections":[{"tags":{},"type":"gauge","value":2.0}],"vertx.http.client.active.requests":[{"tags":{"method":"GET"},"type":"gauge","value":200.0}],"vertx.http.client.bytes.read":[{"tags":{},"type":"counter","count":174900.0}],"vertx.http.client.queue.pending":[{"tags":{},"type":"gauge","value":2.0}],"vertx.http.client.queue.time":[{"tags":{},"type":"timer","count":8150,"totalTimeMs":339976.842014,"meanMs":41.7149499403681,"maxMs":1739.601042}],"vertx.http.client.request.bytes":[{"tags":{"method":"GET"},"type":"summary","count":8150,"total":0.0,"mean":0.0,"max":0.0}],"vertx.http.client.requests":[{"tags":{"method":"GET"},"type":"counter","count":8150.0}],"vertx.http.client.response.bytes":[{"tags":{"code":"200","method":"GET"},"type":"summary","count":7950,"total":174900.0,"mean":22.0,"max":22.0}],"vertx.http.client.response.time":[{"tags":{"code":"200","method":"GET"},"type":"timer","count":7950,"totalTimeMs":2473064.474085,"meanMs":311.07729233773586,"maxMs":816.967}],"vertx.http.client.responses":[{"tags":{"code":"200","method":"GET"},"type":"counter","count":7950.0}]} 

Himanshu Gupta

unread,
Aug 29, 2022, 9:06:05 AM8/29/22
to vert.x
Found the issue.

These two method needs to be changed in MetricsServiceImpl.java

private static JsonObject summaryToJson(JsonObject obj, DistributionSummary summary) {
HistogramSnapshot snapshot = summary.takeSnapshot(false);
obj.put("type", "summary")
.put("count", snapshot.count())
.put("total", snapshot.total())
.put("mean", snapshot.mean())
.put("max", snapshot.max());
for (ValueAtPercentile valueAtPercentile : snapshot.percentileValues()) {
obj.put(Double.toString(valueAtPercentile.percentile()), valueAtPercentile.value());
}

return obj;
}

private static JsonObject timerToJson(JsonObject obj, Timer timer) {
HistogramSnapshot snapshot = timer.takeSnapshot(false);

obj.put("type", "timer")
.put("count", timer.count())
.put("totalTimeMs", timer.totalTime(TimeUnit.MILLISECONDS))
.put("meanMs", timer.mean(TimeUnit.MILLISECONDS))
.put("maxMs", timer.max(TimeUnit.MILLISECONDS));
for (ValueAtPercentile valueAtPercentile : snapshot.percentileValues()) {
obj.put(Double.toString(valueAtPercentile.percentile()), valueAtPercentile.value());
}

return obj;
}

Thomas SEGISMONT

unread,
Aug 29, 2022, 9:47:01 AM8/29/22
to ve...@googlegroups.com
Thanks. Would you mind sending a pull-request?

--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/9f47e89d-900f-4549-9032-fcba7a498e00n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages