Skip to main content

Observability

Mastra configures observability from an observability.ts file directly under src/mastra/. The file default-exports an Observability instance that sets up tracing, logging, metrics, and feedback for the project.

Use this page for the file-based convention. For the signal model, exporters, storage, and multi-config setup, see Observability overview and Observability configuration.

Quickstart
Direct link to Quickstart

Create src/mastra/observability.ts and default-export an Observability instance:

src/mastra/observability.ts
import { MastraStorageExporter, Observability } from '@mastra/observability'

export default new Observability({
configs: {
default: {
serviceName: 'mastra',
exporters: [new MastraStorageExporter()],
},
},
})

Observability and storage
Direct link to Observability and storage

observability.ts configures which signals are collected and where they're exported. storage.ts configures the project store that can persist observability records. For storage support by signal, see Observability storage.

Precedence with code
Direct link to Precedence with code

Code-registered observability wins over observability.ts. Use observability.ts when one project-wide configuration is enough; use code registration when setup depends on runtime wiring in src/mastra/index.ts.

On this page