While working I was facing an error performing some testing because of no valid metric name and no valid label names.
I decided to dive into the code to get more output in the error.
The changes are the following:
Show the invalid name in the error.
Original:
Invalid metric name
Improvement:
Invalid metric name: ${this.name}
Show the invalid label names instead of a generic message
Change the check of every to filter by the regex, and return the invalid labels. So it returns an array instead of a boolean
Check if the array length is higher than 0, then the error is thrown.
Original:
throw new Error('Invalid label name');
Improvement:
Invalid metric name: ${this.name}
The changes have been tested by unit testing inside the gauge test case. It could be in any other metric that inherits from the metric abstract class.
While working I was facing an error performing some testing because of no valid metric name and no valid label names. I decided to dive into the code to get more output in the error.
The changes are the following:
Invalid metric name
Invalid metric name: ${this.name}
Show the invalid label names instead of a generic message
invalid
labels. So it returns an array instead of a booleanthrow new Error('Invalid label name');
Invalid metric name: ${this.name}
The changes have been tested by unit testing inside the gauge test case. It could be in any other metric that inherits from the metric abstract class.