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

String metric values are not rejected, but do not work. #106

Closed
bobtfish opened this issue Dec 14, 2021 · 1 comment
Closed

String metric values are not rejected, but do not work. #106

bobtfish opened this issue Dec 14, 2021 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@bobtfish
Copy link

I've found that it's possible to accidentally call putMetric with a string value, and this value is saved and outputted to cloudwatch as a quoted string, which of course doesn't work as a metric.

The typescript code has type checking that putMetric is called with a number, but this doesn't help if you're writing Javascript, and of course doesn't help at runtime.

It can be subtle and hard to spot what is going on, as if you accidentally push a numeric metric that is typed as a string, then it just ends up quoted in the generated JSON, which is hard to spot until it doesn't work, e.g. putMetric('someKey', '200').

The library should explicitly convert all values it's sent to Number() so that if someone accidentally sends string values then they'll be dealt with correctly if they can be easily converted to numeric.

@markkuhn
Copy link
Contributor

#135 adds validation for metrics

@markkuhn markkuhn self-assigned this Sep 15, 2022
@markkuhn markkuhn added the enhancement New feature or request label Sep 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants