[global] GraphQL 응답속도 Discord 알림 인터셉터 추가#53
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a GraphQL latency monitoring system that sends execution metrics and request details to a Discord channel via webhooks. It implements a WebGraphQlInterceptor to measure latency, a RestClient configuration, and a DiscordWebhookClient for asynchronous notification delivery. Key feedback from the review highlights critical improvements: capturing the SecurityContext synchronously before the reactive chain execution to prevent losing requester information on different threads, recursively masking nested variables to ensure sensitive data is not leaked, adding defensive checks for blank webhook URLs, and providing a default fallback value in application.yaml to avoid startup failures in local or test environments.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
개요
모든 GraphQL 요청의 응답속도를 Discord로 알림 전송하는
WebGraphQlInterceptor를 신규 추가하였습니다. GraphQL은 모든 요청이POST /graphql하나로 들어와 URL만으로는 어떤 쿼리/뮤테이션인지 구분할 수 없어, 요청 단위로 가로채는 인터셉터가 필요했습니다.변경 사항
global/graphql/interceptor/GraphQlLatencyDiscordInterceptor:WebGraphQlInterceptor구현체 신규 추가.@Component로 등록하면 Spring Boot가ObjectProvider<WebGraphQlInterceptor>로 자동 수집하여 별도 설정 클래스 없이 등록됩니다.{이모지} [{환경}] {서비스명} — {상태 문구}형식으로 표준화하였습니다.spring.application.name,spring.profiles.active를 주입받아 서비스명/환경을 표시합니다.`메시지`)로 강조 표시합니다.SecurityContextHolder에서 캡처한 인증 정보로 회원 이름/역할 조회), 쿼리 원문, 요청 변수, 에러 메시지를 담았습니다. 쿼리/변수/에러는 각각graphql/json코드블록으로 감싸 가독성을 높였고, 900자로 truncate하였습니다.input등)까지 재귀적으로 순회하며, 키 이름에password/token/secret이 포함되면 값을***로 마스킹합니다.timestamp필드를 채워, Discord 클라이언트가 자동으로 로컬 타임존 기준 발송 시각을 표시하도록 하였습니다.global/discord/DiscordEmbed,DiscordWebhookClient를 재사용 가능한 컴포넌트로 분리하였습니다.RestClient(신규 의존성 없음)로 전송하며,Schedulers.boundedElastic()에서 fire-and-forget으로 처리해 Discord 전송 지연/실패나 SecurityContext 조회 실패가 실제 GraphQL 응답에 전혀 영향을 주지 않도록 하였습니다.global/config/RestClientConfig에RestClient빈을 신규 등록하였습니다.application.yaml에discord.webhook.graphql-latency-url: ${DISCORD_GRAPHQL_LATENCY_WEBHOOK_URL}을 추가하였습니다.docs/plans/graphql-latency-discord-interceptor-plan.md)를 추가하였습니다.Discord 메시지 예시
정상/지연 요청:
에러 발생 시:
느린 응답(700ms 이상, 에러 없음)일 때는 타이틀이
🐢 [local] GSMC-server-v4 — 느린 응답으로 표시됩니다.참고 사항
DISCORD_GRAPHQL_LATENCY_WEBHOOK_URL환경변수에 실제 Discord 웹훅 URL을 설정해야 합니다.spring.profiles.active가 설정되지 않은 환경(로컬 등)에서는 기본값local이 "환경" 필드/타이틀에 표시됩니다.체크리스트
README,.env.example)