Skip to content

Commit

Permalink
Make reregistration of prom metrics resilient to v0 + v2 (#584)
Browse files Browse the repository at this point in the history
  • Loading branch information
kylelemons committed Nov 4, 2022
1 parent c06ebf3 commit 5fc5cda
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions internal/admin/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ func init() {

Mux.Handle("/metrics", promhttp.Handler())

// Unregister the default GoCollector.
prometheus.Unregister(collectors.NewGoCollector())

// Register GoCollector with baseplate defaults.
prometheus.MustRegister(collectors.NewGoCollector(baseplateGoCollectors))
// Unregister the default GoCollector, and reregister with baseplate defaults
if prometheus.Unregister(collectors.NewGoCollector()) {
// Only register a new collector if we unregistered one to avoid double-reregistration
prometheus.MustRegister(collectors.NewGoCollector(baseplateGoCollectors))
}
}

func Serve() error {
Expand Down

0 comments on commit 5fc5cda

Please sign in to comment.