Skip to content

[FAQ] What is the difference between a trace and a span in OpenTelemetry? #334

Description

@yazdanparasthesam

Question

In Module 5 (Monitoring), we use OpenTelemetry to instrument our RAG system. I see the terms "trace" and "span" used throughout the lesson. What exactly is the difference between them?

Answer

From the OpenTelemetry setup in the Module 5 homework:

  • A trace is the end‑to‑end story of a single request as it moves through your system. For our RAG system, one trace corresponds to one RAG call (a user question going through search, prompt building, and LLM generation).

  • A span is one operation within a trace. A trace is made of one or more spans, organized as a tree. Each span has a name, a start time, an end time, and a set of attributes (key‑value pairs) that record metadata like tokens used or cost.

In our homework, we create one span for each RAG step: rag (the parent), search, and llm (its children). This allows us to see the timing and attributes of each step individually, while still understanding the overall request context.

Source: Module 5 – Monitoring, section "OpenTelemetry" in the homework instructions.

Course

LLM Zoomcamp

Module

05 – Monitoring

Related Links

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions