통계 에러 처리 로직 수정

This commit is contained in:
pksup
2026-01-13 13:51:16 +09:00
parent 84f816b6a8
commit b708aa7688
3 changed files with 36 additions and 28 deletions
@@ -25,9 +25,9 @@ public class ApiStatsMonitorImpl implements StatisticsMonitor {
@Override @Override
public void recordStatistics(EAIMessage requestEaiMessage) { public void recordStatistics(EAIMessage requestEaiMessage) {
try { try {
// 로그 시퀀스 400 또는 900만 처리 // 로그 시퀀스 100, 400, 900만 처리
int logSequence = requestEaiMessage.getLogPssSno(); int logSequence = requestEaiMessage.getLogPssSno();
if (logSequence != 400 && logSequence != 900) { if (logSequence != 100 && logSequence != 400 && logSequence != 900) {
return; return;
} }
@@ -22,7 +22,6 @@ public class HourStatsAggregator {
// 건수 메트릭 // 건수 메트릭
private final AtomicLong totalCnt = new AtomicLong(0); private final AtomicLong totalCnt = new AtomicLong(0);
private final AtomicLong successCnt = new AtomicLong(0);
private final AtomicLong timeoutCnt = new AtomicLong(0); private final AtomicLong timeoutCnt = new AtomicLong(0);
private final AtomicLong systemErrCnt = new AtomicLong(0); private final AtomicLong systemErrCnt = new AtomicLong(0);
private final AtomicLong bizErrCnt = new AtomicLong(0); private final AtomicLong bizErrCnt = new AtomicLong(0);
@@ -62,13 +61,13 @@ public class HourStatsAggregator {
public void recordEvent(TransactionEvent event) { public void recordEvent(TransactionEvent event) {
int logSeq = event.getLogSequence(); int logSeq = event.getLogSequence();
// 로그 시퀀스 400: 일반 통계 집계 // 로그 시퀀스 100: 총 건수만 증가 (첫 호출)
if (logSeq == 400) { if (logSeq == 100) {
totalCnt.incrementAndGet(); totalCnt.incrementAndGet();
}
if (event.isSuccess()) { // 로그 시퀀스 400: 응답시간 및 에러 타입 기록
successCnt.incrementAndGet(); else if (logSeq == 400) {
} else { if (!event.isSuccess()) {
switch (event.getErrorType()) { switch (event.getErrorType()) {
case TIMEOUT: case TIMEOUT:
timeoutCnt.incrementAndGet(); timeoutCnt.incrementAndGet();
@@ -185,11 +184,17 @@ public class HourStatsAggregator {
stats.setOutboundAdapter(key.getOutboundAdapter()); stats.setOutboundAdapter(key.getOutboundAdapter());
// 건수 메트릭 // 건수 메트릭
stats.setTotalCnt(totalCnt.get()); long total = totalCnt.get();
stats.setSuccessCnt(successCnt.get()); long timeout = timeoutCnt.get();
stats.setTimeoutCnt(timeoutCnt.get()); long systemErr = systemErrCnt.get();
stats.setSystemErrCnt(systemErrCnt.get()); long bizErr = bizErrCnt.get();
stats.setBizErrCnt(bizErrCnt.get()); long success = total - (timeout + systemErr + bizErr);
stats.setTotalCnt(total);
stats.setSuccessCnt(success);
stats.setTimeoutCnt(timeout);
stats.setSystemErrCnt(systemErr);
stats.setBizErrCnt(bizErr);
// 로그 시퀀스 900 구간 에러 카운트 // 로그 시퀀스 900 구간 에러 카운트
stats.setSeq900TimeoutCnt(seq900TimeoutCnt.get()); stats.setSeq900TimeoutCnt(seq900TimeoutCnt.get());
@@ -197,7 +202,6 @@ public class HourStatsAggregator {
stats.setSeq900BizErrCnt(seq900BizErrCnt.get()); stats.setSeq900BizErrCnt(seq900BizErrCnt.get());
// 응답시간 메트릭 // 응답시간 메트릭
long total = totalCnt.get();
if (total > 0) { if (total > 0) {
// 평균 // 평균
double avg = (double) totalRespTime.get() / total; double avg = (double) totalRespTime.get() / total;
@@ -22,7 +22,6 @@ public class MinuteStatsAggregator {
// 건수 메트릭 // 건수 메트릭
private final AtomicLong totalCnt = new AtomicLong(0); private final AtomicLong totalCnt = new AtomicLong(0);
private final AtomicLong successCnt = new AtomicLong(0);
private final AtomicLong timeoutCnt = new AtomicLong(0); private final AtomicLong timeoutCnt = new AtomicLong(0);
private final AtomicLong systemErrCnt = new AtomicLong(0); private final AtomicLong systemErrCnt = new AtomicLong(0);
private final AtomicLong bizErrCnt = new AtomicLong(0); private final AtomicLong bizErrCnt = new AtomicLong(0);
@@ -62,13 +61,13 @@ public class MinuteStatsAggregator {
public void recordEvent(TransactionEvent event) { public void recordEvent(TransactionEvent event) {
int logSeq = event.getLogSequence(); int logSeq = event.getLogSequence();
// 로그 시퀀스 400: 일반 통계 집계 // 로그 시퀀스 100: 총 건수만 증가 (첫 호출)
if (logSeq == 400) { if (logSeq == 100) {
totalCnt.incrementAndGet(); totalCnt.incrementAndGet();
}
if (event.isSuccess()) { // 로그 시퀀스 400: 응답시간 및 에러 타입 기록
successCnt.incrementAndGet(); else if (logSeq == 400) {
} else { if (!event.isSuccess()) {
switch (event.getErrorType()) { switch (event.getErrorType()) {
case TIMEOUT: case TIMEOUT:
timeoutCnt.incrementAndGet(); timeoutCnt.incrementAndGet();
@@ -185,11 +184,17 @@ public class MinuteStatsAggregator {
stats.setOutboundAdapter(key.getOutboundAdapter()); stats.setOutboundAdapter(key.getOutboundAdapter());
// 건수 메트릭 // 건수 메트릭
stats.setTotalCnt(totalCnt.get()); long total = totalCnt.get();
stats.setSuccessCnt(successCnt.get()); long timeout = timeoutCnt.get();
stats.setTimeoutCnt(timeoutCnt.get()); long systemErr = systemErrCnt.get();
stats.setSystemErrCnt(systemErrCnt.get()); long bizErr = bizErrCnt.get();
stats.setBizErrCnt(bizErrCnt.get()); long success = total - (timeout + systemErr + bizErr);
stats.setTotalCnt(total);
stats.setSuccessCnt(success);
stats.setTimeoutCnt(timeout);
stats.setSystemErrCnt(systemErr);
stats.setBizErrCnt(bizErr);
// 로그 시퀀스 900 구간 에러 카운트 // 로그 시퀀스 900 구간 에러 카운트
stats.setSeq900TimeoutCnt(seq900TimeoutCnt.get()); stats.setSeq900TimeoutCnt(seq900TimeoutCnt.get());
@@ -197,7 +202,6 @@ public class MinuteStatsAggregator {
stats.setSeq900BizErrCnt(seq900BizErrCnt.get()); stats.setSeq900BizErrCnt(seq900BizErrCnt.get());
// 응답시간 메트릭 // 응답시간 메트릭
long total = totalCnt.get();
if (total > 0) { if (total > 0) {
// 평균 // 평균
double avg = (double) totalRespTime.get() / total; double avg = (double) totalRespTime.get() / total;