-
Notifications
You must be signed in to change notification settings - Fork 3
[FEAT/#447] 커스텀 대시보드·메트릭 및 request-id 로깅 추가 #452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,8 @@ | |
| import com.assu.server.domain.certification.service.CertificationService; | ||
| import com.assu.server.global.util.PrincipalDetails; | ||
|
|
||
| import io.micrometer.core.instrument.MeterRegistry; | ||
| import io.micrometer.core.instrument.Timer; | ||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
|
|
@@ -26,6 +28,7 @@ | |
| public class GroupCertificationController { | ||
|
|
||
| private final CertificationService certificationService; | ||
| private final MeterRegistry meterRegistry; | ||
|
|
||
| @MessageMapping("/certify") | ||
| @Operation( | ||
|
|
@@ -44,15 +47,21 @@ public CertificationProgressResponseDTO certifyGroup(@Payload GroupSessionReques | |
| UsernamePasswordAuthenticationToken auth = (UsernamePasswordAuthenticationToken)principal; | ||
| PrincipalDetails principalDetails = (PrincipalDetails)auth.getPrincipal(); | ||
|
|
||
| Timer.Sample sample = Timer.start(meterRegistry); | ||
| try { | ||
| log.info("### SUCCESS ### 인증 요청 메시지 수신 - user: {}, adminId: {}, sessionId: {}", | ||
| principalDetails.getUsername(), dto.adminId(), dto.sessionId()); | ||
|
|
||
| if (principalDetails != null) { | ||
| return certificationService.handleCertification(dto, principalDetails.getMember()); | ||
| CertificationProgressResponseDTO result = certificationService.handleCertification(dto, principalDetails.getMember()); | ||
| meterRegistry.counter("certification.group.result", "result", "success").increment(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🔎 Supported by static analysis🤖 get_repo_knowledge executed:
Length of output: 4023 🏁 Script executed: #!/bin/bash
set -e
printf '%s\n' '--- controller ---'
sed -n '1,130p' src/main/java/com/assu/server/domain/certification/controller/GroupCertificationController.java
printf '%s\n' '--- service ---'
sed -n '60,175p' src/main/java/com/assu/server/domain/certification/service/CertificationServiceImpl.java
printf '%s\n' '--- metric references ---'
rg -n -C 3 'certification\.group\.result|handleCertification|status' src/main/java src/test || trueRepository: ASSU-dev/ASSU_BE Length of output: 50373 🏁 Script executed: #!/bin/bash
set -e
sed -n '1,130p' src/main/java/com/assu/server/domain/certification/controller/GroupCertificationController.java
printf '\n--- service ---\n'
sed -n '60,175p' src/main/java/com/assu/server/domain/certification/service/CertificationServiceImpl.java
printf '\n--- references ---\n'
rg -n -C 3 'certification\.group\.result|handleCertification|status' src/main/java src/test || trueRepository: ASSU-dev/ASSU_BE Length of output: 50373 🏁 Script executed: #!/bin/bash
set -e
printf '%s\n' '--- controller ---'
cat -n src/main/java/com/assu/server/domain/certification/controller/GroupCertificationController.java | sed -n '1,100p'
printf '%s\n' '--- service ---'
cat -n src/main/java/com/assu/server/domain/certification/service/CertificationServiceImpl.java | sed -n '80,165p'
printf '%s\n' '--- references ---'
rg -n -C 3 'certification\.group\.result|handleCertification|status' src/main/java src/test || trueRepository: ASSU-dev/ASSU_BE Length of output: 50373
🤖 Prompt for AI Agents |
||
| return result; | ||
| } | ||
| } catch (Exception e) { | ||
| log.error("### ERROR ### 인증 처리 중 오류 발생: {}", e.getMessage(), e); | ||
| meterRegistry.counter("certification.group.result", "result", "failure").increment(); | ||
| } finally { | ||
| sample.stop(meterRegistry.timer("certification.group.duration")); | ||
| } | ||
| } | ||
| return null; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ | |
| import com.assu.server.global.exception.DatabaseException; | ||
| import com.assu.server.global.exception.GeneralException; | ||
| import com.assu.server.global.util.PresenceTracker; | ||
| import io.micrometer.core.instrument.MeterRegistry; | ||
| import jakarta.transaction.Transactional; | ||
| import org.springframework.dao.DataIntegrityViolationException; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
@@ -45,6 +46,7 @@ public class ChatServiceImpl implements ChatService { | |
| private final NotificationCommandService notificationCommandService; | ||
| private final PresenceTracker presenceTracker; | ||
| private final BlockRepository blockRepository; | ||
| private final MeterRegistry meterRegistry; | ||
|
|
||
|
|
||
| @Override | ||
|
|
@@ -115,6 +117,7 @@ public MessageHandlingResult handleMessage(ChatRequestDTO.ChatMessageRequestDTO | |
| // 3. 메시지 저장 (기존 로직) | ||
| Message message = Message.toMessageEntity(request, room, sender, receiver, unreadForSender); | ||
| Message saved = messageRepository.saveAndFlush(message); | ||
| meterRegistry.counter("chat.message.sent").increment(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🔎 Supported by static analysis🤖 get_repo_knowledge executed:
Length of output: 4743 🏁 Script executed: #!/bin/bash
set -e
file="src/main/java/com/assu/server/domain/chat/service/ChatServiceImpl.java"
printf '%s\n' '--- target source ---'
cat -n "$file" | sed -n '1,180p'
printf '%s\n' '--- directly bound symbols ---'
rg -n -C 3 'handleMessage|notificationCommandService|sendChat|chat\.message\.sent|`@Transactional`|MeterRegistry' src/main/java src/test 2>/dev/null || trueRepository: ASSU-dev/ASSU_BE Length of output: 50373 🏁 Script executed: #!/bin/bash
set -e
printf '%s\n' '--- notification implementation ---'
cat -n src/main/java/com/assu/server/domain/notification/service/NotificationCommandServiceImpl.java | sed -n '1,125p'
printf '%s\n' '--- transaction event pattern ---'
cat -n src/main/java/com/assu/server/domain/notification/service/OutboxAfterCommitPublisher.java | sed -n '1,75p'
printf '%s\n' '--- chat callers ---'
rg -n -C 5 'handleMessage\(' src/main/java src/test/javaRepository: ASSU-dev/ASSU_BE Length of output: 18136 커밋 후 메트릭 추가는 좋습니다. 그러나 트랜잭션 이벤트를 발행하고 🤖 Prompt for AI AgentsSource: MCP tools |
||
| log.info("saved message id={}, roomId={}, senderId={}, receiverId={}", | ||
| saved.getId(), room.getId(), sender.getId(), receiver.getId()); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| package com.assu.server.global.filter; | ||
|
|
||
| import jakarta.servlet.FilterChain; | ||
| import jakarta.servlet.ServletException; | ||
| import jakarta.servlet.http.HttpServletRequest; | ||
| import jakarta.servlet.http.HttpServletResponse; | ||
| import org.slf4j.MDC; | ||
| import org.springframework.core.Ordered; | ||
| import org.springframework.core.annotation.Order; | ||
| import org.springframework.stereotype.Component; | ||
| import org.springframework.web.filter.OncePerRequestFilter; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.UUID; | ||
|
|
||
| @Component | ||
| @Order(Ordered.HIGHEST_PRECEDENCE) | ||
| public class RequestIdFilter extends OncePerRequestFilter { | ||
|
|
||
| public static final String REQUEST_ID_HEADER = "X-Request-Id"; | ||
| public static final String MDC_KEY = "requestId"; | ||
|
|
||
| @Override | ||
| protected void doFilterInternal( | ||
| HttpServletRequest request, | ||
| HttpServletResponse response, | ||
| FilterChain filterChain) | ||
| throws ServletException, IOException { | ||
| String requestId = UUID.randomUUID().toString(); | ||
| MDC.put(MDC_KEY, requestId); | ||
| response.setHeader(REQUEST_ID_HEADER, requestId); | ||
| try { | ||
| filterChain.doFilter(request, response); | ||
| } finally { | ||
| MDC.remove(MDC_KEY); | ||
|
Comment on lines
+29
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
rg -n -P 'DeferredResult|WebAsyncTask|Callable<|SseEmitter|ResponseBodyEmitter|StreamingResponseBody|CompletionStage|CompletableFuture|`@Async`|WebSocket|Stomp' src/main/java
rg -n -P 'TaskDecorator|ContextSnapshot|ThreadLocalAccessor|MDC\.|RequestIdFilter' src/main/javaRepository: ASSU-dev/ASSU_BE Length of output: 4398 🤖 get_repo_knowledge executed:
Length of output: 3766 🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
printf '%s\n' '--- RequestIdFilter ---'
cat -n src/main/java/com/assu/server/global/filter/RequestIdFilter.java
printf '%s\n' '--- async configuration and uses ---'
rg -n -C 5 '`@EnableAsync`|AsyncConfigurer|TaskDecorator|ThreadPoolTaskExecutor|`@Async`|DeferredResult|WebAsyncTask|Callable<|SseEmitter|ResponseBodyEmitter|StreamingResponseBody|CompletionStage|CompletableFuture' src/main/java
printf '%s\n' '--- filter registration and MVC configuration ---'
rg -n -C 5 'RequestIdFilter|FilterRegistrationBean|OncePerRequestFilter|WebMvcConfigurer|AsyncSupportConfigurer|setTaskExecutor|setCallableInterceptors|setDeferredResultInterceptors' src/main/javaRepository: ASSU-dev/ASSU_BE Length of output: 10078 🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
printf '%s\n' '--- filter source ---'
cat -n src/main/java/com/assu/server/global/filter/RequestIdFilter.java
printf '%s\n' '--- async methods and their callers ---'
rg -n -C 8 '`@Async`|NotificationRetryEventHandler|ReportStatusSyncService' src/main/java
printf '%s\n' '--- async/MDC infrastructure ---'
rg -n -C 5 '`@EnableAsync`|AsyncConfigurer|TaskDecorator|ThreadPoolTaskExecutor|MDC\.|RequestIdFilter' src/main/javaRepository: ASSU-dev/ASSU_BE Length of output: 10052 🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
printf '%s\n' '--- async enablement and event publication ---'
rg -n -C 6 '`@EnableAsync`|ReportProcessedEvent|NotificationFailedEvent|publishEvent|ApplicationEventPublisher' src/main/java
printf '%s\n' '--- relevant event handler bodies ---'
cat -n src/main/java/com/assu/server/domain/report/service/ReportStatusSyncService.java
cat -n src/main/java/com/assu/server/domain/notification/service/NotificationRetryEventHandler.javaRepository: ASSU-dev/ASSU_BE Length of output: 50372 🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
rg -n -C 8 'ReportProcessedEvent|NotificationFailedEvent|publishEvent|ApplicationEventPublisher|Executors|schedule\(' src/main/java
rg -n '`@EnableAsync`|TaskDecorator|ContextSnapshot|MDC' src/main/javaRepository: ASSU-dev/ASSU_BE Length of output: 50372 🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
printf '%s\n' '--- report HTTP entry point and async enablement ---'
rg -n -C 6 'reportContent\(|ReportService|`@EnableAsync`|task:annotation-driven' src/main/java src/main/resourcesRepository: ASSU-dev/ASSU_BE Length of output: 27567
이 경로는 MVC 🤖 Prompt for AI AgentsSource: MCP tools |
||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
4칸 들여쓰기를 사용하세요.
Line 31의
meterRegistry필드는 탭으로 들여쓰기되어 있습니다. 탭을 4개의 공백으로 변경하세요.As per coding guidelines:
src/main/java/com/assu/server/**/*.java는 Java 17과 4-space indentation을 사용해야 합니다.🤖 Prompt for AI Agents
Source: Coding guidelines