반응형
이전 글에서 분산 트레이싱 을 확인하기 위해 OpenTelemetry, Tempo 를 사용해서 구성을 했었습니다.
그런데 샘플링 비율을 10%로 설정을 해서 Trace
를 확인하다 보니, 실제로 제가 원하는 Trace
가 보이질 않아서 방법을 찾아보았더니,
OpenTelemetry-Collector 에서 원하는 정보는 무조건 Trace
가 찍히도록 하는게 있어서 적용 해보았습니다.
이제 실제로 제가 했던 적용 했던 내용을 설명드리겠습니다.
원하는 Trace 조건
저 같은 경우, 아래와 같은 경우 무조건 Trace가 찍히도록 설정하였습니다.
- ERROR
- 400, 500 번대 ERROR 발생
- 11초 이상 걸린 작업
개발자의 도움 없이 분산 Trace 추적:OpenTelemetry Auto-Instrumentation과 Tempo 활용법
이전 글에서 OpenTelemetry-Collector 를 helm
으로 설치를 했었습니다.
그래서, 관련 설정은 values.yaml
파일에 존재합니다.
이 values.yaml
파일의 내용을 수정하여 원하는 Trace
를 확인할 수 있도록 해보겠습니다.
- values.yaml 내용 수정 (수정한 부분만 추가)
config:
exporters:
otlp:
compression: gzip # 네트워크/CPU 절감
processors:
memory_limiter: # Collector의 메모리 사용량을 제한하는 프로세서
check_interval: 5s # 5초 마다 Collector의 메모리 사용량 측정
limit_percentage: 80 # Pod limit.memory의 80%를 넘으면 스팬 수집 중단
spike_limit_percentage: 25 # 순간 급등 (spike) 시 Pod limit.memory의 25%를 넘으면 스팬 수집 중단
tail_sampling: # Trace가 끝난 후, 조건을 보고 샘플링 결정 가능
decision_wait: 50s # Trace 종료까지 최대 50초 기다림
expected_new_traces_per_sec: 500 # 초당 새 Trace 예상치
num_traces: 20000 # Collector가 수집할 Trace의 최대 개수 (메모리 사용량과 직결)
policies: # 샘플링 정책
# Span 중 하나라도 status=ERROR가 있으면 무조건 채택
- name: status-error
type: status_code
status_code:
status_codes: [ERROR]
# http.status_code가 500~599인 경우 무조건 채택 (HTTP 서버 에러 전부 수집)
- name: http-5xx
type: numeric_attribute
numeric_attribute:
key: http.status_code
min_value: 500
max_value: 599
# http.status_code가 400~499인 경우 무조건 채택 (HTTP 서버 에러 전부 수집)
- name: http-4xx
type: numeric_attribute
numeric_attribute:
key: http.status_code
min_value: 400
max_value: 499
# 요청 처리 시간이 11000ms(11초)를 초과하면 무조건 채택 (성능 문제 파악용)
- name: slow
type: latency
latency:
threshold_ms: 11000 # 11초
# 위 조건에 걸리지 않은 정상 요청은 0% 샘플링
- name: normal-prob
type: probabilistic
probabilistic:
sampling_percentage: 0.0
receivers:
extensions:
- health_check
pipelines:
traces:
processors: # 프로세스 순서 중요, memory_limiter -> tail_sampling -> batch
- memory_limiter
- tail_sampling
- batch
이렇게 하면 샘플링 비율을 높이지 않아도 OpenTelemetry-collector, Tempo 에 부하가 많이 없는 상태에서 원하는 Trace
를 볼 수 있어서 볼 수 있습니다.
이상 입니다.
반응형
'Monitoring' 카테고리의 다른 글
개발자의 도움 필요 없이 분산 Trace 추적: OpenTelemetry Auto-Instrumentation과 Tempo 활용법 (1) | 2025.08.21 |
---|---|
Alertmanager <-> Googlechat 으로 알람 보내기 (0) | 2025.08.11 |
Istio ingressgateway 와 ALB 연결 (0) | 2025.07.24 |
Istio, Kiali 설치 및 Prometheus, Grafana 연결 (Using Helm) (3) | 2025.07.24 |
트래픽 조절하면서 Canary 배포 해보기 (used by Istio) (3) | 2025.07.24 |