nspcc-dev / neo-go

Go Node and SDK for the Neo blockchain
MIT License
123 stars 79 forks source link

Provide RegisterMetrics() functions in packages that expose metrics #3698

Open roman-khimov opened 7 hours ago

roman-khimov commented 7 hours ago

Is your feature request related to a problem? Please describe.

I'm always frustrated when I realize that we always register our metrics in init() in every package that exposes them. On one hand it's convenient, but on the other some package users may want to opt out from our metrics.

Describe the solution you'd like

Keep metrics package-level, but expose some RegisterMetrics() function (accepting a registry?) that will do metric registration. Call it in cli/server and everywhere else needed. Keep in mind that variables still need to be initialized properly in every package.

Describe alternatives you've considered

Keep things as is, works too.

Additional context

https://github.com/nspcc-dev/neofs-node/pull/3016

3682