Jaeger
medium 28 minJaeger is an open-source store and viewer for distributed traces.
See it run
Spans from several services become one timeline. Sampling and buffering decide what it costs.
Operations
One trace
A user places an order. Two services make spans and Jaeger joins them.
Step 1 of 6
New id
The web service sees no traceparent, so it makes a trace id and span A.
Step 1: New id
trace = new_trace_id()with span("POST /order", trace) as a: headers["traceparent"] = (trace, a.id) call_pay(headers)export_later(a)# in paywith span("charge", parent=headers["traceparent"]) as c: charge()export_later(c)- Work
- Export is later
- State
- Spans
Say that spans are exported later, so tracing does not delay the answer.
In the real world
The same jaeger doing real jobs. Pick one and step through it.
One service does not pass the context on.
Step 1 of 3
Web calls pay
A self-written client forgets the traceparent header.
Step 1: Web calls pay
Common mistakes
The bugs interviewers watch for, with the fix beside each.
Memory storage in production
criticalEvery trace is lost on a restart, and without a limit memory grows.
Wrongbackends: main: memory: {}Rightbackends: main: elasticsearch: server_urls: ["https://es1:9200"]Each service samples alone
criticalTraces have holes, because services keep different requests.
Wrongif random() < 0.1: record()RightOTEL_TRACES_SAMPLER=parentbased_traceidratioOTEL_TRACES_SAMPLER_ARG=0.1Rates from sampled traces
majorTail sampling keeps errors on purpose, so the error share looks far too high.
Wrongerror_rate = kept_errors / kept_tracesRight# span metrics first, sampling afterThe interface on the internet
criticalIt has no accounts, and traces contain URLs, queries and ids.
Wrong-p 0.0.0.0:16686:16686Right# only behind a login proxyMore collectors for slow storage
minorThe queues fill a little later, that is all.
Wrongreplicas: 20Right# Kafka, more storage, or fewer spans
Interview tips
How to explain it
- One id for one request.
- Spans form a tree.
- Jaeger stores and draws it.
Reading a trace
- Look at self time.
- Look for staircases and gaps.
- Compare slow with normal.
Reach for it when
- Requests cross many services.
- Only some requests are slow.
- You run OpenSearch or Elasticsearch anyway.
Keep in mind
- Storage is the limit.
- Version 1 has ended.
- No accounts in the interface.