go-libp2p icon indicating copy to clipboard operation
go-libp2p copied to clipboard

rcmgr: expose resource limits to Prometheus

Open sneaxhuh opened this issue 4 weeks ago • 0 comments

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"}

sneaxhuh avatar Nov 30 '25 09:11 sneaxhuh