Skip to content

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

Closed
@bobtfish

Description

@bobtfish

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.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions