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

Add a way to print resource limits and current consumption

Open 2color opened this issue 9 months ago • 4 comments
trafficstars

What

It would be useful to have a way to inspect resource manager limits and current consumption in a go-libp2p host. This could help with debugging and monitoring.

How I currently do it

rm := h.Network().ResourceManager()
rm.ViewSystem(
	func(rs network.ResourceScope) error {
		fmt.Printf("stats: %+v\n", rs.Stat())
		if r, ok := rs.(interface{ Limit() rcmgr.Limit }); ok {
			fmt.Printf("limits: %+v\n", r.Limit())
		}
		return nil
	},
)

2color avatar Feb 14 '25 14:02 2color