Need more detail? Connect your coding agent to the full docs.

Skip to Content
AMIRILDocs

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

  • An Amiril workspace at app.amiril.ai. You need the admin role to create an API key.
  • Python 3.10 or later.

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.

Install OpenTelemetry

pip install opentelemetry-sdk opentelemetry-exporter-otlp-proto-http

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:

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.

Send a trace

Save this as first_trace.py:

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:

python first_trace.py

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

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.

To send runs from your own agent, follow Send traces to Amiril.

Next steps

Last updated on