3scale / apisonator

Red Hat 3scale API Management Apisonator backend
https://3scale.net
Apache License 2.0
35 stars 27 forks source link

Optimize alerts detection #287

Closed davidor closed 3 years ago

davidor commented 3 years ago

Currently, the code is loading all the usage limits of a plan and the current usages for those limits on every report job.

This PR introduces a new class (UsageChecked) that allows us to do just once and then, no longer do it for the same application until: 1) An alert expires (24h passed since it was triggered) and can be raised again. 2) A new alert bin is enabled for the service.

With this, on every report job we just need to check the limits and usages of the metrics increased in the job. This should have a noticeable impact for users with many usage limits defined.

davidor commented 3 years ago

@unleashed I added a new commit with the tests that were missing. It's the last commit. I also added a Memoizer.clear call here: https://github.com/3scale/apisonator/pull/287/files#diff-b176f67b39cc7bd8b50fe54aa2a4de9cf404809e691aab4a2199d6aa8dc10011R84

unleashed commented 3 years ago

bors delegate+

bors[bot] commented 3 years ago

:v: davidor can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

davidor commented 3 years ago

bors r+

bors[bot] commented 3 years ago

Build succeeded: