How a trace is structured
A single agent execution produces a tree of spans. The root span represents one request/session execution, and everything inside that execution (LLM calls, tool runs, retrieval, business logic) appears as child spans.request span
trace root
trace ID · timing · metadata
gen_ai.chat
prompt · completion · tokens
tool.lookup-order
input · output
gen_ai.chat
second LLM call
gen_ai.chat spans; app/tool instrumentation creates operational child spans. Lemma ingests this hierarchy and preserves parent/child relationships.
Traces
A trace represents a single execution of your agent from start to finish. It captures:- Inputs — The initial state and parameters passed to your agent
- Outputs — The final result produced by your agent
- Spans — Nested operations within the execution (LLM calls, tool invocations, etc.)
- Timing — Duration and timing of each operation
- Metadata — Additional context like model names, token counts, and error states
Thread identifier
To link multi-turn conversations, includelemma.thread_id on related spans. This is the canonical thread identifier in Lemma.
You can also include framework-native session fields, but lemma.thread_id should be the source of truth for thread grouping in Lemma.
Spans
Spans are the building blocks of a trace. Each span represents a single operation within your agent’s execution, such as:- An LLM generation call
- A tool or function invocation
- A database query
- A custom operation you want to track
- Which operations happened in what order
- How long each operation took
- Where errors occurred in the execution path
Projects
A project is the top-level container in Lemma. It groups:- All traces from your agent(s)
- A project ID — Used when sending traces and making API calls
- An API key — For authentication
- A dashboard for viewing and analyzing data
Tracer Provider
The tracer provider is the OpenTelemetry component responsible for:- Creating and managing spans
- Exporting trace data to Lemma’s OTLP endpoint
- Handling batching and retries
LangfuseSpanProcessor and give it an OpenTelemetry exporter that targets Lemma. If your app already emits OpenTelemetry-compatible spans, keep that instrumentation and add Lemma as an OpenTelemetry export destination.
Next Steps
Now that you understand Lemma’s core concepts:- Explore Tracing to start sending traces
- Start with Langfuse integration for implementation

