You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@storm.apache.org by GitBox <gi...@apache.org> on 2020/12/14 22:07:02 UTC

[GitHub] [storm] Ethanlm commented on a change in pull request #3350: STORM-3714 add rate tracking to TaskMetrics

Ethanlm commented on a change in pull request #3350:
URL: https://github.com/apache/storm/pull/3350#discussion_r542849974



##########
File path: storm-client/src/jvm/org/apache/storm/metrics2/RateCounter.java
##########
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The ASF licenses this file to you under the Apache License, Version
+ * 2.0 (the "License"); you may not use this file except in compliance with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
+ * and limitations under the License.
+ */
+
+package org.apache.storm.metrics2;
+
+import com.codahale.metrics.Counter;
+import com.codahale.metrics.Gauge;
+
+/**
+ * A Counter metric that also implements a Gauge to report a 1 minute rate.  This class was added as a compromise to

Review comment:
       The calculation in the `update()` method looks to me is a per second rate, instead of 1 minute rate. Am I misunderstanding?

##########
File path: storm-client/src/jvm/org/apache/storm/metrics2/RateCounter.java
##########
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The ASF licenses this file to you under the Apache License, Version
+ * 2.0 (the "License"); you may not use this file except in compliance with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
+ * and limitations under the License.
+ */
+
+package org.apache.storm.metrics2;
+
+import com.codahale.metrics.Counter;
+import com.codahale.metrics.Gauge;
+
+/**
+ * A Counter metric that also implements a Gauge to report a 1 minute rate.  This class was added as a compromise to
+ * using a Meter, which has a much larger performance impact.
+ */
+public class RateCounter implements Gauge<Double> {
+    private Counter counter;
+    private double currentRate = 0;
+    private int time = 0;
+    private final long[] values;
+    private final int timeSpanInSeconds;
+
+    RateCounter(StormMetricRegistry metricRegistry, String metricName, String topologyId,
+                String componentId, int taskId, int workerPort, String streamId) {
+        counter = metricRegistry.counter(metricName, topologyId, componentId,
+                taskId, workerPort, streamId);
+        metricRegistry.gauge(metricName + ".m1_rate", this, topologyId, componentId, streamId,
+                taskId, workerPort);
+        this.timeSpanInSeconds = Math.max(60 - (60 % metricRegistry.getRateCounterUpdateIntervalSeconds()),
+                metricRegistry.getRateCounterUpdateIntervalSeconds());

Review comment:
       I am having difficulties understanding this. Can you please elaborate?  What does `timeSpanInSeconds ` and this equation mean? Thanks




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org