Skip to content

Commit

Permalink
Merge pull request #211 from andrewstuart/variadic-register
Browse files Browse the repository at this point in the history
Add *RegisterAll functions with variadic args
  • Loading branch information
beorn7 authored Jul 11, 2016
2 parents 9f1ed1e + e63e6e3 commit 28be158
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions prometheus/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,13 @@ func Register(m Collector) error {
}

// MustRegister works like Register but panics where Register would have
// returned an error.
func MustRegister(m Collector) {
err := Register(m)
if err != nil {
panic(err)
// returned an error. MustRegister is also Variadic, where Register only
// accepts a single Collector to register.
func MustRegister(m ...Collector) {
for i := range m {
if err := Register(m[i]); err != nil {
panic(err)
}
}
}

Expand Down

0 comments on commit 28be158

Please sign in to comment.