ar-io/ar-io-node

refactor(metrics): consolidate metric definitions into metrics.ts

Closed this issue · 0 comments

Currently Prometheus metrics are mostly defined in the constructors of the classes that use them. This was done to keep metrics definitions close to the code that uses them and so that a different metrics registry could be at test time is desired. In practice this has proved to be more cumbersome than helpful. Tests have to work around metrics having already been defined if objects are initialized more than once. It's also inconvenient to jump around the code base to track down the complete list of metrics. As such, I suggest we define all metrics in a single metrics.ts, export them, and reference them as globals elsewhere when needed.