Files
tootaio.com/docs/20251106/observability.md
xiaomai 40b3ee147f docs(engineering): add project audit report and improvement plan
This commit introduces a comprehensive engineering audit report for the Tootaio Studio project. The report is structured into documents covering architecture, code quality, performance, security, CI/CD, and
observability. It also includes a phased improvement roadmap and a set of `.patch` files to apply immediate fixes for content schemas, package scripts, and CI configuration.
2025-11-06 10:15:00 +08:00

41 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 监控、日志与可观测性
## 目标
构建可追踪错误、性能瓶颈与用户关键路径的最小监控闭环。
## Sentry推荐
1) 配置 `runtimeConfig.sentryDsn`
2) 插件(示例,待引入依赖后启用):
```ts
// plugins/sentry.client.ts
export default defineNuxtPlugin(() => {
const { public: pub, sentryDsn } = useRuntimeConfig()
if (!sentryDsn) return
// @ts-ignore: add SDK in deps later
const Sentry = (window as any).Sentry
if (Sentry) {
Sentry.init({ dsn: sentryDsn, tracesSampleRate: 0.1 })
}
})
```
## 日志与错误边界
- 服务器:使用 Nitro 默认日志(生产应接入集中式日志,如 CloudWatch/ELK
- 客户端:全局错误捕获(`app:error` 事件)上报到 Sentry/自建网关。
## Web Vitals可选
收集 LCP/CLS/INP 等指标(示例):
```ts
// plugins/web-vitals.client.ts
import { onCLS, onINP, onLCP } from 'web-vitals'
export default defineNuxtPlugin(() => {
const send = (metric: any) => navigator.sendBeacon('/vitals', JSON.stringify(metric))
onLCP(send); onCLS(send); onINP(send)
})
```
## Dashboard 路线
- 第一步:仅错误计数与关键事务。
- 第二步接口慢查询、资源错误分布、版本追踪commit SHA