labstack / echo-contrib

Echo community contribution
https://echo.labstack.com
MIT License
175 stars 92 forks source link

Use proper variadic arglist in NewPrometheus #60

Closed tdemin closed 1 year ago

tdemin commented 3 years ago

NewPrometheus uses customMetricsList as a single optional argument, panicking on multiple arguments and making function semantics less than obvious (I had to look up the code), while in fact using it as a variadic argument list which is then concatenated with a default set of metrics. This makes NewPrometheus a proper variadic function.

This is a breaking change, as this changes signature of NewPrometheus. To update existing code to the new signature, one can simply append the ... operator to a metrics slice or just remove the slice use altogether.

Before:

p := prometheus.NewPrometheus("subsystemName", nil, []*prometheus.Metric{metric1, metric2})

After:

p := prometheus.NewPrometheus("subsystemName", nil, metric1, metric2)
p := prometheus.NewPrometheus("subsystemName", nil, []*prometheus.Metric{metric1, metric2}...)
aldas commented 1 year ago

This will be closed when #94 gets merged