> ## Documentation Index
> Fetch the complete documentation index at: https://www.botgauge.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Trace Graph

> See every step your AI agent took to answer one message in BotGauge: model calls, tools, timing, and failures. Learn what your app must send to draw it.

The Trace Graph shows every step your AI agent took to answer one message. You can see which model calls it made, which tools it used, how long each step took, and where something failed. In the console it opens from the **Graph view** tab.

<video src="https://mintcdn.com/botguage/ieyhanX4ZD11axgg/videos/graph-view.mp4?fit=max&auto=format&n=ieyhanX4ZD11axgg&q=85&s=bbc6a6d39bca2494c76bc27547c3aa68" controls />

## What the Trace Graph shows

When someone sends your agent a message, the agent rarely answers in one move. It might ask a model what to do, look something up, charge a card, retry a call that timed out, and then ask the model to write the reply. Each of those moves is a step.

The Trace Graph draws the steps for one message as a diagram. The message sits at the top and its steps hang underneath it. Use it when you want to know:

* What did the agent do for this message?
* Which step was slow?
* Which step failed, and did a retry fix it?
* What did a step receive, and what did it return?

### Step types and colors

| Color | What it is |
| - | - |
| Blue | The message being handled, labeled `turn`. It is always the top box. |
| Teal | A call to a language model, labeled `llm:chat` followed by the model name. |
| Orange | A tool call, a lookup, or a named step that groups several tool calls, such as `reschedule_with_retry`. |
| Pink | An agent, or a hand-off between agents. The sample project used in these screenshots has none. |

## What your app needs to send

The Trace Graph has no setup of its own. It is drawn from the steps, called spans, that your app already reports, so there is no switch to turn on. Four things in each span decide how its box looks.

| Span property | How it affects the graph |
| - | - |
| **Its type** | The type sets the color. Model and embedding calls are teal, agents and hand-offs are pink, and everything else is orange. BotGauge reads the usual markers on a span to work out the type: `botgauge.semantic_kind`, `openinference.span.kind`, `gen_ai.operation.name`, or an attribute only that kind of step carries, such as `gen_ai.request.model` on a model call or `gen_ai.tool.name` on a tool call. A span with none of these is drawn as an orange box. |
| **Its parent** | A span is drawn under the span named as its parent, however deep the nesting goes. A span with no parent, or whose parent was never sent, hangs directly under the turn box. |
| **Its status** | A box shows a red cross only when its span's status is **Error**. A step that failed but was not marked as an error still shows a green tick. |
| **Its start and end time** | They give the duration shown in the box. |

**The turn box.** Every trace gets one blue turn box at the top. When a trace has a single top-level span marked `botgauge.turn.root`, which is the span the BotGauge SDK opens for each message, that span becomes the turn and its details appear there. Otherwise the turn box is built from the trace itself and the top-level spans sit under it.

**Sessions.** Traces that carry the same session ID are grouped into one session. A trace without a session ID opens on its own.

> [!TIP]
>
> With the SDK, `tracing.turn(session_id=...)` opens the turn span and adds the session ID for you. See [Manual tracing](https://www.botgauge.com/docs/tracing/manual-tracing.md). If you send spans through a plain OTLP exporter, set the type, parent, status, and times yourself. See [Any OTLP exporter](https://www.botgauge.com/docs/integrations/otlp.md).

> [!NOTE]
>
> **Connect your app.** While a project shows sample data, choose **Back to setup** in the banner at the top of Logs to connect your own app.

## Open the Trace Graph

**1. Go to Logs**

In the left menu, under **Observability**, choose **Logs**. (1 in the screenshot)

**2. Pick a tab**

**Sessions** shows whole conversations, **Traces** shows single messages, and **Spans** shows single steps. (2)

**3. Click any row**

A panel opens on the right. (3)

**4. Choose Graph view**

At the top of the panel, choose **Graph view**. It sits between **Messages** and **Timeline**.

![The Logs page with numbered callouts on the Logs menu item, the Sessions, Traces, and Spans tabs, and a session row](https://mintcdn.com/botguage/ieyhanX4ZD11axgg/images/observability/graph-logs-list.jpg?fit=max\&auto=format\&n=ieyhanX4ZD11axgg\&q=85\&s=b12f5a65f1759b717103cd8095a8087c)

The Logs page. Select a row to open it.

Whichever tab you start from, the graph shows the traces of that session, one at a time. If your project has no data yet, Logs shows sample data like the screenshots here. Choose **Back to setup** in the banner to connect your own app.

## Read the graph

The graph belongs to one trace. The top box is the message, and the boxes below it are the steps the agent took for that message.

![The Graph view with numbered callouts on the tab, the message box, a model call, a tool call, a connector, the trace switcher, zoom buttons, Fit View, and the minimap](https://mintcdn.com/botguage/ieyhanX4ZD11axgg/images/observability/graph-overview.jpg?fit=max\&auto=format\&n=ieyhanX4ZD11axgg\&q=85\&s=254c3e970e1629e6e36f966eca6b2a47)

The booking trace in Graph view.

1. **Graph view tab.** Switches the panel from Messages or Timeline to the graph.
2. **The message.** The top box is the trace. Its time is the total for the whole reply.
3. **A model call.** Teal. The name includes the model that was called.
4. **A tool call.** Orange. The name is the tool the agent used.
5. **Connector.** A line from a step down to the steps it started. The step above is the parent, the step below is the child.
6. **Trace switcher.** "Trace: 2 of 5" shows where you are in the session. Use the arrows to move to another trace. The arrows at the top right of the panel, beside the latency and cost labels, do something different: they move to the next row of the list you opened the panel from, such as "Session: 1 of 4".
7. **Zoom.** The plus button zooms in and the minus button zooms out.
8. **Fit View.** The button with four corner marks. It re-centers the whole graph so every step is in view. Hover over it to see its name.
9. **Minimap.** A small map of the whole graph. Its colored bars match the step colors.

### Anatomy of a box

![A single tool box with numbered callouts on the icon, the name, the status tick, and the duration](https://mintcdn.com/botguage/ieyhanX4ZD11axgg/images/observability/graph-node-anatomy.jpg?fit=max\&auto=format\&n=ieyhanX4ZD11axgg\&q=85\&s=948f3c0f5ab4ec607c175cf9ac13fd09)

One box, enlarged.

1. **Icon.** The type of step. It matches the color table above.
2. **Name.** What the step is called.
3. **Status.** A green tick means the step finished. A red cross means it failed.
4. **Duration.** How long the step took, in seconds, beside a small clock.

> [!NOTE]
>
> **Order of steps.** Boxes under the same parent are laid out from left to right in the order they started. In the screenshot above, the first model call is the left-most teal box, then `hold_fare`, `charge_card`, and `confirm_booking`. The final model call, which writes the reply, is the right-most box.
>
> The [Timeline tab](https://www.botgauge.com/docs/observability/timeline-tab.md) shows the same order from top to bottom, with a bar for how long each step took. Each step's **Created At** time in its details shows when it started.

## Look inside a step

Click any box. It gets a colored outline, the line back up to the message takes the step's color, and a panel opens on the right with everything the step received and returned.

The panel shows the step's input and output, how long it took, what it cost, and its other details. The [Messages tab](https://www.botgauge.com/docs/observability/messages-tab.md#look-inside-a-step) explains every part of it, with screenshots of a turn, a model call, and a tool call. It is the same panel in both places.

> [!TIP]
>
> Opening the panel makes the graph area narrower. Press the button with four corner marks, at the bottom left of the graph, to bring the whole graph back into view. Hover over it to see its name, **Fit View**.

## Find what went wrong

**1. Look for a red cross**

A red cross on a box means that step failed.

**2. Click the box**

The **Response** shows the error the step returned.

**3. Look at the box above it**

If the agent retried, the step above can still be green.

**4. Read the attempts from left to right**

They are in the order they ran. The failed attempt is on the left and the retry is on its right.

![The Graph view for a retry, with callouts on the grouping step, the failed attempt, the retry, and the error in the Response](https://mintcdn.com/botguage/ieyhanX4ZD11axgg/images/observability/graph-failed-step.jpg?fit=max\&auto=format\&n=ieyhanX4ZD11axgg\&q=85\&s=398ed1ec87645f75fd933d78ff6bd915)

A clinic assistant rescheduling an appointment. Session 4, trace 2 in the sample project.

1. **The grouping step.** `reschedule_with_retry` holds both attempts. It finished normally, so it is green.
2. **The failed attempt.** On the left, with a red cross and 1.5 seconds. The calendar service did not answer in time.
3. **The retry.** On the right, with a green tick and 0.35 seconds. The second call worked.
4. **The error.** The Response gives the code `CALENDAR_TIMEOUT`, the message, and `retryable: true`.

In this trace the agent recovered and the message was still answered. The graph keeps the failed attempt, so you can see which service is slow or unreliable before it causes a conversation to fail. The Timeline shows [the same retry as bars](https://www.botgauge.com/docs/observability/timeline-tab.md#follow-a-retry).

The sample project has two more failures. In the Shop Support session, trace 4, a payments call fails. In the IT Helpdesk session, trace 4, a model call fails.

Open the Trace Graph in the consoleGo to [BotGauge](https://cloud.botgauge.com), open a session in Observability, Logs, and choose Graph view.

[Try BotGauge →](https://cloud.botgauge.com)

## Common questions

> [accordion] Does a red cross mean the user got an error?
>
> Not always. A red cross marks one step that failed, not the whole message. In the retry example above, the first call failed, the second one worked, and the user still got an answer. To check how the message ended, look at the blue turn box at the top of the graph. A green tick there means the message itself was not marked as failed. To see what the user actually received, open the [Messages tab](https://www.botgauge.com/docs/observability/messages-tab.md) and read the reply.

> [accordion] The graph looks small after I open a step. Why?
>
> The details panel takes about half the width, so the graph area shrinks. Press the button with four corner marks at the bottom left of the graph to re-center it. Hover over it to see its name, **Fit View**.

> [accordion] Can I move the boxes?
>
> No. The graph places every box, and a single box does not move when you drag it. You can still move the whole graph by dragging the empty background, and you can zoom by scrolling over it. Click a box to open its details.

> [accordion] Why do I see one trace and not the whole conversation?
>
> The graph shows one message at a time. A trace is one user message and the agent's reply, and a session can hold several of them. Use the arrows next to "Trace: 2 of 5" to move between them. To read the whole conversation in one place, open the Messages tab. To see every trace in the session on one time ruler, open [Timeline](https://www.botgauge.com/docs/observability/timeline-tab.md).

> [accordion] How do I zoom and move around the graph?
>
> Scroll over the graph to zoom, and drag the empty background to move it. The plus and minus buttons at the bottom left also zoom. You can drag inside the small map at the bottom right to move around, and scroll over it to zoom. Press the button with four corner marks to bring the whole graph back into view.

> [accordion] In what order are the boxes?
>
> Boxes under the same parent run from left to right in the order they started, so the first model call is on the left and the last one is on the right. When a step has steps inside it, those are drawn on the row below, also from left to right. The Timeline tab shows the same order from top to bottom.

> [accordion] Where does the graph come from?
>
> It is drawn from the steps, called spans, that your app sends to BotGauge. [What your app needs to send](#what-your-app-needs-to-send) explains what each step should carry. If you see sample data instead, choose **Back to setup** in the banner on the Logs page and connect your app.

The screenshots and the video use the BotGauge sample project, which holds a travel assistant, a shop support agent, an IT helpdesk, and a clinic assistant. The interface can change between releases.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.