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

kezhenxu94 pushed a commit to branch sampler
in repository https://gitbox.apache.org/repos/asf/skywalking.git

commit 9e030d26de7a09596e8350434c56530ab48fab08
Author: kezhenxu94 <[email protected]>
AuthorDate: Wed Jul 28 20:34:46 2021 +0800

    Log sampler migrate from qps to rpm
---
 .../analyzer/dsl/spec/sink/sampler/RateLimitingSampler.java  | 12 +++++++++---
 oap-server/server-core/src/main/proto/RemoteService.proto    |  2 +-
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git 
a/oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/dsl/spec/sink/sampler/RateLimitingSampler.java
 
b/oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/dsl/spec/sink/sampler/RateLimitingSampler.java
index c629f75..719ed04 100644
--- 
a/oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/dsl/spec/sink/sampler/RateLimitingSampler.java
+++ 
b/oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/dsl/spec/sink/sampler/RateLimitingSampler.java
@@ -34,9 +34,10 @@ import lombok.extern.slf4j.Slf4j;
 @EqualsAndHashCode(of = {"qps"})
 public class RateLimitingSampler implements Sampler {
     @Getter
-    @Setter
     private volatile int qps;
 
+    private volatile int rpm;
+
     private final AtomicInteger factor = new AtomicInteger();
 
     private final ResetHandler resetHandler;
@@ -45,6 +46,11 @@ public class RateLimitingSampler implements Sampler {
         this.resetHandler = resetHandler;
     }
 
+    public void qps(final int qps) {
+        this.qps = qps;
+        this.rpm = qps * 60;
+    }
+
     @Override
     public RateLimitingSampler start() {
         resetHandler.start(this);
@@ -58,7 +64,7 @@ public class RateLimitingSampler implements Sampler {
 
     @Override
     public boolean sample() {
-        return factor.getAndIncrement() < qps;
+        return factor.getAndIncrement() < rpm;
     }
 
     @Override
@@ -80,7 +86,7 @@ public class RateLimitingSampler implements Sampler {
 
             if (!started) {
                 future = Executors.newSingleThreadScheduledExecutor()
-                                  .scheduleAtFixedRate(this::reset, 1, 1, 
TimeUnit.SECONDS);
+                                  .scheduleAtFixedRate(this::reset, 1, 1, 
TimeUnit.MINUTES);
                 started = true;
             }
         }
diff --git a/oap-server/server-core/src/main/proto/RemoteService.proto 
b/oap-server/server-core/src/main/proto/RemoteService.proto
index 7206b5b..60dceae 100644
--- a/oap-server/server-core/src/main/proto/RemoteService.proto
+++ b/oap-server/server-core/src/main/proto/RemoteService.proto
@@ -40,4 +40,4 @@ message RemoteData {
 }
 
 message Empty {
-}
\ No newline at end of file
+}

Reply via email to