---
type: concept
x-llmwiki:
  schemaVersion: "0.1"
  contentHash: 46f0e70115afbe1e499f035bff4540518ae57045c6087cbfeb9774af543a03d3
  pageDirectory: concepts
  sources:
    - get-started-mlflow-tracing-for-genai-in-a-local-ide-databricks-on-aws.md
  confidence: 0.95
  provenanceState: extracted
  freshnessStatus: unverified
  aliases:
    - trace-spans-root-and-child
    - Child) and Trace Spans (Root
    - TS(AC
  citations:
    - file: get-started-mlflow-tracing-for-genai-in-a-local-ide-databricks-on-aws.md
title: Trace Spans (Root and Child)
description: The hierarchical span structure in MLflow Tracing where a root span captures the top-level function call (e.g., app entry point) and child spans capture sub-operations (e.g., individual LLM API calls), forming a tree of execution.
tags:
  - mlflow
  - tracing
  - spans
  - hierarchy
timestamp: "2026-06-19T18:59:37.990Z"
---

# Trace Spans (Root and Child)

**Trace Spans** represent the fundamental units of work within a single [[MLflow Trace]]. A trace is composed of multiple spans organized in a parent-child hierarchy, where each span captures a specific operation, its inputs and outputs, timing information, and associated metadata. The two primary span types are **root spans** and **child spans**. ^[get-started-mlflow-tracing-for-genai-in-a-local-ide-databricks-on-aws.md]

## Structure

A trace's span hierarchy follows a tree structure, with a single root span at the top and one or more child spans beneath it. Each span records:

- **Inputs:** The data passed into the operation.
- **Outputs:** The result returned by the operation.
- **Attributes:** Metadata such as model name, token counts, and timing information.
- **Hierarchy:** The parent-child relationship that links spans together.

^[get-started-mlflow-tracing-for-genai-in-a-local-ide-databricks-on-aws.md]

### Root Span

The root span represents the entry point of the traced application. It captures the highest-level operation, such as a function decorated with `@mlflow.trace`. For example, in a GenAI application, the root span records the input prompt provided by the user and the final response generated by the application. ^[get-started-mlflow-tracing-for-genai-in-a-local-ide-databricks-on-aws.md]

### Child Span

Child spans represent sub-operations that occur within the scope of a parent span. They provide granular visibility into the steps that comprise the overall workflow. For instance, a child span might capture a specific OpenAI completion request made inside the root function, including the exact request parameters and response details. ^[get-started-mlflow-tracing-for-genai-in-a-local-ide-databricks-on-aws.md]

## Example

When a function decorated with `@mlflow.trace` makes an OpenAI API call that is automatically instrumented by `mlflow.openai.autolog()`, the resulting trace shows:

- **Root span:** Represents the inputs to the decorated function (e.g., the user's question) and the final output (e.g., the assistant's answer).
- **Child span:** Represents the OpenAI completion request, including the model name, messages sent, token counts, and response time.

^[get-started-mlflow-tracing-for-genai-in-a-local-ide-databricks-on-aws.md]

## Visibility Provided

Even a minimal root-child span pair surfaces useful information about application behavior, including:

- What was asked (root span inputs)
- What response was generated (root span outputs)
- How long the overall request took (root span timing)
- How many tokens were consumed, affecting cost (child span attributes)
- Timing and details of sub-calls (child span timing and attributes)

For more complex applications like [Retrieval Augmented Generation (RAG)](/concepts/retrieval-augmented-generation-rag.md) systems or multi-step agents, the root-child span hierarchy provides even more value by revealing the inner workings of each component and step. ^[get-started-mlflow-tracing-for-genai-in-a-local-ide-databricks-on-aws.md]

## Related Concepts

- [MLflow Tracing](/concepts/mlflow-tracing.md) — GenAI observability framework for instrumenting applications.
- [[MLflow Trace]] — The complete record of a traced execution, containing one or more spans.
- [Automatic Tracing](/concepts/automatic-tracing.md) — Using `mlflow.openai.autolog()` to instrument library calls.
- [Manual Tracing](/concepts/manual-tracing.md) — Using the `@mlflow.trace` decorator to instrument custom functions.
- Trace Attributes — Metadata captured on spans, such as model name and token counts.

## Sources

- get-started-mlflow-tracing-for-genai-in-a-local-ide-databricks-on-aws.md

# Citations

1. [get-started-mlflow-tracing-for-genai-in-a-local-ide-databricks-on-aws.md](/references/get-started-mlflow-tracing-for-genai-in-a-local-ide-databricks-on-aws-58181913.md)
