Steve Yegge
34cf361b2b
Add telemetry and observability to daemon (bd-153)
Implement comprehensive metrics collection for the daemon with zero-overhead design:
Features:
- Request metrics: counts, latency percentiles (p50, p95, p99), error rates
- Cache metrics: hit/miss ratios, eviction counts, database connections
- Connection metrics: total, active, rejected connections
- System metrics: memory usage, goroutine count, uptime
Implementation:
- New internal/rpc/metrics.go with Metrics collector
- OpMetrics RPC operation for programmatic access
- 'bd daemon --metrics' command (human-readable and JSON output)
- Lock-free atomic operations for cache/connection metrics
- Copy-and-compute pattern in Snapshot to minimize lock contention
- Deferred metrics recording ensures all requests are tracked
Improvements from code review:
- JSON types use float64 for ms/seconds (not time.Duration)
- Snapshot copies data under short lock, computes outside
- Union of operations from counts and errors maps
- Defensive clamping in percentile calculation
- Defer pattern ensures metrics recorded even on early returns
Documentation updated in README.md with usage examples.
Closes bd-153
Amp-Thread-ID: https://ampcode.com/threads/T-20213187-65c7-47f7-ba21-5234c9e52e26
Co-authored-by: Amp <amp@ampcode.com>
2025-10-19 15:55:55 -07:00
..
2025-10-17 11:24:39 -07:00
2025-10-16 17:44:58 -07:00
2025-10-17 23:42:57 -07:00
2025-10-16 20:50:40 -07:00
2025-10-18 16:30:19 -07:00
2025-10-17 22:45:33 -07:00
2025-10-18 15:59:03 +09:00
2025-10-18 15:59:03 +09:00
2025-10-19 15:55:55 -07:00
2025-10-17 22:06:21 -07:00
2025-10-19 09:00:11 -07:00
2025-10-17 13:50:20 -07:00
2025-10-15 14:52:29 -07:00
2025-10-17 17:40:16 -07:00
2025-10-15 02:57:10 -07:00
2025-10-18 17:14:21 -07:00
2025-10-18 17:14:21 -07:00
2025-10-17 00:09:26 -07:00
2025-10-17 11:24:39 -07:00
2025-10-15 17:51:09 -07:00
2025-10-15 23:38:47 -07:00
2025-10-17 21:56:03 -07:00
2025-10-18 09:58:35 -07:00
2025-10-19 08:04:48 -07:00
2025-10-14 13:21:08 -07:00
2025-10-15 23:38:47 -07:00
2025-10-18 18:21:17 -07:00
2025-10-18 00:37:27 -07:00
2025-10-16 17:05:27 -07:00
2025-10-16 21:29:20 -07:00
2025-10-16 21:21:17 -07:00
2025-10-18 09:58:35 -07:00
2025-10-15 17:06:59 -07:00
2025-10-15 16:31:11 -07:00
2025-10-18 00:37:27 -07:00
2025-10-16 18:06:53 -07:00
2025-10-16 17:11:54 -07:00
2025-10-18 17:14:21 -07:00
2025-10-16 12:43:43 -07:00
2025-10-19 08:04:48 -07:00