Skip to content

Add number_with_delimiter helper to format numbers to be more readable#25

Open
okapusta wants to merge 3 commits intoappoptics:masterfrom
okapusta:number-with-delimiter
Open

Add number_with_delimiter helper to format numbers to be more readable#25
okapusta wants to merge 3 commits intoappoptics:masterfrom
okapusta:number-with-delimiter

Conversation

@okapusta
Copy link

@okapusta okapusta commented Jul 2, 2019

When an Alert notification is sent it looks for example like this:

environment=production
metric `kafka.buzzard.delta` was above threshold 20000000 over 300 seconds with value 22469048 recorded at Tue, Apr  2 2019 at 02:45:00 UTC

If you look at the numbers it's really hard to figure out if 20000000 is 20,000,000 or 2,000,000 or 200,000,000. Added number_with_delimiter helper known from Rails to make numbers more readable.

@okapusta okapusta force-pushed the number-with-delimiter branch from c8e941a to cb10e43 Compare July 4, 2019 08:11
@okapusta okapusta force-pushed the number-with-delimiter branch from cb10e43 to 1141a82 Compare July 5, 2019 07:51
Copy link
Contributor

@akahn akahn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love the idea of this but I don't understand why the implementation is specific to Slack. Also, I think passing the service from the service class to the output formatting module breaks the encapsulation of the service. A better object oriented design, in my view, would be to have a method on AppOptics::Services::Service that outputs the measurement, optionally overridden in a service-specific way.

actual_value = measurement[:value]
formatted_value = AppOptics::Services::Numbers.format_for_threshold(threshold_value, actual_value)
"#{condition[:type]} threshold #{threshold(condition,measurement)} with value #{formatted_value}"
if service == AppOptics::Services::Service::Slack::SERVICE_NAME
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason that only Slack should benefit from this change?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't find the conversation right now but it was pointed out that change in webhooks, for example, might break something for the customers so it was decided that we should only change Slack output.

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.

2 participants