feat(observability): export traces to Tempo via Zipkin reporter#87
Conversation
홈서버 모니터링 스택의 Tempo로 trace를 보내도록 reporter 추가.
이미 micrometer-tracing-bridge-brave가 있고 logback의 prod profile이
traceId MDC를 JSON 로그에 박고 있으므로, Zipkin wire format reporter만
추가하면 Loki ↔ Tempo 양방향 점프 가능.
변경:
- build.gradle: io.zipkin.reporter2:zipkin-reporter-brave 추가
(Brave가 이미 classpath에 있어서 Spring Boot의 ZipkinAutoConfiguration이
ZipkinSpanHandler bean을 자동 생성)
- application-prod.yml:
- management.tracing.propagation.type=b3,w3c — b3는 Brave 표준,
w3c는 OTel 클라이언트와 호환
- management.zipkin.tracing.endpoint=http://tempo:9411/api/v2/spans
(ZIPKIN_ENDPOINT 환경변수로 오버라이드 가능)
샘플링 1.0은 가정 트래픽 기준. 운영 트래픽 증가 시 0.05~0.1 권장.
There was a problem hiding this comment.
Code Review
This pull request configures distributed tracing export to Tempo using the Zipkin wire format by adding the necessary dependency in build.gradle and defining the tracing endpoint and propagation types in application-prod.yml. Feedback suggests upgrading to Zipkin Reporter 3.0 for better compatibility with Spring Boot 3.x and adding the zipkin-sender-urlconnection dependency to ensure the Zipkin auto-configuration functions correctly.
| implementation 'io.micrometer:micrometer-tracing-bridge-brave' | ||
| // Tempo로 trace export (Zipkin wire format). brave가 classpath에 있으면 | ||
| // Spring Boot이 ZipkinAutoConfiguration로 자동 구성. | ||
| implementation 'io.zipkin.reporter2:zipkin-reporter-brave' |
There was a problem hiding this comment.
Spring Boot 3.4 버전부터는 Zipkin Reporter 3.0을 공식적으로 지원하며, 현재 프로젝트의 Spring Boot 버전(3.5.6)을 고려할 때 io.zipkin.reporter2 대신 io.zipkin.reporter3 그룹의 의존성을 사용하는 것이 권장됩니다. 또한, 실제로 HTTP를 통해 Tempo(Zipkin endpoint)로 트레이스를 전송하기 위해서는 Sender 구현체가 필수적입니다. zipkin-sender-urlconnection 의존성을 함께 추가해야 Spring Boot의 Zipkin 자동 설정이 정상적으로 동작하여 트레이스가 전송됩니다.
implementation 'io.zipkin.reporter3:zipkin-reporter-brave'
implementation 'io.zipkin.reporter3:zipkin-sender-urlconnection'
Test Results24 tests 24 ✅ 3s ⏱️ Results for commit 4367103. ♻️ This comment has been updated with latest results. |
리뷰 피드백 반영: - io.zipkin.reporter2 → io.zipkin.reporter3 Spring Boot 3.4+ BOM이 reporter3 그룹을 관리. 3.5.6 사용 중이므로 reporter3가 권장. - zipkin-sender-urlconnection 추가 reporter-brave는 직렬화만 담당. 실제 HTTP 전송은 Sender 구현체가 필요. Sender가 classpath에 없으면 ZipkinAutoConfiguration이 ZipkinSpanHandler 빈을 만들지 않음 → trace 전송 안 됨. URLConnection 기반은 JDK 내장이라 의존성 가벼움. 트래픽 증가 시 okhttp3 sender로 교체 가능.
Spring Boot 3.5 BOM이 관리하는 그룹은 'io.zipkin.reporter2'이며 그 그룹의 내부 버전이 3.5.1로 올라온 형태. 'reporter3'라는 별도 그룹은 Maven Central에 존재하지 않아서 버전 해석이 안 되어 빌드 실패함. 이전 커밋의 리뷰 피드백을 검증 없이 반영한 실수. spring-boot-dependencies-3.5.6.pom의 <zipkin-reporter.version>3.5.1</zipkin-reporter.version> + reporter-bom 그룹이 reporter2임을 확인. - io.zipkin.reporter3 → io.zipkin.reporter2 (sender는 동일하게 유지)
홈서버 모니터링 스택의 Tempo로 trace를 보내도록 reporter 추가.
이미 micrometer-tracing-bridge-brave가 있고 logback의 prod profile이 traceId MDC를 JSON 로그에 박고 있으므로, Zipkin wire format reporter만 추가하면 Loki ↔ Tempo 양방향 점프 가능.
변경:
샘플링 1.0은 가정 트래픽 기준. 운영 트래픽 증가 시 0.05~0.1 권장.
Related issue 🛠
어떤 변경사항이 있었나요?
Work Description ✏️
작업 내용을 작성해주세요.
Uncompleted Tasks 😅
To Reviewers 📢
리뷰어가 알면 좋은 내용을 작성해주세요.