Mastra observability adds custom metrics
TypeScript AI agent framework Mastra now lets developers emit domain-specific measurements via metrics.emit() inside tools, workflow steps, processors, scorers, or standalone code. Custom metrics are trace-correlated, queryable alongside automatic latency and token telemetry, and trigger threshold alerts on Mastra Platform.
Automatic token and latency telemetry tells you if an agent ran, not whether it delivered business value — custom metrics close that gap without bolting on a separate APM stack.
- –Trace-scoped instrumentation fits natively into Mastra's core primitives: tools, workflow steps, processors, and scorers receive a span-linked `MetricsContext` (falling back to a safe no-op when observability is disabled), while `mastra.metrics` covers untraced code
- –Emissions support key-value string labels plus structured `costContext` and `usageId` options, letting teams correlate domain KPIs like empty RAG searches or refund totals directly with per-call model spend
- –Custom metrics share full query parity across the Mastra Client SDK, CLI, and observability endpoints, and hook into Mastra Platform's alert channels (Slack, Discord, Teams, PagerDuty, incident.io, webhooks) when values cross configured thresholds
- –Self-hosted adopters face storage and UI constraints: metric queries require an analytics-capable backend (DuckDB for local dev, ClickHouse or Postgres in production — LibSQL and MongoDB aren't supported), and visual dashboards for custom metrics live in Mastra Platform rather than local Mastra Studio
- –Because Mastra still exports telemetry to OpenTelemetry-compatible tools like Langfuse, Braintrust, and Datadog, the upgrade sharpens its all-in-one TypeScript agent pitch without hard observability lock-in
DISCOVERED
23m ago
2026-12-01
PUBLISHED
1h ago
2026-12-01
RELEVANCE
AUTHOR
mastra