From 35648278fc048578b99f9d561d4228c7433cf568 Mon Sep 17 00:00:00 2001 From: leyangyueshan <15891721997@163.com> Date: Thu, 31 Dec 2020 22:37:31 +0800 Subject: [PATCH] HBASE-25435 Slow metric value can be configured Signed-off-by: jediwang --- .../hbase/regionserver/MetricsRegionServer.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServer.java index 5b05c12348b..824c6b28e19 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServer.java @@ -42,6 +42,7 @@ public class MetricsRegionServer { "hbase.regionserver.enable.table.latencies"; public static final boolean RS_ENABLE_TABLE_METRICS_DEFAULT = true; + public static final String SLOW_METRIC_TIME = "hbase.ipc.slow.metric.time"; private final MetricsRegionServerSource serverSource; private final MetricsRegionServerWrapper regionServerWrapper; private RegionServerTableMetrics tableMetrics; @@ -53,6 +54,8 @@ public class MetricsRegionServer { private Timer bulkLoadTimer; private Meter serverReadQueryMeter; private Meter serverWriteQueryMeter; + protected long slowMetricTime; + protected static final int DEFAULT_SLOW_METRIC_TIME = 1000; // milliseconds public MetricsRegionServer(MetricsRegionServerWrapper regionServerWrapper, Configuration conf, MetricsTable metricsTable) { @@ -68,6 +71,7 @@ public class MetricsRegionServer { // create and use metrics from the new hbase-metrics based registry. bulkLoadTimer = metricRegistry.timer("Bulkload"); + slowMetricTime = conf.getLong(SLOW_METRIC_TIME, DEFAULT_SLOW_METRIC_TIME); serverReadQueryMeter = metricRegistry.meter("ServerReadQueryPerSecond"); serverWriteQueryMeter = metricRegistry.meter("ServerWriteQueryPerSecond"); quotaSource = CompatibilitySingletonFactory.getInstance(MetricsRegionServerQuotaSource.class); @@ -109,7 +113,7 @@ public class MetricsRegionServer { if (tableMetrics != null && tn != null) { tableMetrics.updatePutBatch(tn, t); } - if (t > 1000) { + if (t > slowMetricTime) { serverSource.incrSlowPut(); } serverSource.updatePutBatch(t); @@ -135,7 +139,7 @@ public class MetricsRegionServer { if (tableMetrics != null && tn != null) { tableMetrics.updateDeleteBatch(tn, t); } - if (t > 1000) { + if (t > slowMetricTime) { serverSource.incrSlowDelete(); } serverSource.updateDeleteBatch(t); @@ -166,7 +170,7 @@ public class MetricsRegionServer { if (tableMetrics != null && tn != null) { tableMetrics.updateGet(tn, t); } - if (t > 1000) { + if (t > slowMetricTime) { serverSource.incrSlowGet(); } serverSource.updateGet(t); @@ -177,7 +181,7 @@ public class MetricsRegionServer { if (tableMetrics != null && tn != null) { tableMetrics.updateIncrement(tn, t); } - if (t > 1000) { + if (t > slowMetricTime) { serverSource.incrSlowIncrement(); } serverSource.updateIncrement(t); @@ -188,7 +192,7 @@ public class MetricsRegionServer { if (tableMetrics != null && tn != null) { tableMetrics.updateAppend(tn, t); } - if (t > 1000) { + if (t > slowMetricTime) { serverSource.incrSlowAppend(); } serverSource.updateAppend(t);