Skip to navigation

Mastra

Automatically instrument Mastra agents for monitoring in Astropods
View as Markdown

Instrument a Mastra agent so its model calls, tool calls, and agent steps appear in the Astropods dashboard. The @astropods/adapter-mastra package — the same one that connects a Mastra agent to Astropods messaging — auto-wires OpenTelemetry tracing when OTEL_EXPORTER_OTLP_ENDPOINT is set on the deployed container.

Before you start

  • A deployable Astropods agent project built with Mastra.
  • Astropods sets OTEL_EXPORTER_OTLP_ENDPOINT only on deployed containers, so traces appear once the agent runs on the platform — not during local development.

Set up

1

Install the adapter

bun add @astropods/adapter-mastra
2

Serve the agent

import { Agent } from "@mastra/core/agent";
import { serve } from "@astropods/adapter-mastra";
const agent = new Agent({
name: "My Agent",
model: "anthropic/claude-sonnet-4-6",
instructions: "You are a helpful assistant.",
});
serve(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, and the platform-injected OTEL_EXPORTER_OTLP_ENDPOINT is used for export.

If your project constructs its own Mastra instance (for example, for multi-agent workflows), serve() registers Astropods observability alongside any existing observability instances on that Mastra.

Traces capture each turn’s model calls, tool calls, and agent steps, attributed to the deployed agent.

3

Verify

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

Troubleshooting

If nothing shows up:

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