-
- Downloads
prometheus: Avoid duplicated metrics registration
Praefect uses prometheus to export metrics from inside. It relies on the defaults from the prometheus library to gather set of metrics and register a new metrics. Because of it the new metrics got registered on the DefaultRegisterer - a global pre-configured registerer. Because of that we can't call 'run' function multiple times (for testing purposes) as it results to the metrics registration error. To omit that problem the 'run' function extended with prometheus.Registerer parameter that is used to register praefect custom metrics. The production code still uses the same DefaultRegisterer as it was before. And the test code creates a new instance of the registerer for each 'run' invocation, so there are no more duplicates.
Showing
- cmd/praefect/main.go 8 additions, 8 deletionscmd/praefect/main.go
- cmd/praefect/subcmd_list_untracked_repositories_test.go 2 additions, 1 deletioncmd/praefect/subcmd_list_untracked_repositories_test.go
- cmd/praefect/subcmd_remove_repository_test.go 2 additions, 1 deletioncmd/praefect/subcmd_remove_repository_test.go
- internal/praefect/metrics/prometheus.go 6 additions, 6 deletionsinternal/praefect/metrics/prometheus.go