proagents 1.6.19 → 1.6.21
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/.claude/settings.local.json +13 -1
- package/.proagents/.cursorrules +25 -10
- package/.proagents/.windsurfrules +25 -10
- package/.proagents/AGENTS.md +30 -11
- package/.proagents/AI_INSTRUCTIONS.md +86 -30
- package/.proagents/BOLT.md +25 -10
- package/.proagents/CLAUDE.md +25 -10
- package/.proagents/GEMINI.md +25 -10
- package/.proagents/KIRO.md +25 -10
- package/.proagents/LOVABLE.md +25 -10
- package/.proagents/PROAGENTS.md +96 -343
- package/.proagents/REPLIT.md +25 -10
- package/.proagents/activity.log +1 -0
- package/.proagents/custom-commands.yaml +0 -1
- package/.proagents/docs/command-details.md +1 -2
- package/.proagents/getting-started/ai-training-setup.md +0 -1
- package/.proagents/performance/README.md +59 -0
- package/.proagents/performance/bundle-analysis.md +375 -0
- package/.proagents/performance/load-testing.md +563 -0
- package/.proagents/performance/runtime-metrics.md +489 -0
- package/.proagents/performance/web-vitals.md +425 -0
- package/.proagents/platforms.yaml +66 -0
- package/.proagents/proagents.config.yaml +0 -1
- package/.proagents/prompts/ai-add.md +80 -0
- package/.proagents/prompts/ai-list.md +41 -0
- package/.proagents/prompts/ai-remove.md +112 -0
- package/.proagents/prompts/ai-sync.md +96 -0
- package/.proagents/workflow-modes/entry-modes.md +1 -6
- package/lib/commands/ai.js +100 -48
- package/lib/commands/init.js +89 -22
- package/package.json +1 -1
- package/.proagents/ANTIGRAVITY.md +0 -61
- package/.proagents/CHATGPT.md +0 -57
- package/.proagents/GROQ.md +0 -57
- package/.proagents/api-versioning/README.md +0 -257
- package/.proagents/api-versioning/changelog-template.md +0 -225
- package/.proagents/api-versioning/deprecation-workflow.md +0 -470
- package/.proagents/api-versioning/versioning-strategy.md +0 -291
- package/.proagents/automation/README.md +0 -38
- package/.proagents/automation/ai-behavior-rules.md +0 -339
- package/.proagents/automation/ai-prompt-injection.md +0 -331
- package/.proagents/automation/auto-decisions.md +0 -535
- package/.proagents/automation/decision-defaults.yaml +0 -317
- package/.proagents/cache/README.md +0 -110
- package/.proagents/cache/analysis-metadata.json +0 -76
- package/.proagents/cache/conventions.json +0 -125
- package/.proagents/cache/dependencies.json +0 -85
- package/.proagents/cache/features.json +0 -115
- package/.proagents/cache/patterns.json +0 -105
- package/.proagents/cache/schemas/conventions-schema.json +0 -138
- package/.proagents/cache/schemas/dependencies-schema.json +0 -95
- package/.proagents/cache/schemas/features-schema.json +0 -104
- package/.proagents/cache/schemas/metadata-schema.json +0 -83
- package/.proagents/cache/schemas/patterns-schema.json +0 -136
- package/.proagents/cache/schemas/structure-schema.json +0 -72
- package/.proagents/cache/structure.json +0 -109
- package/.proagents/checklists/README.md +0 -261
- package/.proagents/checklists/code-quality.md +0 -137
- package/.proagents/checklists/code-review.md +0 -148
- package/.proagents/checklists/pr-checklist.md +0 -78
- package/.proagents/checklists/pre-deployment.md +0 -132
- package/.proagents/checklists/pre-implementation.md +0 -80
- package/.proagents/checklists/testing.md +0 -120
- package/.proagents/checkpoints.json +0 -13
- package/.proagents/cicd/README.md +0 -338
- package/.proagents/cicd/azure-devops.md +0 -267
- package/.proagents/cicd/github-actions.md +0 -375
- package/.proagents/cicd/gitlab-ci.md +0 -278
- package/.proagents/cicd/jenkins.md +0 -317
- package/.proagents/collaboration/README.md +0 -143
- package/.proagents/collaboration/roles.md +0 -248
- package/.proagents/collaboration/sessions.md +0 -390
- package/.proagents/collaboration/sync.md +0 -358
- package/.proagents/cost/README.md +0 -48
- package/.proagents/cost/cost-template.md +0 -283
- package/.proagents/cost/estimation-framework.md +0 -287
- package/.proagents/database/README.md +0 -72
- package/.proagents/database/examples/001-create-users.sql +0 -129
- package/.proagents/database/examples/002-add-preferences.sql +0 -94
- package/.proagents/database/examples/003-add-index.sql +0 -105
- package/.proagents/database/examples/004-rename-column.sql +0 -122
- package/.proagents/database/examples/005-add-foreign-key.sql +0 -142
- package/.proagents/database/examples/006-data-migration.sql +0 -196
- package/.proagents/database/examples/007-drop-column.sql +0 -163
- package/.proagents/database/examples/README.md +0 -89
- package/.proagents/database/migration-workflow.md +0 -478
- package/.proagents/database/rollback-scripts.md +0 -487
- package/.proagents/database/safety-checks.md +0 -447
- package/.proagents/git/README.md +0 -68
- package/.proagents/git/branch-strategy.md +0 -164
- package/.proagents/git/commit-conventions.md +0 -241
- package/.proagents/git/pr-workflow.md +0 -286
- package/.proagents/git/rollback-procedures.md +0 -416
- package/.proagents/ide-integration/README.md +0 -124
- package/.proagents/ide-integration/cline-config.md +0 -429
- package/.proagents/ide-integration/continue-config.md +0 -380
- package/.proagents/ide-integration/cursor-rules.md +0 -280
- package/.proagents/ide-integration/github-copilot.md +0 -384
- package/.proagents/ide-integration/windsurf-rules.md +0 -314
- package/.proagents/integrations/README.md +0 -97
- package/.proagents/integrations/pm/README.md +0 -344
- package/.proagents/learning/README.md +0 -136
- package/.proagents/learning/adaptation.md +0 -305
- package/.proagents/learning/data-collection.md +0 -283
- package/.proagents/learning/implementation-guide.md +0 -865
- package/.proagents/learning/reports.md +0 -306
- package/.proagents/mcp/README.md +0 -133
- package/.proagents/mcp/context-providers.md +0 -442
- package/.proagents/mcp/server-config.md +0 -306
- package/.proagents/mcp/tools-definition.md +0 -513
- package/.proagents/pm-integration/README.md +0 -151
- package/.proagents/pm-integration/asana.md +0 -346
- package/.proagents/pm-integration/github-issues.md +0 -308
- package/.proagents/pm-integration/gitlab-issues.md +0 -482
- package/.proagents/pm-integration/jira.md +0 -364
- package/.proagents/pm-integration/linear.md +0 -409
- package/.proagents/pm-integration/notion.md +0 -275
- package/.proagents/pm-integration/sync-config.md +0 -533
- package/.proagents/pm-integration/trello.md +0 -159
- package/.proagents/rules/README.md +0 -179
- package/.proagents/rules/custom-rules-template.yaml +0 -286
- package/.proagents/rules/custom-rules.md +0 -754
- package/.proagents/rules/validation-rules-template.yaml +0 -517
- package/.proagents/runbooks/README.md +0 -219
- package/.proagents/runbooks/dependency-vulnerability.md +0 -505
- package/.proagents/runbooks/incident-response.md +0 -451
- package/.proagents/runbooks/performance-degradation.md +0 -584
- package/.proagents/runbooks/production-debugging.md +0 -489
- package/.proagents/sprints/README.md +0 -58
- package/.proagents/team/README.md +0 -256
- package/.proagents/team/code-ownership.md +0 -306
- package/.proagents/team/communication-templates.md +0 -441
- package/.proagents/team/handoff-protocol.md +0 -380
- package/.proagents/team/ide-setup/README.md +0 -103
- package/.proagents/team/ide-setup/cursor.md +0 -276
- package/.proagents/team/ide-setup/jetbrains.md +0 -330
- package/.proagents/team/ide-setup/neovim.md +0 -640
- package/.proagents/team/ide-setup/vscode.md +0 -348
- package/.proagents/team/onboarding.md +0 -278
- package/.proagents/time-tracking.json +0 -19
- package/.proagents/troubleshooting/README.md +0 -730
- package/.proagents/troubleshooting/ai-issues.md +0 -601
- package/.proagents/troubleshooting/workflow-issues.md +0 -571
|
@@ -0,0 +1,489 @@
|
|
|
1
|
+
# Runtime Performance Metrics
|
|
2
|
+
|
|
3
|
+
Monitor and measure application performance during execution.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
Runtime metrics help:
|
|
10
|
+
- Identify performance bottlenecks
|
|
11
|
+
- Track performance over time
|
|
12
|
+
- Alert on degradation
|
|
13
|
+
- Guide optimization efforts
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Key Metrics Categories
|
|
18
|
+
|
|
19
|
+
### 1. Response Time Metrics
|
|
20
|
+
|
|
21
|
+
```yaml
|
|
22
|
+
response_time:
|
|
23
|
+
targets:
|
|
24
|
+
p50: 100ms # 50th percentile (median)
|
|
25
|
+
p95: 300ms # 95th percentile
|
|
26
|
+
p99: 500ms # 99th percentile
|
|
27
|
+
max: 2000ms # Maximum acceptable
|
|
28
|
+
|
|
29
|
+
by_endpoint:
|
|
30
|
+
"/api/users":
|
|
31
|
+
p50: 45ms
|
|
32
|
+
p95: 120ms
|
|
33
|
+
p99: 250ms
|
|
34
|
+
status: "healthy"
|
|
35
|
+
|
|
36
|
+
"/api/users/:id":
|
|
37
|
+
p50: 35ms
|
|
38
|
+
p95: 80ms
|
|
39
|
+
p99: 150ms
|
|
40
|
+
status: "healthy"
|
|
41
|
+
|
|
42
|
+
"/api/reports/generate":
|
|
43
|
+
p50: 1200ms
|
|
44
|
+
p95: 3500ms
|
|
45
|
+
p99: 8000ms
|
|
46
|
+
status: "needs_optimization"
|
|
47
|
+
|
|
48
|
+
alerts:
|
|
49
|
+
warning_threshold: "p95 > 500ms"
|
|
50
|
+
critical_threshold: "p99 > 2000ms"
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 2. Throughput Metrics
|
|
54
|
+
|
|
55
|
+
```yaml
|
|
56
|
+
throughput:
|
|
57
|
+
requests_per_second:
|
|
58
|
+
current: 450
|
|
59
|
+
peak: 1200
|
|
60
|
+
target: 1000
|
|
61
|
+
|
|
62
|
+
by_endpoint:
|
|
63
|
+
"/api/users": 150 rps
|
|
64
|
+
"/api/auth/login": 50 rps
|
|
65
|
+
"/api/posts": 200 rps
|
|
66
|
+
|
|
67
|
+
capacity:
|
|
68
|
+
current_utilization: 45%
|
|
69
|
+
headroom: 55%
|
|
70
|
+
estimated_max: 1000 rps
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### 3. Error Rate Metrics
|
|
74
|
+
|
|
75
|
+
```yaml
|
|
76
|
+
error_rates:
|
|
77
|
+
overall: 0.5%
|
|
78
|
+
target: "<1%"
|
|
79
|
+
|
|
80
|
+
by_type:
|
|
81
|
+
"4xx": 0.3%
|
|
82
|
+
"5xx": 0.2%
|
|
83
|
+
|
|
84
|
+
by_endpoint:
|
|
85
|
+
"/api/users":
|
|
86
|
+
error_rate: 0.1%
|
|
87
|
+
status: "healthy"
|
|
88
|
+
|
|
89
|
+
"/api/payments":
|
|
90
|
+
error_rate: 1.5%
|
|
91
|
+
status: "needs_attention"
|
|
92
|
+
top_errors:
|
|
93
|
+
- "Payment gateway timeout": 45%
|
|
94
|
+
- "Invalid card": 30%
|
|
95
|
+
- "Internal error": 25%
|
|
96
|
+
|
|
97
|
+
alerts:
|
|
98
|
+
warning: ">1%"
|
|
99
|
+
critical: ">5%"
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### 4. Resource Utilization
|
|
103
|
+
|
|
104
|
+
```yaml
|
|
105
|
+
resources:
|
|
106
|
+
cpu:
|
|
107
|
+
average: 35%
|
|
108
|
+
peak: 75%
|
|
109
|
+
target: "<70%"
|
|
110
|
+
|
|
111
|
+
memory:
|
|
112
|
+
used: "2.1GB"
|
|
113
|
+
available: "4GB"
|
|
114
|
+
utilization: 52%
|
|
115
|
+
heap_used: "1.8GB"
|
|
116
|
+
heap_limit: "3GB"
|
|
117
|
+
|
|
118
|
+
connections:
|
|
119
|
+
database:
|
|
120
|
+
active: 25
|
|
121
|
+
idle: 5
|
|
122
|
+
max: 100
|
|
123
|
+
utilization: 25%
|
|
124
|
+
|
|
125
|
+
redis:
|
|
126
|
+
active: 10
|
|
127
|
+
max: 50
|
|
128
|
+
utilization: 20%
|
|
129
|
+
|
|
130
|
+
event_loop:
|
|
131
|
+
lag: "2ms"
|
|
132
|
+
target: "<10ms"
|
|
133
|
+
status: "healthy"
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## Monitoring Implementation
|
|
139
|
+
|
|
140
|
+
### 1. Node.js Performance Monitoring
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
// src/lib/metrics.ts
|
|
144
|
+
import { performance, PerformanceObserver } from 'perf_hooks';
|
|
145
|
+
import { Counter, Histogram, Gauge, Registry } from 'prom-client';
|
|
146
|
+
|
|
147
|
+
// Create metrics registry
|
|
148
|
+
const register = new Registry();
|
|
149
|
+
|
|
150
|
+
// HTTP request duration histogram
|
|
151
|
+
const httpRequestDuration = new Histogram({
|
|
152
|
+
name: 'http_request_duration_seconds',
|
|
153
|
+
help: 'Duration of HTTP requests in seconds',
|
|
154
|
+
labelNames: ['method', 'route', 'status_code'],
|
|
155
|
+
buckets: [0.01, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10],
|
|
156
|
+
registers: [register],
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
// Request counter
|
|
160
|
+
const httpRequestsTotal = new Counter({
|
|
161
|
+
name: 'http_requests_total',
|
|
162
|
+
help: 'Total number of HTTP requests',
|
|
163
|
+
labelNames: ['method', 'route', 'status_code'],
|
|
164
|
+
registers: [register],
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
// Active connections gauge
|
|
168
|
+
const activeConnections = new Gauge({
|
|
169
|
+
name: 'active_connections',
|
|
170
|
+
help: 'Number of active connections',
|
|
171
|
+
registers: [register],
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
// Error counter
|
|
175
|
+
const errorsTotal = new Counter({
|
|
176
|
+
name: 'errors_total',
|
|
177
|
+
help: 'Total number of errors',
|
|
178
|
+
labelNames: ['type', 'route'],
|
|
179
|
+
registers: [register],
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
// Middleware for Express
|
|
183
|
+
export function metricsMiddleware(req, res, next) {
|
|
184
|
+
const start = performance.now();
|
|
185
|
+
|
|
186
|
+
res.on('finish', () => {
|
|
187
|
+
const duration = (performance.now() - start) / 1000;
|
|
188
|
+
const route = req.route?.path || req.path;
|
|
189
|
+
|
|
190
|
+
httpRequestDuration.observe(
|
|
191
|
+
{ method: req.method, route, status_code: res.statusCode },
|
|
192
|
+
duration
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
httpRequestsTotal.inc({
|
|
196
|
+
method: req.method,
|
|
197
|
+
route,
|
|
198
|
+
status_code: res.statusCode,
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
if (res.statusCode >= 400) {
|
|
202
|
+
errorsTotal.inc({
|
|
203
|
+
type: res.statusCode >= 500 ? 'server' : 'client',
|
|
204
|
+
route,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
next();
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export { register, httpRequestDuration, httpRequestsTotal, activeConnections };
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### 2. Database Query Monitoring
|
|
216
|
+
|
|
217
|
+
```typescript
|
|
218
|
+
// src/lib/db-metrics.ts
|
|
219
|
+
import { Histogram, Counter } from 'prom-client';
|
|
220
|
+
|
|
221
|
+
const queryDuration = new Histogram({
|
|
222
|
+
name: 'db_query_duration_seconds',
|
|
223
|
+
help: 'Duration of database queries',
|
|
224
|
+
labelNames: ['operation', 'table'],
|
|
225
|
+
buckets: [0.001, 0.005, 0.01, 0.05, 0.1, 0.5, 1, 5],
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
const slowQueries = new Counter({
|
|
229
|
+
name: 'db_slow_queries_total',
|
|
230
|
+
help: 'Number of slow queries (>100ms)',
|
|
231
|
+
labelNames: ['operation', 'table'],
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
// Prisma middleware for query monitoring
|
|
235
|
+
export const prismaMetrics = {
|
|
236
|
+
async $use(params, next) {
|
|
237
|
+
const start = performance.now();
|
|
238
|
+
const result = await next(params);
|
|
239
|
+
const duration = (performance.now() - start) / 1000;
|
|
240
|
+
|
|
241
|
+
queryDuration.observe(
|
|
242
|
+
{ operation: params.action, table: params.model },
|
|
243
|
+
duration
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
if (duration > 0.1) {
|
|
247
|
+
slowQueries.inc({ operation: params.action, table: params.model });
|
|
248
|
+
console.warn(`Slow query: ${params.model}.${params.action} took ${duration}s`);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
return result;
|
|
252
|
+
},
|
|
253
|
+
};
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### 3. Memory Monitoring
|
|
257
|
+
|
|
258
|
+
```typescript
|
|
259
|
+
// src/lib/memory-metrics.ts
|
|
260
|
+
import { Gauge } from 'prom-client';
|
|
261
|
+
|
|
262
|
+
const memoryUsage = new Gauge({
|
|
263
|
+
name: 'nodejs_memory_usage_bytes',
|
|
264
|
+
help: 'Memory usage in bytes',
|
|
265
|
+
labelNames: ['type'],
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
const eventLoopLag = new Gauge({
|
|
269
|
+
name: 'nodejs_eventloop_lag_seconds',
|
|
270
|
+
help: 'Event loop lag in seconds',
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
// Collect memory metrics every 10 seconds
|
|
274
|
+
setInterval(() => {
|
|
275
|
+
const mem = process.memoryUsage();
|
|
276
|
+
memoryUsage.set({ type: 'heapUsed' }, mem.heapUsed);
|
|
277
|
+
memoryUsage.set({ type: 'heapTotal' }, mem.heapTotal);
|
|
278
|
+
memoryUsage.set({ type: 'rss' }, mem.rss);
|
|
279
|
+
memoryUsage.set({ type: 'external' }, mem.external);
|
|
280
|
+
}, 10000);
|
|
281
|
+
|
|
282
|
+
// Measure event loop lag
|
|
283
|
+
let lastCheck = process.hrtime.bigint();
|
|
284
|
+
setInterval(() => {
|
|
285
|
+
const now = process.hrtime.bigint();
|
|
286
|
+
const lag = Number(now - lastCheck) / 1e9 - 0.1; // Subtract expected 100ms
|
|
287
|
+
eventLoopLag.set(Math.max(0, lag));
|
|
288
|
+
lastCheck = now;
|
|
289
|
+
}, 100);
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
## Metrics Dashboard
|
|
295
|
+
|
|
296
|
+
```yaml
|
|
297
|
+
dashboard:
|
|
298
|
+
overview:
|
|
299
|
+
- metric: "Request Rate"
|
|
300
|
+
value: "450 req/s"
|
|
301
|
+
trend: "+5%"
|
|
302
|
+
status: "healthy"
|
|
303
|
+
|
|
304
|
+
- metric: "Error Rate"
|
|
305
|
+
value: "0.5%"
|
|
306
|
+
trend: "-10%"
|
|
307
|
+
status: "healthy"
|
|
308
|
+
|
|
309
|
+
- metric: "P95 Latency"
|
|
310
|
+
value: "120ms"
|
|
311
|
+
trend: "+15ms"
|
|
312
|
+
status: "warning"
|
|
313
|
+
|
|
314
|
+
- metric: "CPU Usage"
|
|
315
|
+
value: "35%"
|
|
316
|
+
trend: "stable"
|
|
317
|
+
status: "healthy"
|
|
318
|
+
|
|
319
|
+
charts:
|
|
320
|
+
- name: "Request Latency Distribution"
|
|
321
|
+
type: "histogram"
|
|
322
|
+
data: "http_request_duration_seconds"
|
|
323
|
+
|
|
324
|
+
- name: "Requests Over Time"
|
|
325
|
+
type: "line"
|
|
326
|
+
data: "rate(http_requests_total[5m])"
|
|
327
|
+
|
|
328
|
+
- name: "Error Rate"
|
|
329
|
+
type: "line"
|
|
330
|
+
data: "rate(errors_total[5m])"
|
|
331
|
+
|
|
332
|
+
- name: "Memory Usage"
|
|
333
|
+
type: "area"
|
|
334
|
+
data: "nodejs_memory_usage_bytes"
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
**Visual Dashboard:**
|
|
338
|
+
```
|
|
339
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
340
|
+
│ Performance Dashboard │
|
|
341
|
+
├──────────────────┬──────────────────┬──────────────────────┤
|
|
342
|
+
│ Request Rate │ Error Rate │ P95 Latency │
|
|
343
|
+
│ 450 req/s │ 0.5% │ 120ms │
|
|
344
|
+
│ ↑ +5% │ ↓ -10% │ ↑ +15ms │
|
|
345
|
+
│ ✅ │ ✅ │ ⚠️ │
|
|
346
|
+
├──────────────────┴──────────────────┴──────────────────────┤
|
|
347
|
+
│ │
|
|
348
|
+
│ Request Latency (last hour) │
|
|
349
|
+
│ ┌─────────────────────────────────────────────────────┐ │
|
|
350
|
+
│ │ ╭──╮ ╭─╮ │ │
|
|
351
|
+
│ │ ╭╯ ╰╮ ╭╯ ╰╮ ╭──╮ │ │
|
|
352
|
+
│ │──╯ ╰────╯ ╰────╯ ╰────────────────────── │ │
|
|
353
|
+
│ │ │ │
|
|
354
|
+
│ └─────────────────────────────────────────────────────┘ │
|
|
355
|
+
│ │
|
|
356
|
+
│ Slowest Endpoints Error Distribution │
|
|
357
|
+
│ ┌───────────────────────┐ ┌──────────────────┐ │
|
|
358
|
+
│ │ /api/reports 1200ms │ │ 4xx ████████ 60% │ │
|
|
359
|
+
│ │ /api/search 450ms │ │ 5xx ████ 40% │ │
|
|
360
|
+
│ │ /api/export 380ms │ └──────────────────┘ │
|
|
361
|
+
│ └───────────────────────┘ │
|
|
362
|
+
└─────────────────────────────────────────────────────────────┘
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
---
|
|
366
|
+
|
|
367
|
+
## Alerting Rules
|
|
368
|
+
|
|
369
|
+
```yaml
|
|
370
|
+
# prometheus/alerts.yml
|
|
371
|
+
groups:
|
|
372
|
+
- name: performance
|
|
373
|
+
rules:
|
|
374
|
+
- alert: HighLatency
|
|
375
|
+
expr: histogram_quantile(0.95, http_request_duration_seconds) > 0.5
|
|
376
|
+
for: 5m
|
|
377
|
+
labels:
|
|
378
|
+
severity: warning
|
|
379
|
+
annotations:
|
|
380
|
+
summary: "High latency detected"
|
|
381
|
+
description: "P95 latency is above 500ms"
|
|
382
|
+
|
|
383
|
+
- alert: HighErrorRate
|
|
384
|
+
expr: rate(errors_total[5m]) / rate(http_requests_total[5m]) > 0.05
|
|
385
|
+
for: 2m
|
|
386
|
+
labels:
|
|
387
|
+
severity: critical
|
|
388
|
+
annotations:
|
|
389
|
+
summary: "High error rate"
|
|
390
|
+
description: "Error rate is above 5%"
|
|
391
|
+
|
|
392
|
+
- alert: HighMemoryUsage
|
|
393
|
+
expr: nodejs_memory_usage_bytes{type="heapUsed"} / nodejs_memory_usage_bytes{type="heapTotal"} > 0.9
|
|
394
|
+
for: 10m
|
|
395
|
+
labels:
|
|
396
|
+
severity: warning
|
|
397
|
+
annotations:
|
|
398
|
+
summary: "High memory usage"
|
|
399
|
+
description: "Heap usage is above 90%"
|
|
400
|
+
|
|
401
|
+
- alert: SlowQueries
|
|
402
|
+
expr: rate(db_slow_queries_total[5m]) > 10
|
|
403
|
+
for: 5m
|
|
404
|
+
labels:
|
|
405
|
+
severity: warning
|
|
406
|
+
annotations:
|
|
407
|
+
summary: "Slow database queries"
|
|
408
|
+
description: "More than 10 slow queries per minute"
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
---
|
|
412
|
+
|
|
413
|
+
## Performance Baseline
|
|
414
|
+
|
|
415
|
+
```yaml
|
|
416
|
+
baseline:
|
|
417
|
+
established: "2024-01-01"
|
|
418
|
+
environment: "production"
|
|
419
|
+
|
|
420
|
+
metrics:
|
|
421
|
+
response_time:
|
|
422
|
+
p50: 45ms
|
|
423
|
+
p95: 120ms
|
|
424
|
+
p99: 250ms
|
|
425
|
+
|
|
426
|
+
throughput:
|
|
427
|
+
average: 400 rps
|
|
428
|
+
peak: 1000 rps
|
|
429
|
+
|
|
430
|
+
error_rate: 0.3%
|
|
431
|
+
|
|
432
|
+
resources:
|
|
433
|
+
cpu_average: 30%
|
|
434
|
+
memory_average: 50%
|
|
435
|
+
|
|
436
|
+
comparison:
|
|
437
|
+
current_vs_baseline:
|
|
438
|
+
response_time_p95: "+8%" # 120ms → 130ms
|
|
439
|
+
throughput: "+12%" # 400 → 450 rps
|
|
440
|
+
error_rate: "+67%" # 0.3% → 0.5%
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
---
|
|
444
|
+
|
|
445
|
+
## Configuration
|
|
446
|
+
|
|
447
|
+
```yaml
|
|
448
|
+
# proagents.config.yaml
|
|
449
|
+
|
|
450
|
+
performance:
|
|
451
|
+
runtime_metrics:
|
|
452
|
+
enabled: true
|
|
453
|
+
|
|
454
|
+
collect:
|
|
455
|
+
- response_time
|
|
456
|
+
- throughput
|
|
457
|
+
- error_rate
|
|
458
|
+
- cpu_usage
|
|
459
|
+
- memory_usage
|
|
460
|
+
- database_queries
|
|
461
|
+
- event_loop_lag
|
|
462
|
+
|
|
463
|
+
endpoints:
|
|
464
|
+
metrics: "/metrics" # Prometheus format
|
|
465
|
+
health: "/health"
|
|
466
|
+
|
|
467
|
+
targets:
|
|
468
|
+
response_time_p95: 300ms
|
|
469
|
+
error_rate: 1%
|
|
470
|
+
cpu_usage: 70%
|
|
471
|
+
|
|
472
|
+
alerting:
|
|
473
|
+
enabled: true
|
|
474
|
+
channels:
|
|
475
|
+
- slack
|
|
476
|
+
- pagerduty
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
---
|
|
480
|
+
|
|
481
|
+
## Commands
|
|
482
|
+
|
|
483
|
+
| Command | Description |
|
|
484
|
+
|---------|-------------|
|
|
485
|
+
| `pa:perf-metrics` | View current metrics |
|
|
486
|
+
| `pa:perf-metrics --endpoint [path]` | Metrics for specific endpoint |
|
|
487
|
+
| `pa:perf-metrics --baseline` | Compare to baseline |
|
|
488
|
+
| `pa:perf-metrics --slow` | List slow endpoints |
|
|
489
|
+
| `pa:perf-metrics --alerts` | View active alerts |
|