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

> ## Agent Instructions
> These docs moved from docs.flintai.dev to docs.switchagents.ai. Use docs.switchagents.ai for every link and request.
> To search these docs from an AI tool, connect the MCP server at https://docs.switchagents.ai/mcp. The page index is at https://docs.switchagents.ai/llms.txt.
> The source code for these products is public on GitHub. Switch Rooms: https://github.com/sandbox-quantum/switch. Switch Trust CLI: https://github.com/sandbox-quantum/switch-trust-cli. Switch Trust CodeScan action: https://github.com/sandbox-quantum/switch-trust-codescan-action. Switch Trust MCP server: https://github.com/sandbox-quantum/switch-trust-mcp. Switch Trust Python SDK: https://github.com/sandbox-quantum/switch-trust-sdk-py. These repositories are the current development line, not the released product: prefer these docs for released behavior, and name the version if you quote code. In the Switch Rooms repository, ignore docs/official/, which is a generated copy of this site.

# OpenTelemetry

> Send agent sessions, turns, and cost to Switch Trust over OpenTelemetry, with no SDK to install

OpenTelemetry is a telemetry data source. Instead of Switch Trust scanning something you own,
your agent sends Switch Trust its traces as it runs. Switch Trust turns them into the agent's
sessions, turns, and cost. If your agent already uses OpenTelemetry, or you can't add the Switch
Trust SDK to it, you can connect it by setting environment variables, with no code change.

To open this page, go to **Settings**, then **Data sources**, and select **OpenTelemetry**.

> [!NOTE]
>
> Setting up the OpenTelemetry data source requires the **Editor** role or higher. With a lower
> role, the **OpenTelemetry** card can't be selected.

## Supported frameworks

Switch Trust reads traces from the following frameworks:

* **LangChain**, instrumented with [OpenInference](https://github.com/Arize-ai/openinference).
  Install `openinference-instrumentation-langchain` alongside the OpenTelemetry SDK and exporter.
  Switch Trust recognizes LangChain traces by their OpenInference instrumentation, so LangChain
  traces from other instrumentation libraries aren't read.
* **Claude Code**, using its built-in telemetry. There is nothing to install.

## Connect your agent

The **Setup** tab gives you the values to use, with your own endpoint already filled in.

**1. Get your connection details**

You need two values: your OTLP endpoint and a Switch Trust API token.

* **OTLP endpoint.** The **Setup** tab shows the exact URL to use. Copy it from there. It is
  a base URL, ending in `/agent/otel`, and your OpenTelemetry SDK adds the path for each
  signal itself.
* **API token.** Use an existing token, or create one now if you don't have one. Tokens are
  managed under **Settings**, then **API keys**, and the **Setup** tab has a
  **Create one now** shortcut. The token needs the **Editor** role or higher. A **Viewer**
  token is rejected.

**2. Set your environment variables**

On the **Setup** tab, choose your agent's framework under **Framework**. Then set the
variables it shows in your agent's environment before you start the agent. Replace the
following placeholders with your own values:

* `<service>` - A name for the service that runs the agent
* `<agent>` - The agent's name (see [Name your agent](#name-your-agent))
* `<apikey>` - The API token from the first step

**LangChain**

```bash theme={null}
OTEL_METRICS_EXPORTER=none
OTEL_LOGS_EXPORTER=none
OTEL_TRACES_EXPORTER=otlp
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
OTEL_EXPORTER_OTLP_ENDPOINT=<your OTLP endpoint>
OTEL_SERVICE_NAME=<service>
OTEL_RESOURCE_ATTRIBUTES=gen_ai.agent.name=<agent>
OTEL_EXPORTER_OTLP_HEADERS="Authorization=ApiKey <apikey>"
```

**Claude Code**

```bash theme={null}
CLAUDE_CODE_ENABLE_TELEMETRY=1
CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1
OTEL_METRICS_EXPORTER=none
OTEL_LOGS_EXPORTER=otlp
OTEL_TRACES_EXPORTER=otlp
OTEL_LOG_USER_PROMPTS=1
OTEL_LOG_ASSISTANT_RESPONSES=1
OTEL_LOG_TOOL_CONTENT=1
OTEL_LOG_TOOL_DETAILS=1
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
OTEL_EXPORTER_OTLP_ENDPOINT=<your OTLP endpoint>
OTEL_SERVICE_NAME=<service>
OTEL_RESOURCE_ATTRIBUTES=gen_ai.agent.name=<agent>
OTEL_EXPORTER_OTLP_HEADERS="Authorization=ApiKey <apikey>"
```

The `OTEL_LOG_*` variables send the prompt, the response, and tool content to Switch
Trust. Leave them out to send usage only. Switch Trust still records the model, tokens,
timing, and cost of each turn.

> [!TIP]
>
> Already running an OpenTelemetry Collector? Add Switch Trust as an additional OTLP exporter
> in your Collector instead. You don't have to move your existing stack.

**3. Run your agent**

Start your agent as you normally would. Switch Trust starts reading as soon as the first
traces arrive, and you don't need to create the agent in Switch Trust first.

## Name your agent

Switch Trust attributes each trace to an agent, and cost, spend caps, and burn rate are all
tracked per agent. Set the agent's name with `gen_ai.agent.name` in
`OTEL_RESOURCE_ATTRIBUTES`, as the variables above do.

If you also scan the agent's code, use the same name the scan gave the agent, which is the
**Name** on the agent's **Details** card. When the names match, the traces and the scan
results land on one agent. When they don't, Switch Trust lists two agents and splits the
agent's cost and history between them. Set the name before the agent first sends traces,
because Switch Trust can't merge the two agents afterward.

If you don't set `gen_ai.agent.name`, Switch Trust names the agent after the nearest agent in
the trace. For Claude Code, or when the trace doesn't have one, it uses `OTEL_SERVICE_NAME`
instead.

## What you see

Once traces arrive, the agent appears in [Agents](/switch-trust/inventory/agents). Its
sessions appear on its **Sessions** tab and its spending on its cost cards. Each turn also
appears on the [Live](/switch-trust/monitoring/live) page.

Switch Trust prices each model call from [Model pricing](/switch-trust/cost/model-pricing). If
the agent calls a model Switch Trust has no list price for, such as a model served from Hugging
Face, its usage counts as \$0 until you set a price for it.

The OpenTelemetry data source has no **Scans** tab, and its card doesn't show a
**Connected** status. To confirm that traces are arriving, open the agent and check its
**Sessions** tab.

> [!WARNING]
>
> Connect each agent through either OpenTelemetry or the
> [Switch Trust SDK](/switch-trust/getting-started/runtime), not both. An agent that reports
> through both is recorded twice for every call, so its cost is counted twice.

## Next steps

> **[Live traffic](/switch-trust/monitoring/live)**
>
> Watch your agents' turns as they happen

> **[Connect another data source](/switch-trust/admin/data-sources)**
>
> Add a repository or a cloud platform to widen your inventory
