This is an automated email from the ASF dual-hosted git repository.

zhangmeng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/helix.git


The following commit(s) were added to refs/heads/master by this push:
     new b12e025  Use 1 min sliding window size for Helix rest metrics (#1749)
b12e025 is described below

commit b12e0257f8d819ec3e7759c516f3173c729ab22f
Author: Meng Zhang <[email protected]>
AuthorDate: Thu May 20 17:34:01 2021 -0700

    Use 1 min sliding window size for Helix rest metrics (#1749)
    
    Co-authored-by: Meng Zhang <[email protected]>
---
 helix-core/helix-core-1.0.2-SNAPSHOT.ivy                    |  2 +-
 helix-rest/helix-rest-1.0.2-SNAPSHOT.ivy                    |  4 ++--
 .../java/org/apache/helix/rest/server/HelixRestServer.java  | 13 ++++++++++++-
 pom.xml                                                     |  6 +++---
 4 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/helix-core/helix-core-1.0.2-SNAPSHOT.ivy 
b/helix-core/helix-core-1.0.2-SNAPSHOT.ivy
index 56a02a8..ff27a69 100644
--- a/helix-core/helix-core-1.0.2-SNAPSHOT.ivy
+++ b/helix-core/helix-core-1.0.2-SNAPSHOT.ivy
@@ -62,7 +62,7 @@ under the License.
     <dependency org="com.google.guava" name="guava" rev="15.0" 
conf="compile->compile(default);runtime->runtime(default);default->default"/>
     <dependency org="org.yaml" name="snakeyaml" rev="1.12" 
conf="compile->compile(default);runtime->runtime(default);default->default"/>
     <dependency org="commons-logging" name="commons-logging-api" rev="1.1" 
conf="compile->compile(*),master(*);runtime->runtime(*)"/>
-    <dependency org="io.dropwizard.metrics" name="metrics-core" rev="4.1.12.1" 
conf="compile->compile(default);runtime->runtime(default);default->default"/>
+    <dependency org="io.dropwizard.metrics" name="metrics-core" rev="4.1.14" 
conf="compile->compile(default);runtime->runtime(default);default->default"/>
        </dependencies>
 </ivy-module>
 
diff --git a/helix-rest/helix-rest-1.0.2-SNAPSHOT.ivy 
b/helix-rest/helix-rest-1.0.2-SNAPSHOT.ivy
index 3d5fa0b..8295a42 100644
--- a/helix-rest/helix-rest-1.0.2-SNAPSHOT.ivy
+++ b/helix-rest/helix-rest-1.0.2-SNAPSHOT.ivy
@@ -50,7 +50,7 @@ under the License.
                <dependency org="com.fasterxml.jackson.core" 
name="jackson-databind" rev="2.11.0" force="true" 
conf="compile->compile(*),master(*);runtime->runtime(*)"/>
                <dependency org="com.fasterxml.jackson.core" 
name="jackson-core" rev="2.11.0" force="true" 
conf="compile->compile(*),master(*);runtime->runtime(*)"/>
                <dependency org="commons-cli" name="commons-cli" rev="1.2" 
force="true" conf="compile->compile(*),master(*);runtime->runtime(*)"/>
-               <dependency org="io.dropwizard.metrics" name="metrics-jersey2" 
rev="4.1.12.1" force="true" 
conf="compile->compile(*),master(*);runtime->runtime(*)"/>
-               <dependency org="io.dropwizard.metrics" name="metrics-jmx" 
rev="4.1.12.1" force="true" 
conf="compile->compile(*),master(*);runtime->runtime(*)"/>
+               <dependency org="io.dropwizard.metrics" name="metrics-jersey2" 
rev="4.1.14" force="true" 
conf="compile->compile(*),master(*);runtime->runtime(*)"/>
+               <dependency org="io.dropwizard.metrics" name="metrics-jmx" 
rev="4.1.14" force="true" 
conf="compile->compile(*),master(*);runtime->runtime(*)"/>
        </dependencies>
 </ivy-module>
diff --git 
a/helix-rest/src/main/java/org/apache/helix/rest/server/HelixRestServer.java 
b/helix-rest/src/main/java/org/apache/helix/rest/server/HelixRestServer.java
index 4ec3b8c..8137739 100644
--- a/helix-rest/src/main/java/org/apache/helix/rest/server/HelixRestServer.java
+++ b/helix-rest/src/main/java/org/apache/helix/rest/server/HelixRestServer.java
@@ -24,10 +24,15 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import java.util.function.Supplier;
 import javax.net.ssl.SSLContext;
 
+import com.codahale.metrics.Clock;
 import com.codahale.metrics.MetricRegistry;
+import com.codahale.metrics.Reservoir;
 import com.codahale.metrics.SharedMetricRegistries;
+import com.codahale.metrics.SlidingTimeWindowReservoir;
 import 
com.codahale.metrics.jersey2.InstrumentedResourceMethodApplicationListener;
 import com.codahale.metrics.jmx.JmxReporter;
 import org.apache.helix.HelixException;
@@ -178,7 +183,13 @@ public class HelixRestServer {
    */
   private void initMetricRegistry(ResourceConfig cfg, String namespace) {
     MetricRegistry metricRegistry = new MetricRegistry();
-    cfg.register(new 
InstrumentedResourceMethodApplicationListener(metricRegistry));
+    // Set the sliding time window to be 1 minute for now
+    Supplier<Reservoir> reservoirSupplier = () -> {
+      return new SlidingTimeWindowReservoir(60, TimeUnit.SECONDS);
+    };
+    cfg.register(
+        new InstrumentedResourceMethodApplicationListener(metricRegistry, 
Clock.defaultClock(),
+            false, reservoirSupplier));
     SharedMetricRegistries.add(namespace, metricRegistry);
 
     // JmxReporter doesn't have an option to specify namespace for each 
servlet,
diff --git a/pom.xml b/pom.xml
index ff970e5..bb00b59 100644
--- a/pom.xml
+++ b/pom.xml
@@ -449,9 +449,9 @@
     <SKIP_INTEGRATION_TESTS>true</SKIP_INTEGRATION_TESTS>
     <!-- Configuration for unit/integration tests section 1 of 3 (properties) 
ENDS HERE.-->
 
-    <metrics-core.version>4.1.12.1</metrics-core.version>
-    <metrics-jersey2.version>4.1.12.1</metrics-jersey2.version>
-    <metrics-jmx.version>4.1.12.1</metrics-jmx.version>
+    <metrics-core.version>4.1.14</metrics-core.version>
+    <metrics-jersey2.version>4.1.14</metrics-jersey2.version>
+    <metrics-jmx.version>4.1.14</metrics-jmx.version>
   </properties>
 
   <distributionManagement>

Reply via email to