Skip to content

Commit

Permalink
Fix qps time window unit (#13077)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbumenJ authored Sep 19, 2023
1 parent 575c339 commit 139a62e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class TimeWindowCounter {

private final LongAdderSlidingWindow slidingWindow;

public TimeWindowCounter(int bucketNum, int timeWindowSeconds) {
public TimeWindowCounter(int bucketNum, long timeWindowSeconds) {
this.slidingWindow = new LongAdderSlidingWindow(bucketNum, TimeUnit.SECONDS.toMillis(timeWindowSeconds));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit;

import static org.apache.dubbo.common.constants.CommonConstants.CONSUMER_SIDE;
import static org.apache.dubbo.common.constants.CommonConstants.PROVIDER_SIDE;
Expand Down Expand Up @@ -127,7 +128,7 @@ public void onEvent(RequestEvent event) {
if (enableQps) {
MethodMetric metric = calcWindowCounter(event, MetricsKey.METRIC_REQUESTS);
TimeWindowCounter qpsCounter = ConcurrentHashMapUtils.computeIfAbsent(qps, metric,
methodMetric -> new TimeWindowCounter(bucketNum, qpsTimeWindowMillSeconds));
methodMetric -> new TimeWindowCounter(bucketNum, TimeUnit.MILLISECONDS.toSeconds(qpsTimeWindowMillSeconds)));
qpsCounter.increment();
}
}
Expand Down

0 comments on commit 139a62e

Please sign in to comment.