# Send traces from Google ADK

Turn on Google ADK's own OpenTelemetry tracing in Python or TypeScript and send every agent invocation to Amiril, with each tool call's arguments and result.

Google ADK records each invocation as OpenTelemetry spans, but it sends them nowhere until you give it an exporter.

## Install [#install]

```bash tab="Python"
pip install "google-adk[otel]"
```

```bash tab="TypeScript"
npm install @opentelemetry/api @opentelemetry/context-async-hooks @opentelemetry/sdk-trace @opentelemetry/exporter-trace-otlp-proto
```

## Turn on trace export [#turn-on-trace-export]

Run these lines once when your agent starts, before it takes its first request.

```py tab="Python" title="tracing.py"
from google.adk.telemetry.setup import maybe_set_otel_providers

maybe_set_otel_providers()
```

```ts tab="TypeScript" title="tracing.ts"
import { context, trace } from "@opentelemetry/api";
import { AsyncLocalStorageContextManager } from "@opentelemetry/context-async-hooks";
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-proto";
import { BatchSpanProcessor, TracerProvider } from "@opentelemetry/sdk-trace";

// A script must call `await provider.shutdown()` before it exits, or its last spans are lost.
export const provider = new TracerProvider({
  spanProcessors: [new BatchSpanProcessor({ exporter: new OTLPTraceExporter() })],
});
trace.setGlobalTracerProvider(provider);
context.setGlobalContextManager(new AsyncLocalStorageContextManager());
```

## Set the endpoint and key [#set-the-endpoint-and-key]

In Amiril, create an API key and copy the endpoint:

1. Switch to the [environment](/traces/environments-and-keys) your runs belong to, with the menu at the top of the page.
2. Open **Data** and select **Set up a new installation**. It opens a panel that connects an agent to Amiril.
3. In the panel, enter a **Key name** under **Create a new key** and select **Create key**.
4. Copy the key and the **OpenTelemetry traces endpoint**.

Then set these variables where your agent runs:

```bash
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="<OpenTelemetry traces endpoint>"
export OTEL_EXPORTER_OTLP_TRACES_PROTOCOL="http/protobuf"
export OTEL_EXPORTER_OTLP_TRACES_HEADERS="Authorization=Bearer <your API key>"
export OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT="SPAN_ONLY"
```

The last line puts tool arguments, tool results and messages on ADK's spans. Without it Amiril sees which tools ran, but not what they were called with.

## Check that traces arrived [#check-that-traces-arrived]

Run the agent and open **Traces**. Each invocation shows as a run of the agent `name` you gave your ADK agent. Open it to see each tool call with its arguments and result, and each model call.

A new run shows a **Scoring** badge until Amiril has ranked it. If no run appears, [read what the exporter logged](/traces/opentelemetry#check-that-traces-arrived).

## Next steps

- [Find a run and see why it was flagged](https://docs.amiril.ai/monitor/runs.md): Open a run from an issue, the Anomalies page or the Traces page and see why Amiril flagged it. Then review it to teach Amiril which rarity factors are noise.
- [Add Amiril to a Google ADK agent](https://docs.amiril.ai/sdk/google-adk.md): Check every tool call of a Google ADK agent against your rules, in Python or TypeScript. Amiril runs as the first plugin and blocks calls that break a rule.
- [Set up environments and API keys](https://docs.amiril.ai/traces/environments-and-keys.md): Create an environment such as Staging and an API key that sends to it, so test runs stay out of production. Then put the key where each service runs.
- [Send traces from LiveKit Agents](https://docs.amiril.ai/traces/livekit.md): Give LiveKit Agents a tracer provider and send each voice session to Amiril over OpenTelemetry as one run, with every turn and the tool calls made in it.
- [Send traces from LangGraph](https://docs.amiril.ai/traces/langgraph.md): Send each run of a LangGraph agent to Amiril over OpenTelemetry with OpenInference's LangChain instrumentation, in Python or TypeScript.

## More detail

- [Trace attributes Amiril reads](https://docs.amiril.ai/assistant/traces/attributes.md): Every span attribute and Langfuse field Amiril reads, per dialect: what makes a run, tool call or generation, how agent and session are found, the OTLP receiver, and what is ignored.
- [Troubleshooting](https://docs.amiril.ai/assistant/troubleshooting.md): Symptom, cause, how to confirm and fix for common Amiril problems: missing runs, plan limits, wrong agent or environment, rules that never fire or never block, SDK, key, import and MCP failures.
