Refactor: GatewayLoggingAspect를 axhub-gateway 모듈로 이동 및 포인트컷 최적화

This commit is contained in:
jade
2026-07-06 09:59:45 +09:00
parent 42fa2d8e7a
commit 40c163828e
2 changed files with 6 additions and 8 deletions

View File

@@ -1,41 +0,0 @@
package io.shinhanlife.axhub.biz.mcp.adapter.aop;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;
import org.springframework.util.StopWatch;
@Slf4j
@Aspect
@Component
public class GatewayLoggingAspect {
// controller 및 connector 패키지 하위의 모든 클래스/메서드 실행 시 작동
@Around("execution(* io.shinhanlife.axhub.biz.mcp.gateway.controller..*(..)) " +
"|| execution(* io.shinhanlife.axhub.biz.mcp.tool.controller..*(..)) " +
"|| execution(* io.shinhanlife.axhub.biz.mcp.adapter.connector..*(..))")
public Object logConnectorExecutionTime(ProceedingJoinPoint joinPoint) throws Throwable {
String targetMethod = joinPoint.getSignature().toShortString();
StopWatch stopWatch = new StopWatch();
log.info(" [Gateway 송신 시작] Target: {}", targetMethod);
stopWatch.start();
try {
// 실제 대상 메서드(외부 통신) 실행
Object result = joinPoint.proceed();
return result;
} finally {
stopWatch.stop();
long timeMillis = stopWatch.getTotalTimeMillis();
if (timeMillis > 3000) { // 3초 이상 걸리면 WARN 로그로 슬로우 통신 경고
log.warn("⏱ [Gateway 슬로우 응답] Target: {} | 소요시간: {}ms", targetMethod, timeMillis);
} else {
log.info("⏹ [Gateway 송신 완료] Target: {} | 소요시간: {}ms", targetMethod, timeMillis);
}
}
}
}

View File

@@ -102,7 +102,7 @@ public class ToolRegistryHeartbeatSender {
.toEntity(String.class);
if (response.getStatusCode().is2xxSuccessful()) {
log.debug(" [HeartbeatSender] 하트비트 전송 성공: {}", tool.getToolName());
log.info(" [HeartbeatSender] 하트비트 전송 성공: {}", tool.getToolName());
}
} catch (Exception e) {
log.warn(" [HeartbeatSender] 하트비트 전송 실패 ({}): {}. 재등록을 시도합니다.", tool.getToolName(), e.getMessage());