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

Drop non-numeric metric values #28

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rkallos
Copy link
Owner

@rkallos rkallos commented Jan 6, 2025

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.

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.
@rkallos rkallos force-pushed the fix/drop-non-numeric-values branch from 363787e to f627e97 Compare January 31, 2025 19:01
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.

1 participant