평균값 계산 로직 보완
This commit is contained in:
@@ -152,12 +152,12 @@ public class HourStatsAggregator {
|
||||
* @return 백분위 응답시간 (ms)
|
||||
*/
|
||||
private long calculatePercentile(double percentile) {
|
||||
long total = totalCnt.get();
|
||||
if (total == 0) {
|
||||
long avgCount = getAvgCount();
|
||||
if (avgCount == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
long targetCount = (long) Math.ceil(total * percentile / 100.0);
|
||||
long targetCount = (long) Math.ceil(avgCount * percentile / 100.0);
|
||||
long accumulated = 0;
|
||||
|
||||
for (int i = 0; i < respTimeBuckets.length; i++) {
|
||||
@@ -193,7 +193,7 @@ public class HourStatsAggregator {
|
||||
long timeout = timeoutCnt.get();
|
||||
long systemErr = systemErrCnt.get();
|
||||
long bizErr = bizErrCnt.get();
|
||||
long avgCount = success + timeout + systemErr + bizErr;
|
||||
long avgCount = getAvgCount();
|
||||
|
||||
stats.setTotalCnt(total);
|
||||
stats.setSuccessCnt(success);
|
||||
@@ -233,6 +233,14 @@ public class HourStatsAggregator {
|
||||
return stats;
|
||||
}
|
||||
|
||||
private long getAvgCount() {
|
||||
long success = successCnt.get();
|
||||
long timeout = timeoutCnt.get();
|
||||
long systemErr = systemErrCnt.get();
|
||||
long bizErr = bizErrCnt.get();
|
||||
return success + timeout + systemErr + bizErr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 집계된 총 건수 반환 (빈 집계기 체크용)
|
||||
*/
|
||||
|
||||
+11
-3
@@ -152,12 +152,12 @@ public class MinuteStatsAggregator {
|
||||
* @return 백분위 응답시간 (ms)
|
||||
*/
|
||||
private long calculatePercentile(double percentile) {
|
||||
long total = totalCnt.get();
|
||||
if (total == 0) {
|
||||
long avgCount = getAvgCount();
|
||||
if (avgCount == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
long targetCount = (long) Math.ceil(total * percentile / 100.0);
|
||||
long targetCount = (long) Math.ceil(avgCount * percentile / 100.0);
|
||||
long accumulated = 0;
|
||||
|
||||
for (int i = 0; i < respTimeBuckets.length; i++) {
|
||||
@@ -239,4 +239,12 @@ public class MinuteStatsAggregator {
|
||||
public long getTotalCount() {
|
||||
return totalCnt.get();
|
||||
}
|
||||
|
||||
private long getAvgCount() {
|
||||
long success = successCnt.get();
|
||||
long timeout = timeoutCnt.get();
|
||||
long systemErr = systemErrCnt.get();
|
||||
long bizErr = bizErrCnt.get();
|
||||
return success + timeout + systemErr + bizErr;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user