Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With this change, Peep.EventHandler will not call Peep.insert_metric/4 with a non-numeric value.
This change also unifies the behavior of Peep.Storage.{Striped, ETS}.insert_metric/4 such that, for all metric types, inserting a non-numeric metric value raises an ArgumentError. Previously, storing a non-numeric value in a Metrics.LastValue was allowed, while storing a non-numeric value for other metrics (except Metrics.Counter) all coincidentally raised ArgumentError.
It may seem redundant to make both of these changes, since avoiding all calls to Peep.insert_metric/4 should transitively prevent Peep.Storage..insert_metric/4 from being called with a bad argument. I can't argue that, but I like the behavior of raising an exception in Peep.Storage..insert_metric/4, since that should produce a 'loud' error when running Peep's tests. However, this does come with the slight drawback of calling Kernel.is_number/1 twice when storing a value associated with a Metrics.LastValue.