-
Notifications
You must be signed in to change notification settings - Fork 13
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
[Feature] Time error groupping #99
Open
joaquinco
wants to merge
2
commits into
wyeworks:master
Choose a base branch
from
joaquinco:feature/time-grouping
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,34 +91,38 @@ defmodule YourApp.Router do | |
options: # ... | ||
] | ||
] | ||
|
||
#... | ||
end | ||
``` | ||
|
||
## Notification Trigger | ||
## Throttling notifications | ||
|
||
By default, `BoomNotifier` will send a notification every time an exception is | ||
raised. | ||
|
||
However, there are different strategies to decide when to send the | ||
notifications using the `:notification_trigger` option with one of the | ||
following values: `:always` and `:exponential`. | ||
|
||
### Always | ||
There are two throttling mechanisms you can use to reduce notification rate. Counting | ||
based and time based throttling. The former allows notifications to be delivered | ||
on exponential error counting and the latter based on time throttling, that is | ||
if a predefined amount of time has passed from the last error. | ||
|
||
This option is the default one. It will trigger a notification for every | ||
exception. | ||
### Count Based Throttle | ||
|
||
```elixir | ||
defmodule YourApp.Router do | ||
use Phoenix.Router | ||
|
||
use BoomNotifier, | ||
notification_trigger: :always, | ||
notifiers: [ | ||
# ... | ||
] | ||
# ... | ||
], | ||
groupping: :count, | ||
count: :exponential, | ||
time_limit: :timer.minutes(30) | ||
end | ||
``` | ||
|
||
### Exponential | ||
#### Exponential | ||
|
||
It uses a formula of `log2(errors_count)` to determine whether to send a | ||
notification, based on the accumulated error count for each specific | ||
|
@@ -132,7 +136,7 @@ defmodule YourApp.Router do | |
use Phoenix.Router | ||
|
||
use BoomNotifier, | ||
notification_trigger: :exponential, | ||
count: :exponential, | ||
notifiers: [ | ||
# ... | ||
] | ||
|
@@ -143,32 +147,49 @@ defmodule YourApp.Router do | |
use Phoenix.Router | ||
|
||
use BoomNotifier, | ||
notification_trigger: [exponential: [limit: 100]] | ||
count: [exponential: [limit: 100]] | ||
notifiers: [ | ||
# ... | ||
] | ||
``` | ||
|
||
### Notification trigger time limit | ||
### Time Based Throttle | ||
|
||
```elixir | ||
defmodule YourApp.Router do | ||
use Phoenix.Router | ||
|
||
use BoomNotifier, | ||
notifiers: [ | ||
# ... | ||
], | ||
groupping: :time, | ||
throttle: :timer.minutes(1) | ||
end | ||
``` | ||
|
||
### Time Limit | ||
|
||
If you've defined a triggering strategy which holds off notification delivering you can define a time limit value | ||
which will be used to deliver the notification after a time limit milliseconds have passed from the last error. The | ||
time counter is reset on new errors and only applies for cases where notifications are not sent. | ||
Both groupping strategies allow you to define a time limit that tells boom to deliver a notification if the amount | ||
of time has passed from the last time a notification was sent or error groupping started. | ||
|
||
If specified, a notification will be triggered even though the groupping strategy does not met the criteria. For | ||
time based throttling this is usefull if errors keep appearing before the throttle time and for count based throttle | ||
to reset (and notify) the grupping after a certain time period. | ||
|
||
```elixir | ||
defmodule YourApp.Router do | ||
use Phoenix.Router | ||
|
||
use BoomNotifier, | ||
notification_trigger: [:exponential], | ||
count: [:exponential], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Even though I like this name better I'd rather not to introduce api changes in this pull request I think before releasing |
||
time_limit: :timer.minutes(30), | ||
notifier: CustomNotifier | ||
|
||
# ... | ||
end | ||
``` | ||
|
||
|
||
## Custom data or Metadata | ||
|
||
By default, `BoomNotifier` will **not** include any custom data from your | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it makes sense to have
:time
as othernotification_trigger
strategy instead of adding a new option? And maybe we could use the same time limit key we use for the others