Add peak QPS of time window #240

This commit is contained in:
Francis Dong
2021-07-08 12:13:25 +08:00
committed by dxfeng10
parent ea7aac9897
commit ea10d6a952
2 changed files with 16 additions and 0 deletions

View File

@@ -203,6 +203,7 @@ public class ResourceStat {
long totalReqs = 0;
long totalRt = 0;
long peakConcurrences = 0;
long peakRps = 0;
long errors = 0;
long blockReqs = 0;
long totalBlockReqs = 0;
@@ -215,6 +216,7 @@ public class ResourceStat {
peakConcurrences = timeSlot.getPeakConcurrentRequests() > peakConcurrences
? timeSlot.getPeakConcurrentRequests()
: peakConcurrences;
peakRps = timeSlot.getCounter().get() > peakRps ? timeSlot.getCounter().get() : peakRps;
totalReqs = totalReqs + timeSlot.getCounter().get();
totalRt = totalRt + timeSlot.getTotalRt().get();
errors = errors + timeSlot.getErrors().get();
@@ -232,6 +234,7 @@ public class ResourceStat {
tws.setBlockRequests(blockReqs);
tws.setTotalBlockRequests(totalBlockReqs);
tws.setCompReqs(compReqs);
tws.setPeakRps(new BigDecimal(peakRps));
if (compReqs > 0) {
tws.setAvgRt(totalRt / compReqs);

View File

@@ -69,6 +69,11 @@ public class TimeWindowStat {
* the average RPS(Requests Per Second) of time window
*/
private BigDecimal rps;
/**
* the peak RPS(Requests Per Second) of time window
*/
private BigDecimal peakRps;
/**
* Peak concurrent requests of the time window
@@ -181,4 +186,12 @@ public class TimeWindowStat {
this.totalBlockRequests = totalBlockRequests;
}
public BigDecimal getPeakRps() {
return peakRps;
}
public void setPeakRps(BigDecimal peakRps) {
this.peakRps = peakRps;
}
}