prom-client
prom-client copied to clipboard
Breaking changes v13 - labels as arguments considered as object
Hi, When I'm setting labels as arguments and the first argument is an array:
someCounter.labels(arr, string1, string2)
it is considered as an object and throws Added label "0" is not included in initial labelset
.
I found that there is a condition if (typeof args[0] === 'object')
but it might also check that it is not an array.
I've upgraded from v12 to v14 (but it happens in v13 also).
Thanks
I don't think I understand what the use case and expectation are here. metric.labels()
is supposed to accept an object of key-value pairs, or a series of strings that match up one-to-one with the metric's label names. An array shouldn't be passed here. Can you clarify please?
Yes.
When we used this library in v12 we could pass just arguments such as metric.labels(arg1, arg2, arg3)
.
One of the args was an array: metrics.labels(arr, arg2, arg3)
.
After upgrading to v13/14 the ability to pass an object was added also and as a result, the code above was broken.
The new code checks if the type of the first argument is an object but it returns true for array also.