Jaeger
Jaeger
A distributed tracing system. Developed by Uber. Microservice debugging.
Jaeger
A distributed tracing system. Developed by Uber. Microservice debugging.
Jaeger is an open-source distributed tracing system developed by Uber. When a request in a microservices environment is processed across multiple services, it tracks the processing time at each service and the call relationships. It implements the OpenTracing standard and is currently a CNCF graduated project.
The core concepts of distributed tracing are Trace and Span. An entire request is a Trace, and the unit of processing at each service is a Span. Spans are connected in parent-child relationships to form a call graph. Jaeger UI visualizes this as a timeline, so you can identify bottlenecks at a glance.
The Jaeger architecture consists of Agent, Collector, Query, and Storage. The Agent collects Spans over UDP on each host, and the Collector processes them and stores them in Storage (Cassandra, Elasticsearch, Kafka, etc.). The Query service searches the stored traces and serves them to the UI.
In practice, Jaeger gives accurate answers to the question "Why is this API slow?" Because you can prove with trace data where P99 latency spikes, where errors occur in a specific service, and which DB queries are unnecessary, it is essential for performance optimization and incident analysis.
# Python Flask + OpenTelemetry로 Jaeger 연동
from flask import Flask
from opentelemetry import trace
from opentelemetry.exporter.jaeger.thrift import JaegerExporter
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.instrumentation.flask import FlaskInstrumentor
from opentelemetry.instrumentation.requests import RequestsInstrumentor
# Tracer 설정
trace.set_tracer_provider(TracerProvider())
tracer = trace.get_tracer(__name__)
# Jaeger Exporter 설정
jaeger_exporter = JaegerExporter(
agent_host_name="jaeger-agent.observability.svc",
agent_port=6831,
)
# BatchSpanProcessor로 효율적인 전송
trace.get_tracer_provider().add_span_processor(
BatchSpanProcessor(jaeger_exporter)
)
app = Flask(__name__)
# 자동 계측
FlaskInstrumentor().instrument_app(app)
RequestsInstrumentor().instrument()
@app.route("/order/")
def get_order(order_id):
# 커스텀 Span 생성
with tracer.start_as_current_span("fetch_order_details") as span:
span.set_attribute("order.id", order_id)
# 다른 서비스 호출 (자동으로 trace context 전파)
order = fetch_from_order_service(order_id)
with tracer.start_as_current_span("enrich_with_user_data"):
user = fetch_user_info(order["user_id"])
order["user"] = user
return order
SRE: "The order API's P99 latency spiked to 2 seconds last night. Did you check the sampled traces in Jaeger?"
Developer: "Yes, I checked. The segment waiting for a DB connection in the inventory service was taking as long as 1.5 seconds."
SRE: "Looks like we need to increase the connection pool size. If you share the trace ID, I'll attach it to the incident report."
Interviewer: "Why is Trace Context propagation important in distributed tracing?"
Candidate: "To link a request that passes through multiple services into a single Trace, the Trace ID must be passed between services. It is propagated via HTTP headers (traceparent) or gRPC metadata, and if this is broken, the trace is split and the overall flow cannot be understood."
Take a mock interview on this topic → WIA SOOM AI Interview · Start for free
Reviewer: "The Span is getting broken in this asynchronous task. You need to pass the context explicitly instead of using start_as_current_span."
Developer: "Ah, that's because it's a Celery task. I'll pass trace_context as a task parameter and attach it on the receiving side."