Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enhance error output on not valid name and label names #613

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

ManuelLG92
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant