sui icon indicating copy to clipboard operation
sui copied to clipboard

[Authority] Track size of compiled module cache

Open amnn opened this issue 2 years ago • 2 comments

New Prometheus collector outputting a gauge metric to track the number of modules in Move's SyncModuleCache.

Test Plan

Will take advice here on the best way to test a new gauge, apart from the usual:

$ cargo simtest
$ cargo nextest run

amnn avatar Nov 11 '22 13:11 amnn

I did notice the existing AuthorityMetric integration, but the reason I opted for this approach was that there isn't an easy to access place where the cache gets updated and I could set the count (the cache is updated on reads and that code lives in the Move repo). By defining a custom Collector API, rather than pushing metric updates as they happen, Prometheus can pull the module cache size directly as it is gathering metrics which avoids a class of bug where the metric lags behind because it has not been set between the last time it changed and the next time Prometheus gathers data.

(I do need to hook up the commented out code though)

amnn avatar Nov 11 '22 23:11 amnn

(P.S. I'd like to take credit for the idea, but it was @gdanezis' ;) )

amnn avatar Nov 14 '22 14:11 amnn

noob q: when is ModuleCacheGauge.collect called ?

longbowlu avatar Nov 18 '22 21:11 longbowlu

It's called by the PrometheusRegistry before it's about to send the metrics off.

amnn avatar Nov 18 '22 22:11 amnn