As discussed in https://github.com/weaveworks/common/issues/285 - this PR adds ability to manually register metrics, for example, when users restart the Server, but want to reuse existing and already registered metrics.
It does so by introducing a new, alternative constructor function for the server so a user can pick the preferred implementation:
// New makes a new Server. It will panic if the metrics cannot be registered.
func New(cfg Config) (*Server, error) {
metrics := NewServerMetrics(cfg)
metrics.MustRegister(cfg.registererOrDefault())
return newServer(cfg, metrics)
}
// NewWithMetrics makes a new Server using the provided Metrics. It will not attempt to register the metrics,
// the user is responsible for doing so.
func NewWithMetrics(cfg Config, metrics *Metrics) (*Server, error) {
return newServer(cfg, metrics)
}
As discussed in https://github.com/weaveworks/common/issues/285 - this PR adds ability to manually register metrics, for example, when users restart the Server, but want to reuse existing and already registered metrics.
It does so by introducing a new, alternative constructor function for the server so a user can pick the preferred implementation:
Fixes https://github.com/weaveworks/common/issues/285