Skip to main content
Back to timeline
mastra.aiSource publication:

Mastra adds latency metrics to observability: see whether an agent's first response waits on the model or your own code

Synopsis

Mastra platform and Studio now record two latency metrics for every agent and model call: TTFC, the time a user waits before the first chunk arrives, and TTFT, the time the model takes to start responding. Previously durationMs showed only how long a run took, not how long a user waited for the first response or whether that wait came from the model or from the application's own code. Both metrics are recorded on every span, from the model call up to the agent run, and can be filtered and sorted as fields in trace and span queries on Mastra platform and on self-hosted projects whose storage uses DuckDB, PostgreSQL, or ClickHouse.

Source-provided article image: Introducing Latency Metrics for Mastra Observability
mastra.ai

Interpretation

Mastra observability now records two latency metrics aimed at user waiting, so slowness in an agent run can be located separately as how long until the user sees the first chunk and how long the model takes to start responding. The previously available durationMs reflected only the total length of a run, and could not show how long a user waited for the first response or whether that wait came from the model call or from the application's own code. Both metrics are recorded on every span, from the model call up to the agent run, so waits at the same level can be compared separately.

The two metrics enter the query interface as fields and can be used alongside status, environment, and agent name to filter and sort traces, spans, and threads. The query entry points are the Mastra CLI, Mastra platform and Studio, the Mastra Client SDK, and observability endpoints, four ways to use the metrics. The example queries find runs from the last 7 days where users waited more than 10 seconds for the first chunk and runs where the model took more than 3 seconds to start responding; the Traces tab on platform and Studio filters and sorts by these metrics, and platform can show the columns through column settings.

Perspective

The metrics are for developers using Mastra platform or self-hosted Mastra projects whose observability storage is DuckDB, PostgreSQL, or ClickHouse; queries need a platform access token and project ID, and the observability base URL is chosen by the project's region, US or EU.

The material reports no latency measurements or before-and-after comparison, so how many slow points the two metrics reveal and how much a fix improves are not shown.