跳到主要内容
非官方简体中文翻译,内容版权归 Mastra 所有,遵循 Apache-2.0 许可。

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 the observability overview and observability configuration.

Quickstart
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
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 signal support.

Precedence with code
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