From 434c0f285f39aec842943941b3d4c7382383ecf7 Mon Sep 17 00:00:00 2001 From: YangJiaqi Date: Mon, 29 Jul 2024 22:08:25 +0800 Subject: [PATCH] fix JRaft Timer Metrics BUG --- .../store/node/metrics/JRaftMetrics.java | 40 ++++++++++++++----- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/hugegraph-store/hg-store-node/src/main/java/org/apache/hugegraph/store/node/metrics/JRaftMetrics.java b/hugegraph-store/hg-store-node/src/main/java/org/apache/hugegraph/store/node/metrics/JRaftMetrics.java index a9b53de2db..098372bee6 100644 --- a/hugegraph-store/hg-store-node/src/main/java/org/apache/hugegraph/store/node/metrics/JRaftMetrics.java +++ b/hugegraph-store/hg-store-node/src/main/java/org/apache/hugegraph/store/node/metrics/JRaftMetrics.java @@ -214,18 +214,36 @@ private static void registerTimer(String group, String name, com.codahale.metric String baseName = PREFIX + "." + name.toLowerCase(); - Gauge.builder(baseName + ".count", timer, Timer::getCount) + Gauge.builder(baseName + ".count", timer, t->t.getCount()) + .tags(tags).register(registry); + Gauge.builder(baseName + ".min", timer, t -> t.getSnapshot().getMin()) + .tags(tags).register(registry); + Gauge.builder(baseName + ".max", timer, t -> t.getSnapshot().getMax()) + .tags(tags).register(registry); + Gauge.builder(baseName + ".mean", timer, t -> t.getSnapshot().getMean()) + .tags(tags).register(registry); + Gauge.builder(baseName + ".stddev", timer, t -> t.getSnapshot().getStdDev()) + .tags(tags).register(registry); + Gauge.builder(baseName + ".p50", timer, t -> t.getSnapshot().getMedian()) + .tags(tags).register(registry); + Gauge.builder(baseName + ".p75", timer, t -> t.getSnapshot().get75thPercentile()) + .tags(tags).register(registry); + Gauge.builder(baseName + ".p95", timer, t -> t.getSnapshot().get95thPercentile()) + .tags(tags).register(registry); + Gauge.builder(baseName + ".p98", timer, t -> t.getSnapshot().get98thPercentile()) + .tags(tags).register(registry); + Gauge.builder(baseName + ".p99", timer, t -> t.getSnapshot().get99thPercentile()) + .tags(tags).register(registry); + Gauge.builder(baseName + ".p999", timer, t -> t.getSnapshot().get999thPercentile()) + .tags(tags).register(registry); + Gauge.builder(baseName + ".m1_rate", timer, t -> t.getOneMinuteRate()) + .tags(tags).register(registry); + Gauge.builder(baseName + ".m5_rate", timer, t -> t.getFiveMinuteRate()) + .tags(tags).register(registry); + Gauge.builder(baseName + ".m15_rate", timer, t -> t.getFifteenMinuteRate()) + .tags(tags).register(registry); + Gauge.builder(baseName + ".mean_rate", timer, t -> t.getMeanRate()) .tags(tags).register(registry); - - Gauge.builder(baseName + ".timer", timer, Timer::getCount) - .tags(tags).tag("rate", "1m").register(registry); - Gauge.builder(baseName + ".timer", timer, Timer::getCount) - .tags(tags).tag("rate", "5m").register(registry); - Gauge.builder(baseName + ".timer", timer, Timer::getCount) - .tags(tags).tag("rate", "15m").register(registry); - Gauge.builder(baseName + ".timer", timer, Timer::getCount) - .tags(tags).tag("rate", "mean").register(registry); - } private static void registerMeter(String group, String name, com.codahale.metrics.Meter meter) {