/astropods:wire-astropods-telemetryfrom astropods
Wires up an Astropods adapter on an existing agent to publish OpenTelemetry traces and metrics. For LangChain (Python) and Mastra (TypeScript) agents that already have astropods.yml but no telemetry.
Ships in astropods. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Use this skill when an agent already runs on Astropods (has astropods.yml and a Dockerfile) but is missing the framework adapter that publishes OpenTelemetry traces back to the platform. Without the adapter, the agent works but the platform records no run-level telemetry.
If the project does not yet adopt Astropods at all, start with migrate-to-astropods first, then return here.
Confirm the plan before performing any actions.
astropods.yml exists and the agent builds/runs under ast project start, butagent.invoke(...), mastra.getAgent(...).stream(...), etc.) instead of an Astropods adapter's serve().Supported frameworks today: LangChain (Python) and Mastra (TypeScript). For other frameworks, telemetry must be emitted manually via the OTEL SDK using OTEL_EXPORTER_OTLP_ENDPOINT — see Manual instrumentation. The endpoint is injected in deployed environments only; see the local-dev caveat in step 5. The same applies to a frontend agent that serves its own HTTP surface (interfaces.frontend: true, no messaging sidecar, hence no serve()): its OTEL SDK is the entire telemetry path. For plain Python without LangChain, the framework-agnostic astropods-adapter-core package provides serve()/AgentAdapter directly, and astropods-messaging provides the raw gRPC stubs (requires grpcio>=1.81).
Find the current entry point — the file referenced by CMD in the Dockerfile (e.g. python -m agent.main, bun run agent/index.ts). Confirm which framework constructs the agent:
langchain, langgraph, or langchain_*; uses create_agent, AgentExecutor, or LangGraph.@mastra/core, constructs new Agent({...}) or new Mastra({...}).# Python / LangChain
pip install astropods-adapter-langchain # add to requirements.txt
# TypeScript / Mastra (Bun)
bun add @astropods/adapter-mastra
# TypeScript / Mastra (npm)
npm install @astropods/adapter-mastra
OTEL auto-wiring needs @astropods/adapter-mastra >= 0.2.0 and @mastra/core >= 1.63.0. A fresh install satisfies both, but an agent pinned to an older adapter (0.0.9 has no setupObservability at all) produces no traces even when deployed — check the pinned version before assuming the wiring is at fault.
serve()Replace the existing entry-point invocation with the adapter's serve() call. The agent's construction code stays untouched — tools, prompts, models, memory all keep working.
from astropods_adapter_langchain import LangChainAdapter, serve
# existing agent setup stays untouched
agent = create_agent(llm, tools=tools, system_prompt=system_prompt)
adapter = LangChainAdapter(agent, name="my-agent", system_prompt=system_prompt, tools=tools)
serve(adapter)
Notes:
astream(stream_mode="updates") — responses arrive as complete messages, not token-by-token.options.conversation_id is passed as thread_id automatically — LangGraph memory/checkpointing works across turns.tools passed to LangChainAdapter is only for playground display; actual tool wiring stays in create_agent.For a simple agent:
import { Agent } from '@mastra/core/agent';
import { serve } from '@astropods/adapter-mastra';
const agent = new Agent({
name: 'My Agent',
instructions: 'You are a helpful assistant.',
model: openai('gpt-4o'),
tools: { ... },
});
serve(agent);
For a full Mastra app (new Mastra({...})), pass the agent to serve() and ensure storage is initialized before the Mastra instance is constructed — Mastra queries storage on construction and will race ahead of any lazy init:
import { Mastra } from '@mastra/core/mastra';
import { serve } from '@astropods/adapter-mastra';
// Initialize storage first — Mastra queries it immediately on construction
await storage.init();
export const mastra = new Mastra({ agents: { myAgent }, storage, ... });
serve(myAgent);
Notes:
fullStream — responses stream token-by-token.options.conversationId is passed as the memory thread automatically.OTEL_EXPORTER_OTLP_ENDPOINT is set (injected in deployed environments; see the local-dev caveat in step 5).Dockerfile CMD if neededIf the entry-point filename changed, update the final CMD line to match. If you kept the same filename and only replaced its contents, the Dockerfile does not need changes.
Local-dev caveat (verified on CLI 0.15.10):
ast project startinjectsGRPC_SERVER_ADDRbut does not injectOTEL_EXPORTER_OTLP_ENDPOINT, and the local stack runs no trace collector. Local tracing is therefore a silent no-op — this is expected, not a bug in your wiring. Verify traces on the deployed platform, where the endpoint is provided.
Deploy the agent, send a request through the messaging interface, then check the platform's runs/traces view. You should see a new run with spans for the agent's LLM calls and tool invocations.
From the terminal, ast agent trace --name <agent> lists recent traces and ast agent trace -t <trace-id> shows one in detail — usually a faster loop than the platform UI.
If OTEL_EXPORTER_OTLP_ENDPOINT is unset (local dev, tests, running outside the platform), the adapter falls back to no-op tracing — agent works, telemetry is silently dropped.
For an agent with no first-party adapter (a different framework, raw LLM calls, or a frontend agent that owns its own HTTP surface and never calls serve()), there is nothing to auto-wire tracing — the OTEL SDK is the whole telemetry path.
OTEL_EXPORTER_OTLP_ENDPOINT (the runner injects it; unset locally → no-op). Set service.name from ASTRO_AGENT_NAME and service.version from ASTRO_AGENT_BUILD — both are deploy-only, like the endpoint, so always supply a fallback (process.env.ASTRO_AGENT_NAME ?? "agent", process.env.ASTRO_AGENT_BUILD ?? "dev"). Without one, pointing the endpoint at your own local collector emits traces with undefined service metadata.| Purpose | Span attribute(s) |
|---|---|
| Input | langfuse.observation.input, langfuse.trace.input (also gen_ai.input, input.value) |
| Output | langfuse.observation.output, langfuse.trace.output (also gen_ai.output, output.value) |
| User (filterable) | langfuse.user.id — a stable, non-PII identifier |
| Session (groups a conversation) | langfuse.session.id |
| LLM generation | langfuse.observation.type = "generation" + gen_ai.request.model |
| Token usage | gen_ai.usage.input_tokens, gen_ai.usage.output_tokens |
On a root (or workflow-kind) span, observation-level input/output is promoted to the trace-level fields automatically; otherwise set the langfuse.trace.* keys directly.
langfuse.observation.input/output, langfuse.trace.input/output, gen_ai.prompt/completion/input/output, llm.prompts/completions) become [REDACTED]; usage, model, user, and session are left intact.| Problem | Fix |
|---|---|
| Agent responds but no runs appear in the platform | Confirm the entry point calls serve(...), not the framework's invoke/stream directly. If running locally: expected — ast project start does not inject OTEL_EXPORTER_OTLP_ENDPOINT (see step 5); check the deployed agent instead. |
| Mastra: agent can't connect to postgres after storage init | Storage must be initialized before new Mastra() is constructed — use top-level await on storage.init(). |
| Mastra: traces appear but missing tool spans | Ensure tools are registered on the Agent/Mastra instance, not bound ad-hoc per call — only registered tools are auto-traced. |
| LangChain: streaming feels slow / arrives in chunks | Expected. The LangChain adapter uses astream(stream_mode="updates"), so updates land as complete messages. Switch to per-token streaming requires a custom adapter. |
serve() exits immediately on container start | The runner injects GRPC_SERVER_ADDR only inside ast project start. Outside it, serve() has nothing to bind to. |
| Manual instrumentation: user / input / output blank in a trace | You're setting non-recognized attribute keys. Use the langfuse.* / gen_ai.* keys from Manual instrumentation; anything else lands in raw metadata, not the dedicated fields. |
| Tokens show but cost is blank | Usage is recorded, but the backend has no price for the model. Register a model price for the reported model name; the gateway emits raw usage and does not compute cost. |
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Other plugins' skills for the same job
npx claudepluginhub astropods/agents --plugin astropods4 skills in this plugin
/agent-cardStepsCreate or update the AGENT.md for the current Astropods agent project./build-astropods-agentbuild-astropods-agent — recipes for building a Mastra + Astropods agentRecipes for building an AI agent for the Astropods platform./migrate-to-astropodsMigrate Agent to AstropodsPort a net-new project to the Astropods platform by adding astropods.yml, Dockerfile, and AGENT.md. No agent logic is modified.