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}...)
NewPrometheus
usescustomMetricsList
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 makesNewPrometheus
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:
After: