go-libp2p
go-libp2p copied to clipboard
rcmgr: expose resource limits to Prometheus
Implements TODO to report system limits to Prometheus metrics. Previously, only resource usage was tracked in metrics, but the configured limits were not exposed, making it difficult to understand when resources were approaching their limits.
Changes:
- Add 'libp2p_rcmgr_limit' gauge metric with scope and resource labels
- Implement StatsTraceReporter.ReportSystemLimits() to export limits
- Report system and transient scope limits during initialization
- Export limits for memory, connections, streams, and file descriptors
- Add comprehensive tests for limits metrics
The new metric allows monitoring:
- Configured resource limits vs current usage
- Resource utilization percentages in dashboards
- Alert thresholds based on limit proximity
Example metrics exposed:
- libp2p_rcmgr_limit{scope="system",resource="memory"}
- libp2p_rcmgr_limit{scope="system",resource="conns"}
- libp2p_rcmgr_limit{scope="transient",resource="streams"}