Monitor your agents

Send OpenTelemetry traces from your agent to see token usage, tool calls, and latency in the Astro dashboard
View as Markdown

Astro automatically monitors agents that interact with common AI model providers. After deploying an agent on Astro, you can monitor your agents using the insights page. For enhanced observability, Astro provides adapters for common frameworks.

Framework guides

Manually attaching observability

When an adapter isn’t available for your framework of choice, you may manually instrument an agent using standard OpenTelemetry. Every deployed agent container receives these environment variables automatically:

VariablePurpose
OTEL_EXPORTER_OTLP_ENDPOINTOTLP HTTP base URL. Append /v1/traces for the traces signal.
ASTRO_AGENT_NAMEUse as OpenTelemetry service.name.
ASTRO_AGENT_BUILDUse as OpenTelemetry service.version.

OTEL_EXPORTER_OTLP_ENDPOINT is unset during local development. Guard your instrumentation on the variable so the agent runs cleanly in both environments.

Node.js

Install the OpenTelemetry SDK and the OTLP HTTP trace exporter:

$bun add @opentelemetry/sdk-node @opentelemetry/exporter-trace-otlp-http @opentelemetry/resources @opentelemetry/semantic-conventions

Initialize the SDK at the entry point of your agent, before any other imports that you want traced:

1import { NodeSDK } from "@opentelemetry/sdk-node";
2import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
3import { resourceFromAttributes } from "@opentelemetry/resources";
4import {
5 ATTR_SERVICE_NAME,
6 ATTR_SERVICE_VERSION,
7} from "@opentelemetry/semantic-conventions";
8
9if (process.env.OTEL_EXPORTER_OTLP_ENDPOINT) {
10 new NodeSDK({
11 resource: resourceFromAttributes({
12 [ATTR_SERVICE_NAME]: process.env.ASTRO_AGENT_NAME ?? "agent",
13 [ATTR_SERVICE_VERSION]: process.env.ASTRO_AGENT_BUILD ?? "dev",
14 }),
15 traceExporter: new OTLPTraceExporter({
16 url: `${process.env.OTEL_EXPORTER_OTLP_ENDPOINT}/v1/traces`,
17 }),
18 }).start();
19}

With the SDK running, emit spans wherever you want them — see the OpenTelemetry tracing API for the span API and the auto-instrumentation packages for HTTP, fetch, and other off-the-shelf coverage.