AlgoViz

OpenTelemetry

medium 30 min

OpenTelemetry 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

Our systemUserShop servicetrace 0af7Stock serviceCollector

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

Our systemOTLPServicesversion 1CollectorBackend ABackend Bnot used

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

    critical

    Series multiply, costs grow and the overflow series hides the truth.

    Wrong
    requests.add(1, {"user.id": uid})
    Right
    requests.add(1, {"http.route": route})span.set_attribute("user.id", uid)
  • Tail sampling behind round robin

    critical

    Each Collector sees a part of the trace.

    Wrong
    balancer: round_robin
    Right
    load_balancing:  routing_key: traceID
  • The SDK as a library dependency

    major

    Users are forced into a version and a configuration.

    Wrong
    requires = ["opentelemetry-sdk"]
    Right
    requires = ["opentelemetry-api"]
  • A Collector open to everyone

    major

    Anyone can send data or fill its memory.

    Wrong
    endpoint: 0.0.0.0:4317
    Right
    endpoint: localhost:4317# or a private address with TLS and auth
  • No flush at the end

    minor

    A short job ends before its batch is sent.

    Wrong
    main()
    Right
    main()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.