npm / @mastra/observability
@mastra/observability
What changed in @mastra/observability 1, from its official release notes, upgrade guides and advisories. Sources checked 2026-12-05.
7 breaking2 security21 new APIs and options15 behavior and defaults49 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli init@mastra/observability 194 changes
Breaking changes 7
Opt in to retaining MastraStorageExporter on Platform alongside Mastra Platform; built-in storage exporters remain disabled there by default.
On traces using hideInput or hideOutput, exported span errors redact messages and omit free-form details to avoid exposing hidden input or output.
Ended spans ignore subsequent end(), error(), and outcome updates, preserving the exported result; null or absent outcome means none was recorded.
Agent-stream inference spans retain provider timing and usage but no longer record response output; use processed chunks or MODEL_GENERATION output instead.
Spans and signals no longer attribute a versioned agent's version to its tool or model calls, so grouping or filtering by version counts only that version's own entity.
Completed event spans now end at their start time with zero duration, and no longer emit duration metrics.
Processors returning a copy of a span now cause the span to be dropped with a logged processor error, rather than throwing for started or updated spans or silently dropping ended spans.
Security 2
Redacts the entire value under a sensitive key, including nested objects and arrays, preventing nested values from appearing in traces.
Sensitive fields inside a span's requestContext are now redacted like fields in attributes, metadata, input, output, and errorInfo.
New APIs and options 21
MastraPlatformExporter and MastraStorageExporter support opt-in byte-based flush thresholds and configurable export concurrency; count batching remains the default.
Platform can export feedback and scores that require trace details, retrying while waiting for a trace; flush and shutdown wait for pending deliveries.
Delivers feedback replacements through supporting exporters; Platform sends PUT requests and storage exporters persist their copies independently.
Spans now include local error counts, allowing developers to inspect errors associated with an individual span.
Updates feedback review status through supporting storage and Platform exporters; flush and shutdown wait for pending updates.
After cancellation, end a span and its open descendants by passing endTree: true.
Span lifecycle methods and exporters support execution outcomes; custom producers can retain arbitrary outcome strings.
Span lifecycle methods accept a stop reason, with framework-generated context containing compact facts and span references.
Model and agent spans report milliseconds from model-call start to the first streamed chunk, excluding work before the model call.
Spans can be filtered and grouped by parent or root entity; durable agents retain lineage across steps, while previously stored spans have no parent or root entity.
Model tracing records completionStartTime on the first response chunk and copies it to the model step, model generation, and agent run span, enabling time-to-first-chunk calculations at every level.
Controls price refresh behavior: refresh is on by default under mastra dev and off by default in other environments.
Disables price refresh everywhere, regardless of the MASTRA_AUTO_REFRESH_PRICING setting.
Added tracingOptions.nestUnderParent for runs with a traceId and parentSpanId; exported spans are marked nestedUnderParent and run tags are no longer applied to the trace.
Token and cost metrics now include a shared usageId per model call, letting storage group metric rows independently of their span.
The tools attribute is added to MODEL_INFERENCE spans, holding the tool definitions sent to the provider so exporters can read the tools for each model call.
Set a per-run root span name for agent and workflow runs, including through HTTP routes and generated client request types. The name replaces the default on the root span only; child span names and entity filtering are unchanged.
Added resolveFromEnv; set it to false to ignore the listed environment credentials and endpoint, using only passed config. It defaults to true.
Added the endTree option to close still-open descendant spans when ending a span, without applying the terminal output or error to them.
Adds an API that closes a span and every still-open descendant, applying the supplied options to each so abandoned operations can emit a full trace.
Added the indexed redaction style, which assigns each unique sensitive value a stable token derived from the first matched field name.
Behavior and default changes 15
A fallback model attempt opens its own inference span named after the model it calls, and the failed attempt's span ends with the error.
Exported spans include model as a top-level field when the span's own attributes have both model and provider.
Processed MODEL_CHUNK spans are children of MODEL_STEP regardless of output-processor buffering.
Exported spans include provider as a top-level field when the span's own attributes have both model and provider.
Ending a span again is reported as a dropped event with the span-not-updatable reason.
Storage and Platform exporters automatically provide span-aware input, output, and error previews using processed payloads; intentionally empty strings are preserved.
Classifier token usage now contributes to token and cost metrics and appears in Studio traces, with estimated costs when the model has a known price.
Bundled model pricing was updated with the latest prices from models.dev, affecting estimated costs for models with known prices.
The model label on cost metrics now uses the models.dev model ID for some models, so charts grouped by model can show them under a new name.
Cost estimates use model prices from models.dev; models no longer listed there retain token metrics but no longer receive cost estimates.
Custom gateways can return pricing from fetchProviders() to provide cost estimates for models that models.dev doesn't price.
A model request cancelled by a queued signal gets its own inference span ending with finish reason interrupted; its replacement opens a separate span under the same MODEL_STEP.
Provider API errors now include the HTTP status code, request URL, retryability, and provider response body under
details, making failures easier to diagnose.Requests now advertise quota-pause support, allowing the platform to return 402 Payment Required to clients that understand the contract while shielding legacy clients from retry loops.
Automatically pauses uploads when the organization's observability quota is exhausted, drops events locally, and periodically probes for re-enablement; exports resume automatically, with warnings on pause and resume.
Fixes and other changes 49
Each exporter handles its own destination, so missing local traces no longer block remote export; storage lookup retries are included in flush and shutdown.
Model inference spans carry the response again after output processors run, so exporters can show model text and tool calls.
Raw provider streams now attach the serving model to the span, preventing cost estimation and exporters from falling back to the requested model.
Stored spans inherit the service name from Observability config when span metadata does not set one, allowing span and trace filters to find them by that service name.
hideInput and hideOutput settings now remain effective on tool calls, nested workflows, and Inngest workflow and step spans in durable agent runs, including runs continued in a later step.
For batch-with-updates or realtime tracing, ended spans from another process are sent directly to storage instead of waiting for an unseen start; conditional span updates are required.
Model step spans report the model and provider actually called, including after an input processor switches models or a fallback takes over; both are empty when no model is called.
Vercel AI Gateway routing details are retained on model step spans so exporters can identify the serving provider and failed provider attempts before fallback.
Native span fields, including resumedFromSpanId, outcome, stopReason, and stopReasonContext, survive export, snapshots, and rebuilds for durable and multi-worker runs.
Suspended or approval-waiting tool calls now report token usage and end model step and inference spans as suspended; later approval requests from the same step no longer create empty spans.
Cost estimates for inference profiles with the
in.prefix no longer reportno_matching_model.Tracking exporters wait for in-progress trace-cap evictions in
flush()andshutdown(), ensuring aborted spans are sent instead of queued after flushing or aborted twice.MastraStorageExporter and DefaultExporter flush() now wait for storage writes already started by a batch timer or size trigger, preventing spans from being lost when a process exits.
Spans keep and export links they were started with and links set before they end; links with invalid W3C trace or span IDs are ignored.
MastraStorageExporter and DefaultExporter shutdown() now wait for storage writes already started by a batch timer or size trigger, preventing spans from being lost when a process exits.
Datadog APM no longer starts a dd-trace span for excluded types, allowing remaining spans to finish and the trace to be sent.
flush() and shutdown() finish processing queued span events first, preventing spans from being incorrectly reported as aborted when shutdown follows flush.
When a model has no separate reasoning price, reasoning tokens use the output price in cost estimates, matching provider billing.
Each model inference span records the first content time for its own request instead of reusing the run's first request time.
Spans in Braintrust, LangSmith, and PostHog traces now end with their real output instead of staying open until shutdown and being marked as failed.
Cost estimates are now available for the newest OpenAI and Anthropic models because the pricing data is up to date.
Root span selection now handles spans returned out of start order and traces with an unpersisted parent, so scores and feedback use the real root's entity and tags.
Cost estimates now use provider raw-usage counts for 5-minute and 1-hour cache writes, pricing 1-hour writes at their actual rate.
model_step spans no longer export the provider's raw HTTP response body in metadata, avoiding oversized spans and repeated output and usage; response headers remain available.
Preserve internal span status through
exportSpan()andrebuildSpan(), so internal spans stay out of exporters by default and remain included whenincludeInternalSpansis enabled.Pricing data was refreshed to provide cost estimates for the newest models.
Exact OpenRouter generation costs, including BYOK upstream charges, are now reflected in observability spans and Langfuse exports.
Built-in storage exporters no longer continue writing in Mastra Platform deployments; other exporters remain enabled.
Model step and model inference spans now use ModelStepInput for their input type; what the spans record is unchanged.
Errors, aborts, suspensions, tripwires, and prepare failures now close the whole span tree, preventing exporters that wait for every span to finish from retaining traces and payloads indefinitely.
Already-redacted values keep their token across span events, so the same secret maps to one token across a trace; mappings are retained for the 1000 most recently seen traces.
Startup no longer fails when an older supported @mastra/core version lacks observability exports, because the helpers are defined locally.
Values extracted via requestContextKeys now reach exported spans even when the agent has no memory configured.
Metadata entries with undefined values no longer erase existing span values; entries with real values still take precedence.
MastraPlatformExporter now reads this environment variable as an observability endpoint override, allowing projects in non-default regions to route signals to the right collector.
Tripwire aborts from output stream processors in later steps of a multi-step agent run now show up on the processor_run span instead of an empty span.
Newly emitted logs and metrics use the nearest ancestor span that reaches exporters, or omit spanId when no such ancestor exists, preventing links to unavailable spans.
The exporter recovers when a configured observability store is temporarily unavailable during startup, allowing traces to resume on a later event without restarting the process.
Writes now preserve complete surrogate pairs and sanitize NUL characters and unpaired surrogates before the jsonb cast, preventing malformed fields from discarding an entire batch.
Repeated calls are ignored; a force-closed span retains its closed state and reports its end exactly once even if its work later calls end again.
TTL-specific rates are applied without double counting aggregate tokens.
Internal tracing fields are removed only from framework-owned payloads, preserving user data with matching key names.
The marker now counts only fields dropped by the object-key limit, and values beyond the limit are no longer read.
Fixed traces that start under an external parent span not appearing in Mastra Studio.
When excludeSpanTypes removes a parent span, descendant spans now use the nearest exported parent so exporters retain tool calls.
Prevents live workflow scores and feedback from being lost before trace data reaches observability storage, and logs a warning when an annotation cannot be saved.
Completed model inference spans now preserve the provider response model.
Completed model generations use costs reported by Vercel AI Gateway when every step reports a valid cost.
Token metrics retain model labels and cost data when providers return blank response model IDs.