-
Notifications
You must be signed in to change notification settings - Fork 107
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
feat: circuit status now contains a rolling window #34
Conversation
lib/status.js
Outdated
} | ||
|
||
const stats = () => ({ |
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.
cache hits/misses will be part of stats [right?]
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.
I will merge from master before pushing my changes. There will be conflicts in this file, but I will deal with them.
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.
Looking good so far 👍
1 similar comment
The rolling stats window is configurable in both total time sampled, and how many snapshots, or buckets, within that time frame. The new options that can be applied to a circuit breaker are `rollingCountTimeout` and `rollingCountBuckets`, which default to 10000 and 10, respectively. So by default, the window is a statistical view over the last 10 seconds, consisting of 10 one second snapshots. The current circuit breaker status api has not been modified directly, however the expected results are different. For example, you can still do this: ```js console.log(`Failure count: ${circuit.status.failures}`); ``` But that count will consist only of the number of failures within the current snapshot. To obtain stats for the entire window, use the `window` property. ```js const stats = circuit.status.window; ``` This will give you an array containing the statistical sampling for the entire window. So, given the defaults noted above, by default this will be a ten element array, with each element containing an object with sample data that looks something like this: ```js { failures: 11, fallbacks: 9, successes: 3491, rejects: 2, fires: 3493, timeouts: 0, start: 1488999002013 } ```
Users can add a listener to a circuit's status object, which gets called with the most recent status each time a new snapshot is created. Allows users to maintain cumulative stats if they want to.
972b830
to
1434c0f
Compare
This is an ongoing PR, do not merge yet
The rolling stats window is configurable in both total time sampled, and
how many snapshots, or buckets, within that time frame.
The new options that can be applied to a circuit breaker are
rollingCountTimeout
androllingCountBuckets
, which default to 10000and 10, respectively. So by default, the window is a statistical view
over the last 10 seconds, consisting of 10 one second snapshots.
The current circuit breaker status api has not been modified directly,
however the expected results are different. For example, you can still
do this:
But that count will consist only of the number of failures within the
current snapshot.
To obtain stats for the entire window, use the
window
property.This will give you an array containing the statistical sampling for the
entire window. So, given the defaults noted above, by default this will
be a ten element array, with each element containing an object with
sample data that looks something like this: