Metrics & Observability
Shared lock-free atomic counters across forked processes and the HTTP JSON GET /metrics endpoint.
Shared-Memory Atomic Telemetry
Status: Available. Implemented in utils/vsi_metrics.c. Before spawning any child service process, main() calls vsi_metrics_init(), which allocates a vsi_metrics_store_t struct via mmap(NULL, sizeof(...), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0).
Each counter is cache-line aligned (_Alignas(64)) and updated using relaxed C11 atomic operations (atomic_fetch_add_explicit and CAS loop for max_proxy_overhead_ns), allowing forked Forward Proxy and Reverse Proxy processes to increment the same counters with zero mutex overhead.
GET /metrics JSON Output
When enabled (default true on 0.0.0.0:9100), vsi_metrics_start_server() spawns a detached thread serving GET /metrics (other paths return 404 Not Found):
{ "requests": { "total": 128, "active": 2, "failed": 1 }, "traffic_bytes": { "inbound": 65536, "outbound": 2097152 }, "latency_us": { "avg_total": 1845.25, "avg_upstream_wait": 1712.10, "avg_proxy_overhead": 133.15, "max_proxy_overhead": 490.00 }}To restrict metrics to localhost or disable the endpoint entirely, set "listen_ip": "127.0.0.1" or "enabled": false under the "metrics" object in config.json.