siimon / prom-client

Prometheus client for node.js
Apache License 2.0
3.15k stars 378 forks source link

Improve error message on labels #633

Closed leftieFriele closed 5 months ago

leftieFriele commented 5 months ago

This fix ensures consumers of the library get more insights into which labels are causing an error to occur.

With the new error message it is easier for a developer to debug what happened in the case where you accidentally pass in a bad argument.

If getLabels gets called like this:

getLabels(['label1', 'label2'], ['arg1']);

it used to throw...

Error: Invalid number of arguments
    at exports.getLabels 

now it throws this:

Error: Invalid number of arguments: "arg1" for label names: "label1,label2".
    at exports.getLabels 
leftieFriele commented 5 months ago

thanks! just a quick suggestion, happy to merge after that 🙂

👍 I didn't squash it on the branch, so squash and merge. thanks for the quick reply ❤️

stalet commented 5 months ago

When is this scheduled to be released ?

SimenB commented 5 months ago

I'm currently away at a festival, but I can make a release on Sunday (unless @zbjornson gets to it before me)

SimenB commented 5 months ago

had some time this morning, so published in https://github.com/siimon/prom-client/releases/tag/v15.1.3