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

# Distributed Tracing

> Correlate LLM calls with your application's internal traces.

When building complex AI applications, a single user action might trigger multiple sequential or parallel LLM calls (e.g. an agentic workflow using LangChain or AutoGen).

MetrixLLM supports passing standard tracing headers to correlate your application's internal traces with the LLM requests logged in the gateway.

## Supported tracing headers

When making a request to the MetrixLLM gateway, you can optionally include the following HTTP headers:

| Header                | Description                                                     | Example                 |
| :-------------------- | :-------------------------------------------------------------- | :---------------------- |
| `metrix-session-id`   | A unique identifier for the entire workflow or user session.    | `session_abc123`        |
| `metrix-parent-id`    | The ID of the parent trace or span that triggered this request. | `span_xyz789`           |
| `metrix-session-name` | A human-readable name for the trace.                            | `Data Extraction Agent` |

## Example usage

<CodeGroup>
  ```python Python theme={null}
  response = client.chat.completions.create(
      model="gpt-4o",
      messages=[{"role": "user", "content": "Extract the dates."}],
      extra_headers={
          "metrix-session-id": current_session_id,
          "metrix-parent-id": current_span_id,
          "metrix-session-name": "Date Extractor"
      }
  )
  ```

  ```bash cURL theme={null}
  curl https://gateway.metrixllm.com/openai/v1/chat/completions \
    -H "Authorization: Bearer mtx_..." \
    -H "metrix-session-id: session_abc123" \
    -H "metrix-parent-id: span_xyz789" \
    -H "metrix-session-name: Data Extraction Agent" \
    -d '{"model": "gpt-4o", "messages": [{"role": "user", "content": "Hello!"}]}'
  ```
</CodeGroup>

## Viewing traces

When these headers are provided, the gateway automatically indexes them.

In the **Request Logs** dashboard, requests sharing the same `metrix-session-id` are grouped together. You can click on a session to view the entire span tree, making it easy to debug multi-step agent workflows and calculate the total cost and latency of a single session.
