AI-ENGINEERING
    advanced

    LLM Observability (OTEL / Langfuse)

    AI Engineer path · lesson 94 of 124
    The idea
    An observability tool for LLMs is a plane's black box. When something goes wrong you don't want to re-fly the flight — you want to open the recorder, read what the pilot said, which button they pressed, and what each instrument reported at that moment.
    How to use
    Click a trace to open its span tree. Every generation carries model, tokens, and cost — hover a span for detail.
    trace t1 · "Refund window for digital goods?"
    0ms460ms920ms1380ms1840ms
    Parse query
    Embed query
    Vector search
    Assemble context
    LLM call
    Generation span

    The same generation as span g1 in the Trace hierarchy tab — by far the largest slice of the timeline.

    gen_ai.request.model
    claude-3.5-sonnet
    gen_ai.usage.input_tokens
    2100
    gen_ai.usage.output_tokens
    140
    cost
    $0.0031
    starts at 320ms · lasts 1520ms · 83% of trace
    1840ms
    trace duration
    5
    spans
    LLM call
    slowest span

    Key insight

    A span is nothing more than a name, a start time, and a duration — attributes and a parent link are optional extras. Lay every span in a trace out by its start time and you get a waterfall: the same view Datadog, Langfuse, and Jaeger use to show exactly where a request's time went. Notice the small gaps between bars, too — that's real time (network hops, queueing) that no span covers. Click "Simulate slow vector DB" to watch a bottleneck appear.

    Nest a trace correctly

    Sequence

    Order these from the outermost span to the innermost.

    Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.

    1. 1Drop a step here
    2. 2Drop a step here
    3. 3Drop a step here
    4. 4Drop a step here
    4 pieces left to place

    Test your knowledge

    23 questions
    Question 1 of 23
    Score: 0

    In the standard trace hierarchy, what nests inside what?

    The short version

    An observability tool for LLMs is a plane's black box. When something goes wrong you don't want to re-fly the flight — you want to open the recorder, read what the pilot said, which button they pressed, and what each instrument reported at that moment.

    In more depth

    LLM observability

    An LLM observability stack (Langfuse, Arize, Helicone, Datadog LLM Observability, or a homegrown OTEL setup) records every layer of what your product actually did in production.

    Anatomy of a span

    A span is the atomic unit of a trace: a name, a start time, and a duration, plus optional attributes (model, tokens, cost, error) and a link to its parent span. A single RAG request is really several spans back to back — parse the query, embed it, search a vector DB, assemble context, call the model — each with its own timing. Lay those spans out on a time axis by their start offset and you get a waterfall: the same trace-viewer layout every observability tool (Datadog, Langfuse, Jaeger) uses, because it makes a bottleneck visually obvious — one span balloons, and everything after it visibly shifts right.

    The trace hierarchy

    Session — a user's full conversation or multi-turn interaction.
    Trace — one user turn or one product action.
    Span — a step inside the trace: retrieval, tool call, agent iteration, sub-agent.
    Generation — an LLM call. Tagged with model, prompt, completion, prompt/completion tokens, cost, temperature.

    OTEL GenAI semantic conventions

    Standardized attribute names — gen_ai.request.model, gen_ai.request.temperature, gen_ai.usage.input_tokens, gen_ai.response.finish_reasons, session.id, user.id — so instrumenting once works with every OTEL-compatible backend.

    Above the traces

    User feedback (thumbs, ratings) attached to sessions or traces.
    Automatic evals (LLM-as-judge, structural checks) attached as trace-level attributes.
    Prompt versions — emit content hash so you can correlate a regression with a rollout.

    Below the traces

    PII redaction at the SDK boundary before export.
    Tail-based sampling by traffic slice — keep 100% of failures, evals-below-threshold, thumbs-down sessions; downsample the rest.
    Short retention on raw prompts/completions, longer on aggregated metrics.

    Interview Questions

    Anthropic
    Datadog
    Langfuse
    Langfuse
    Datadog
    CNCF
    Datadog
    Grafana
    Datadog
    Langfuse
    Google
    Datadog

    Love this visualization?

    Sign up to track your progress, earn achievements, use the AI assistant, and access your personal learning dashboard.

    100% free • No credit card required