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

Skip to Content
AMIRILDocs

Send traces from any OpenTelemetry SDK

Point an OpenTelemetry exporter at Amiril with three standard variables, learn the span attributes Amiril reads and check that your traces arrived.

Amiril is an OpenTelemetry destination. Your agent exports its spans with OpenTelemetry's own SDK, and three standard variables point that exporter at Amiril. You add no Amiril code.

Set the endpoint and key

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

  1. Switch to the environment 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:

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

The OTLP exporter in every OpenTelemetry SDK reads them. Amiril takes OTLP over HTTP as protobuf or JSON, but not over gRPC.

Export spans from your agent

If your agent runs on a framework, its guide lists the instrumentation to install and the lines that turn on export. There are guides for Google ADK, LangGraph, CrewAI and other frameworks.

Otherwise you set up OpenTelemetry yourself. Install the SDK and its OTLP HTTP exporter:

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

When the agent starts, register a tracer provider that sends spans through that exporter. Then write a span for each step. The Python script does both for one payments agent run with one issue_payment call. The TypeScript lines register the provider:

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()

Span attributes Amiril reads

Amiril reads the OpenTelemetry GenAI conventions, OpenInference and OpenLLMetry. Framework instrumentations set these attributes for you. If you write spans yourself, as the script above does, this is what Amiril looks for:

  • One trace per run. Amiril reads the trace's root span as the run and every span under it as a step.
  • The agent's name. Put it in gen_ai.agent.name, on the root span or on an invoke_agent span. Each name you send becomes an agent in Amiril, listed under Unregistered on the Agents page until you register it. A run without one lands under Unattributed.
  • Tool calls. Set gen_ai.operation.name to execute_tool, the tool in gen_ai.tool.name, and its arguments as JSON in gen_ai.tool.call.arguments. The result goes in gen_ai.tool.call.result. Rules and rarity factors read the arguments.
  • Model calls. Set gen_ai.operation.name to chat, with gen_ai.request.model and the token counts in gen_ai.usage.input_tokens and gen_ai.usage.output_tokens.
  • Sessions. When several runs belong to one conversation, put its id in gen_ai.conversation.id.

Check that traces arrived

Run your agent once. While the setup panel is open, First data changes to "A trace arrived. Data is reaching this workspace."

After that, the Connections card on the Data page shows the time of the Last trace received, with a Receiving badge while traces keep coming. The runs show on the Traces page. Each has a Scoring badge until Amiril has ranked it against the agent's other runs.

If nothing arrives, read what your exporter logged. In Python, the exporter logs each failed export with its HTTP status, so a wrong key or endpoint shows up there. In Node.js it stays silent until you set a logger with OpenTelemetry's diag.setLogger.

Next steps

Last updated on