vafast 0.4.8 → 0.4.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -602,6 +602,33 @@ const categories = registry.getCategories(); // ['auth', 'users']
|
|
|
602
602
|
| `map(callback)` | 映射所有路由 |
|
|
603
603
|
| `size` | 路由数量 |
|
|
604
604
|
|
|
605
|
+
## 📊 内置监控
|
|
606
|
+
|
|
607
|
+
零依赖的性能监控,一行代码启用:
|
|
608
|
+
|
|
609
|
+
```typescript
|
|
610
|
+
import { Server } from 'vafast';
|
|
611
|
+
import { withMonitoring } from 'vafast/monitoring';
|
|
612
|
+
|
|
613
|
+
const server = new Server(routes);
|
|
614
|
+
const monitored = withMonitoring(server, {
|
|
615
|
+
slowThreshold: 500,
|
|
616
|
+
excludePaths: ['/health']
|
|
617
|
+
});
|
|
618
|
+
|
|
619
|
+
// 获取监控状态
|
|
620
|
+
const status = monitored.getMonitoringStatus();
|
|
621
|
+
console.log(`P99: ${status.p99}ms, RPS: ${status.rps}`);
|
|
622
|
+
```
|
|
623
|
+
|
|
624
|
+
**特性:**
|
|
625
|
+
- P50/P95/P99 百分位数
|
|
626
|
+
- 时间窗口统计(1分钟/5分钟/1小时)
|
|
627
|
+
- RPS 计算、状态码分布
|
|
628
|
+
- 按路径统计、内存监控
|
|
629
|
+
- 采样率控制、路径排除
|
|
630
|
+
- 自定义回调(onRequest/onSlowRequest)
|
|
631
|
+
|
|
605
632
|
## 🔧 运行时支持
|
|
606
633
|
|
|
607
634
|
```typescript
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vafast",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.20",
|
|
4
4
|
"description": "极简结构化Web框架,支持 Bun 和 Node.js。Go风格,函数优先。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"dev": "npx tsx watch example/index.ts",
|
|
41
41
|
"test": "vitest run",
|
|
42
42
|
"type-check": "tsc --noEmit",
|
|
43
|
-
"release": "npm run type-check && npm run build && npm run test && npx bumpp
|
|
43
|
+
"release": "npm run type-check && npm run build && npm run test && npx bumpp"
|
|
44
44
|
},
|
|
45
45
|
"keywords": [
|
|
46
46
|
"bun",
|