Commit 5114a43
committed
feat(#142 T2.1): per-agent process telemetry — RSS / CPU% / uptime / in-flight count
v0.10.0 Track 2 / T2.1 — agent-node side per-agent process telemetry.
Extends #119's host-telemetry.ts with metrics scoped to THIS agent-node
process (vs the host machine). Aggregated by commhub-server T2.2
(派 通信牛) and rendered by dashboard sidebar/hover T2.3 (派 N站马).
New module: agent-node/src/process-telemetry.ts (~75 LOC)
Public API:
getProcessTelemetry(): ProcessTelemetry
{
rss_bytes: number, // process.memoryUsage().rss
rss_mb: number, // rss_bytes / 1MB, rounded to 1 decimal
cpu_pct: number | null, // delta cpuUsage / wall delta, % (null on first sample)
uptime_seconds: number, // Math.round(process.uptime())
in_flight_count: number, // current think() invocations in flight
}
incrementInFlight() / decrementInFlight() / getInFlightCount()
_resetProcessTelemetry() // test-only, resets sampler state
Wiring in cli.ts:
- register() + reportStatus() payloads now include process_telemetry
field alongside the existing host field (additive, ignored by old
commhub servers per the same conservative-additive principle as #119)
- think() wraps the run() body with incrementInFlight() / try /
decrementInFlight() in finally so the counter accurately reflects
active task processing even on error paths
CPU% calculation:
cpu.user_us + cpu.system_us delta over wall-clock delta, expressed
as percent. Can exceed 100 on multi-core systems (e.g. async I/O
parallelism). First sample returns null because there's no prior
reference point.
Unit smoke (local /tmp/p142-telemetry-smoke.mjs) PASS:
sample 1 (no prev): rss_mb=34, cpu_pct=null ✓
busy-loop 100ms + 3 incr + 1 decr →
sample 2: rss_mb=42.6, cpu_pct=109.3, in_flight_count=2 ✓
Bundle clean: bun 84 modules → 0.32 MB cli.js.
Refs #142 (T2.1 of 4)
Refs #140 (v0.10.0 tracker)
Author-Agent: 通信SDK马1 parent 3b29e84 commit 5114a43
2 files changed
Lines changed: 89 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
451 | 452 | | |
452 | 453 | | |
453 | 454 | | |
| 455 | + | |
454 | 456 | | |
455 | 457 | | |
456 | 458 | | |
| |||
460 | 462 | | |
461 | 463 | | |
462 | 464 | | |
| 465 | + | |
463 | 466 | | |
464 | 467 | | |
465 | 468 | | |
| |||
1031 | 1034 | | |
1032 | 1035 | | |
1033 | 1036 | | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
1034 | 1041 | | |
1035 | 1042 | | |
1036 | 1043 | | |
| |||
1046 | 1053 | | |
1047 | 1054 | | |
1048 | 1055 | | |
| 1056 | + | |
1049 | 1057 | | |
1050 | 1058 | | |
1051 | 1059 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
0 commit comments