sui
sui copied to clipboard
[Authority] Track size of compiled module cache
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
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)
(P.S. I'd like to take credit for the idea, but it was @gdanezis' ;) )
noob q: when is ModuleCacheGauge.collect
called ?
It's called by the PrometheusRegistry before it's about to send the metrics off.