OpenTelemetry
medium 30 minOpenTelemetry is an open standard, with libraries and a Collector, for making and moving traces, metrics and logs.
See it run
Context, the Collector, series, tail sampling and queues.
Operations
One trace, two services
A request goes from shop to stock. Watch the header.
Step 1 of 5
Start
No header came in, so shop makes a new trace id.
Step 1: Start
span = tracer.start("GET /order")headers = inject(span) # traceparentcall("stock", headers)# in stockctx = extract(headers)child = tracer.start("reserve", parent=ctx)child.end(); span.end()exporter.send_batch()- Work
- Two header writes
- State
- Active span
Say that the header carries the id and the decision, not the span itself.
In the real world
The same opentelemetry doing real jobs. Pick one and step through it.
Move from A to B without touching a service.
Step 1 of 3
Only A
Services send to the Collector, which sends to A.
Step 1: Only A
Common mistakes
The bugs interviewers watch for, with the fix beside each.
User id on a metric
criticalSeries multiply, costs grow and the overflow series hides the truth.
Wrongrequests.add(1, {"user.id": uid})Rightrequests.add(1, {"http.route": route})span.set_attribute("user.id", uid)Tail sampling behind round robin
criticalEach Collector sees a part of the trace.
Wrongbalancer: round_robinRightload_balancing: routing_key: traceIDThe SDK as a library dependency
majorUsers are forced into a version and a configuration.
Wrongrequires = ["opentelemetry-sdk"]Rightrequires = ["opentelemetry-api"]A Collector open to everyone
majorAnyone can send data or fill its memory.
Wrongendpoint: 0.0.0.0:4317Rightendpoint: localhost:4317# or a private address with TLS and authNo flush at the end
minorA short job ends before its batch is sent.
Wrongmain()Rightmain()provider.shutdown()
Interview tips
How to explain it
- One common plug.
- A box in the middle.
- Any recorder behind it.
Numbers to know
- 4317 and 4318.
- 2,048 spans in the SDK queue.
- 2,000 series, 300 seconds of retries.
Reach for it when
- Many languages or backends.
- You write a library.
- You want to own your data.
Check first
- Status of your language.
- Stability of each component.
- What instrumentation records.