# Send your first trace

Send one run of a payments agent to Amiril over OpenTelemetry, then find it on the Traces page. A short Python script and about five minutes.

In this quickstart you send one run to Amiril and find it on the **Traces** page, with its `issue_payment` tool call. A run is one task an agent carried out from start to finish. A short Python script plays a payments agent and sends the run as an OpenTelemetry trace.

## Before you start [#before-you-start]

- An Amiril workspace at [app.amiril.ai](https://app.amiril.ai). You need the admin role to create an API key.
- Python 3.10 or later.

<Steps>
<Step>
### Create an API key [#create-an-api-key]

In Amiril, open **Data** and select **Set up a new installation**. This opens a panel where you create an API key and find the address to send traces to. The panel connects an agent to your workspace, and your script is that agent. Keep the panel open until the last step.

Under **API key**, choose **Create a new key**. Enter a **Key name** such as `payments-agent` and select **Create key**. Copy the key now, because Amiril shows it only once.
</Step>

<Step>
### Install OpenTelemetry [#install-opentelemetry]

```bash
pip install opentelemetry-sdk opentelemetry-exporter-otlp-proto-http
```
</Step>

<Step>
### Set the environment variables [#set-the-environment-variables]

The panel lists the **OpenTelemetry traces endpoint** under **Endpoints**. Export it and your key in the terminal you will run the script from:

```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>"
```

Keep the quotes, because the header value has a space in it.
</Step>

<Step>
### Send a trace [#send-a-trace]

Save this as `first_trace.py`:

```py title="first_trace.py"
import json

from opentelemetry import trace
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor

# The exporter reads the endpoint and the API key from the OTEL_ variables.
provider = TracerProvider(resource=Resource.create({"service.name": "payments-agent"}))
provider.add_span_processor(BatchSpanProcessor(OTLPSpanExporter()))
trace.set_tracer_provider(provider)
tracer = trace.get_tracer("payments-agent")

# One run of the payments agent: a root span with one tool call inside it.
with tracer.start_as_current_span("invoke_agent payments") as run:
    run.set_attribute("gen_ai.operation.name", "invoke_agent")
    run.set_attribute("gen_ai.agent.name", "payments")
    with tracer.start_as_current_span("execute_tool issue_payment") as call:
        call.set_attribute("gen_ai.operation.name", "execute_tool")
        call.set_attribute("gen_ai.tool.name", "issue_payment")
        call.set_attribute("gen_ai.tool.call.arguments", json.dumps({"amount": 120, "currency": "EUR"}))
        call.set_attribute("gen_ai.tool.call.result", json.dumps({"status": "sent"}))

# Send the spans before the script exits.
provider.shutdown()
```

Then run it:

```bash
python first_trace.py
```

It prints nothing when the export works. If the trace cannot be delivered, the exporter logs the error.
</Step>

<Step>
### Find the run [#find-the-run]

Back in the panel, **First data** changes to "A trace arrived. Data is reaching this workspace." If it still says it is waiting, check the endpoint and the key you exported. Then select **Done** to close the panel.

Open **Traces**, the page that lists every run. Your run shows there with a **Scoring** badge at first, and scoring usually takes under two minutes. Scoring gives the run a **rarity**, which says how unusual it is next to the agent's earlier runs. This is the agent's first run, so it has nothing to compare with yet and nothing stands out.

Open the run to see the `issue_payment` call and its arguments.
</Step>
</Steps>

To send runs from your own agent, follow [Send traces to Amiril](/traces).

## Next steps

- [Send traces to Amiril](https://docs.amiril.ai/traces.md): Send your agents' traces to Amiril live over OpenTelemetry, from your framework or any OpenTelemetry SDK, or upload a file exported from Langfuse.
- [Monitor your agents in production](https://docs.amiril.ai/monitor.md): Amiril ranks every run your agents make by how unusual it is for that agent. It groups the runs that share a problem into one issue to triage.
- [Register and manage agents](https://docs.amiril.ai/agents.md): Amiril lists every agent it finds in your traces. Register one with a display name so it can have owners, tool grants and a gateway token.
- [Block your first tool call](https://docs.amiril.ai/quickstart/rules.md): Run a rule that caps payments, then watch the Amiril SDK block a tool call on your laptop. You need no account and no API key to try it.

## 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.
- [Limits and defaults](https://docs.amiril.ai/assistant/limits.md): Every limit and default a customer can hit in Amiril, with its number: plan amounts, ingest sizes and rates, imports, rules, backtests, API and MCP rates, page sizes, retention, name lengths.
- [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.
