Mastra

Automatically instrument Mastra agents for monitoring in Astro
View as Markdown

The @astropods/adapter-mastra package — the same one used to connect a Mastra agent to Astro messaging — auto-wires OpenTelemetry tracing when OTEL_EXPORTER_OTLP_ENDPOINT is set in the deployed container. Model calls, tool calls, and agent steps flow into the dashboard automatically.

Install

$bun add @astropods/adapter-mastra

Use

1import { Agent } from "@mastra/core/agent";
2import { serve } from "@astropods/adapter-mastra";
3
4const agent = new Agent({
5 name: "My Agent",
6 model: "anthropic/claude-sonnet-4-5",
7 instructions: "You are a helpful assistant.",
8});
9
10serve(agent);

Calling serve() registers the agent with the messaging service and configures observability in the same step. The agent’s name is sent as the OpenTelemetry service.name; the platform-injected OTEL_EXPORTER_OTLP_ENDPOINT is used for export. No additional configuration is required.

If your project constructs its own Mastra instance (e.g. for multi-agent workflows), serve() registers Astro’s OpenTelemetry observability alongside any existing observability instances on that Mastra.

Verify

Deploy the agent, send it a message, then open the agent’s detail page in the Astro dashboard. Traces appear within ~30 seconds.

If nothing shows up:

  • Confirm OTEL_EXPORTER_OTLP_ENDPOINT is present in the deployed container.
  • Check the agent container logs for OpenTelemetry export errors.