feat: add API latency metrics (Micrometer + Prometheus) - #102
Conversation
- micrometer-registry-prometheus 의존성 추가 - /api/v1/prometheus 엔드포인트 노출 (management exposure) - http.server.requests 히스토그램 버킷 + SLO 버킷 활성화 (p95/p99 계산용) - 공통 태그 application=snuclear-server, 프로필별 env=dev|prod - SecurityConfig: /api/v1/prometheus permitAll (클러스터 내부 scrape용, 외부는 Istio에서 차단) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6ea9520091
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "/api/leaderboard/weekly", | ||
| "/api/v1/health", | ||
| // Prometheus 스크래핑 — 클러스터 내부 접근만 허용, 외부는 Istio VirtualService에서 차단 | ||
| "/api/v1/prometheus", |
There was a problem hiding this comment.
Gate Prometheus scrapes in the app
With src/main/resources/application.yaml:22 exposing prometheus, this permitAll matcher becomes the only application-level gate for /api/v1/prometheus; it does not actually restrict access to cluster-internal clients despite the comment. In any deployment where the public backend route forwards /api/v1/** before or without the separate Istio VirtualService change, anonymous users can scrape request/JVM metrics, so keep this authenticated or add an in-app network/token check unless the route block is deployed atomically.
Useful? React with 👍 / 👎.
셀프 리뷰 ✅변경 검토
검증
probe 영향 없음: 머지합니다. |
변경 사항
주요 API 레이턴시(p95/p99)·트래픽·에러율을 Grafana에서 모니터링하기 위해, 모든 HTTP 엔드포인트를 Micrometer로 자동 계측하고 Prometheus 스크래핑 엔드포인트를 노출합니다.
micrometer-registry-prometheus의존성 추가management.endpoints.web.exposure.include에prometheus추가 →/api/v1/prometheus노출http.server.requests히스토그램 버킷 + SLO 버킷 활성화 → Grafana에서 p95/p99 계산 가능application=snuclear-server, 프로필별env=dev|prodSecurityConfig:/api/v1/prometheuspermitAll (클러스터 내부 Prometheus scrape용)계측 범위
Micrometer가 Spring MVC의 모든 요청을
uri(템플릿 경로)·method·status·outcome태그로 자동 기록합니다. 별도 엔드포인트 지정 없이, 새 API도 자동으로 계측됩니다.보안
/api/v1/prometheus는 permitAll이지만 클러스터 내부 scrape 전용입니다. 외부 노출은 인프라(waffle-world-oci)의 Istio VirtualService에서 차단합니다 (별도 PR)./api/v1/health는 변경하지 않아 기존 liveness/readiness probe에 영향 없습니다.검증
./gradlew compileKotlin ktlintCheck통과/api/v1/prometheus에서http_server_requests_seconds_bucket(p95/p99용) 및application/env태그 정상 출력 확인참고
이 PR은 앱 계측 부분입니다. 대시보드·스크래핑(ServiceMonitor)·외부차단은 인프라 레포(waffle-world-oci)에서 별도 PR로 진행합니다.
🤖 Generated with Claude Code