85 lines
5.5 KiB
Markdown
85 lines
5.5 KiB
Markdown
---
|
|
title: "company-tech-blog / LINE / Ryosuke Hasebe — About Micrometer Context Propagation (2025)"
|
|
source_type: company-tech-blog
|
|
url: https://dev.to/be-hase/about-micrometer-context-propagation-5gg9
|
|
archive_url:
|
|
related_branches: [feature-runtime-context-propagation-contract]
|
|
related_projects: [ca-skeleton, ca-tmpl]
|
|
tags: [company-tech-blog, micrometer, context-propagation, threadlocal, context-snapshot, line, spring-boot-3]
|
|
created: 2026-06-09
|
|
last_reviewed: 2026-06-09
|
|
status: raw
|
|
confidence: medium
|
|
---
|
|
|
|
# LINE (Ryosuke Hasebe) — About Micrometer Context Propagation
|
|
|
|
> Layer: `raw/company-tech-blogs/` — LINE (Tokyo) Principal SWE / Senior EM Ryosuke Hasebe 의 기술 아티클.
|
|
> **출처 주의**: company-tech-blog 이므로 공식 best practice 로 일반화 금지. Micrometer Context Propagation 의 MDC/Kotlin 통합 사례 reference 로만 사용.
|
|
> WebFetch 성공. Author: Ryosuke Hasebe (LINE, Principal SWE), Published: February 7, 2025.
|
|
|
|
## Parent / 활용 branch
|
|
|
|
| Branch | 이 자료가 정당화하는 결정 |
|
|
|---|---|
|
|
| [[raw/branch-notes/feature-runtime-context-propagation-contract]] | Alt-2 (Micrometer ContextSnapshot/ContextRegistry) 의 실제 사용 패턴 사례 — MDC 를 ThreadLocalAccessor 로 등록하고 ContextSnapshot.setThreadLocals() 로 capture-restore 하는 패턴 |
|
|
|
|
## 출처 / Source
|
|
|
|
- 원본 URL: https://dev.to/be-hase/about-micrometer-context-propagation-5gg9
|
|
- 저자: Ryosuke Hasebe (Principal SWE and Senior EM at LINE, Tokyo)
|
|
- 발행일: February 7, 2025
|
|
- 마지막 확인일: 2026-06-09
|
|
- 접근 상태: WebFetch 성공
|
|
|
|
## 핵심 인용 / Key quotes (verbatim, WebFetch)
|
|
|
|
> "A ContextSnapshot can be created via ContextSnapshotFactory" by calling captureAll(). The snapshot stores Thread Local values which are then propagated through `setThreadLocals().use { }` constructs that manage lifecycle via resource cleanup.
|
|
|
|
> "MDC.put("hoge", "hoge-value"); snapshot.setThreadLocals().use { someFunc1() }"
|
|
> (Kotlin code example demonstrating capture-restore with MDC)
|
|
|
|
> "restore() methods can be overridden in ThreadLocalAccessor for flexibility when 'restoring the original value'"
|
|
|
|
> Author characterizes the primary use case as: "Including context information in logs offers enhanced debugging, improved auditing and monitoring, and streamlined troubleshooting."
|
|
|
|
## Self-Grep 검증
|
|
|
|
```
|
|
Fragment: "A ContextSnapshot can be created via ContextSnapshotFactory"
|
|
→ WebFetch output 에서 확인 PASS
|
|
|
|
Fragment: "MDC.put(\"hoge\", \"hoge-value\")"
|
|
→ WebFetch output 에서 확인 PASS (Kotlin code block)
|
|
```
|
|
|
|
검증한 인용 V: 3 / PASS P: 3 / 폐기 D: 0
|
|
|
|
## Claims Extracted
|
|
|
|
| Claim ID | Claim | Evidence quote | Strength | Applies to | Does not prove |
|
|
|---|---|---|---|---|---|
|
|
| LN-MCP-C1 | ContextSnapshotFactory.captureAll() 로 현재 thread 의 ThreadLocal 값들을 snapshot 으로 수집한 뒤, setThreadLocals().use { } 패턴으로 다른 thread 에서 restore 하는 것이 Micrometer Context Propagation 의 핵심 사용 패턴이다 | "A ContextSnapshot can be created via ContextSnapshotFactory by calling captureAll(). The snapshot stores Thread Local values which are then propagated through setThreadLocals().use { } constructs that manage lifecycle via resource cleanup." | `company-case-study` | Spring Boot + io.micrometer:context-propagation 사용 코드 | virtual thread 에서의 안전성 — 이 아티클은 virtual threads 를 언급하지 않음 |
|
|
| LN-MCP-C2 | MDC 는 Micrometer Context Propagation 의 ThreadLocalAccessor 구현체로 등록 가능하며 ContextSnapshot 에 포함된다 | "MDC.put("hoge", "hoge-value"); snapshot.setThreadLocals().use { someFunc1() }" 패턴이 MDC 를 context 로 전달함 | `company-case-study` | MDC + Micrometer Context Propagation 을 함께 사용하는 코드 | 이 패턴이 ca-tmpl 의 foundation branch MDC accessor 와 충돌 없이 동작하는지 — 별도 검증 필요 |
|
|
| LN-MCP-C3 | ThreadLocalAccessor 의 restore() 메서드를 override 하면 원래 값으로 복원하는 동작을 커스터마이즈할 수 있다 | "restore() methods can be overridden in ThreadLocalAccessor for flexibility when 'restoring the original value'" | `company-case-study` | 커스텀 도메인 context 를 ThreadLocalAccessor 로 구현하는 경우 | 이것이 "공식" 패턴인지 — Micrometer 공식 문서에 동일한 내용 있으면 `official-vendor-doc` 으로 업그레이드 가능 |
|
|
|
|
## Usage Boundaries
|
|
|
|
- 이 자료가 지지하는 것:
|
|
- captureAll() + setThreadLocals().use {} 가 실제 코드에서 MDC propagation 에 동작함 (LINE 엔지니어 검증)
|
|
- ThreadLocalAccessor 의 restore() override 가 가능하고 유용함
|
|
- 이 자료가 증명하지 않는 것:
|
|
- virtual thread (Java 21 Loom) 환경에서의 동작 안전성
|
|
- ScopedValue 와의 비교 또는 co-existence
|
|
- Spring Boot 의 auto-configured MDC accessor 와의 충돌 여부
|
|
- 내 프로젝트 적용 시 주의:
|
|
- Kotlin 코드 예시이므로 Java 코드로의 변환 필요
|
|
- LINE 의 MDC propagation 패턴이 ca-tmpl 의 foundation branch (diagnostic keys) 와 동일한 범위인지 확인
|
|
- 이 아티클은 "domain/business context" 가 아닌 "diagnostic context" (MDC) 를 다룸 — business context 에의 적용 extrapolation 은 INFERENCE
|
|
|
|
## 메모 / Notes
|
|
|
|
- 저자 Ryosuke Hasebe 는 LINE Yahoo (Japan) 의 Principal SWE / Senior EM — 대형 Java 서비스 운영 경험 있음.
|
|
- Kotlin 코드 예시이나 Java 에서도 동일한 Micrometer API 를 사용.
|
|
- ScopedValue 언급 없음 — 이 아티클은 현행 ThreadLocal + Micrometer 패턴에 집중.
|