Skip to content

Instantly share code, notes, and snippets.

@dudo
Created January 12, 2022 18:40
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save dudo/1affcae4825ba4c0635aa3348ad812a1 to your computer and use it in GitHub Desktop.
def step(min: 1, comp: 20)
return 0 if min == comp
(1 - (min - comp).abs / (min - comp).to_f) / 2
end
@dudo
Copy link
Author

dudo commented Jan 12, 2022

I use this in monitors all the time to remove flappy, low volume metrics.

For instance... an error rate monitor might

a = errors count
b = total count
error_percent = a / b
step = (1 - abs(1 - b) / (1 - b)) / 2
error_percent * step

You can compare against the errors or the total in this case.

If b < 1, the step evaluates to 0, otherwise 1.

@dudo
Copy link
Author

dudo commented Apr 19, 2022

Datadog now has cutoff_min which is wayyyyyyy easier to use

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment