> Discover all available pages from the documentation index: https://mastra.zisheng.pro/zh-HK/llms.txt # 可觀測性 Mastra 會透過 `src/mastra/` 直屬的 `observability.ts` 檔案設定[可觀測性](https://mastra.zisheng.pro/zh-HK/docs/observability/overview)。該檔案會預設匯出一個 `Observability` 實例,為項目設定追蹤、日誌、指標及意見回饋。 本頁說明檔案式慣例。如需了解訊號模型、匯出器、儲存空間及多重設定,請參閱[可觀測性概覽](https://mastra.zisheng.pro/zh-HK/docs/observability/overview)及[可觀測性設定](https://mastra.zisheng.pro/zh-HK/docs/observability/overview)。 ## 快速開始 建立 `src/mastra/observability.ts`,並預設匯出一個 `Observability` 實例: ```typescript import { MastraStorageExporter, Observability } from '@mastra/observability' export default new Observability({ configs: { default: { serviceName: 'mastra', exporters: [new MastraStorageExporter()], }, }, }) ``` ## 可觀測性與儲存空間 `observability.ts` 會設定收集哪些訊號,以及將其匯出至何處。[`storage.ts`](https://mastra.zisheng.pro/zh-HK/reference/file-based-agents/storage) 則設定可持久保存可觀測性記錄的項目儲存空間。如需了解各類訊號的儲存支援,請參閱[可觀測性訊號支援](https://mastra.zisheng.pro/zh-HK/docs/observability/overview)。 ## 與程式碼設定的優先次序 以程式碼註冊的可觀測性設定優先於 `observability.ts`。如果整個項目使用一項設定已足夠,請使用 `observability.ts`;如果設定取決於 `src/mastra/index.ts` 中的執行階段連接方式,請使用程式碼註冊。