-
Notifications
You must be signed in to change notification settings - Fork 106
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
WIP - first pass at percentiles #55
Conversation
c8491a5
to
4c25510
Compare
b6dd2c1
to
5aa78b0
Compare
@lance @helio-frota mind just taking a quick look at this if you guys have a chance, just to see if the code looks legit |
5aa78b0
to
e28e516
Compare
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.
This looks good except for a few nits. I think there should also be some tests. :)
lib/circuit.js
Outdated
@@ -275,8 +282,9 @@ class CircuitBreaker extends EventEmitter { | |||
* Emitted when the circuit breaker action takes longer than `options.timeout` | |||
* @event CircuitBreaker#timeout | |||
*/ | |||
this.emit('timeout', error); | |||
resolve(fallback(this, error, args) || fail(this, error, args)); | |||
const latencyEndTime = Date.now() - latencyStartTime; |
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.
Nit: How about just naming this latency
, since it's not really the end time, but the actual difference.
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.
yes, that makes sense
lib/circuit.js
Outdated
.catch((error) => | ||
handleError(error, this, timeout, args, resolve, reject)); | ||
.catch((error) => { | ||
const latencyEndTime = Date.now() - latencyStartTime; |
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.
Nit: Same as comment above re: the name.
lib/circuit.js
Outdated
if (fb) resolve(fb); | ||
else reject(error); | ||
} | ||
|
||
function fallback (circuit, err, args) { | ||
function fallback (circuit, err, args, latencyEndTime) { |
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.
Is latencyEndTime
used here? I don't really follow.
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.
ah, doesn't look like it is, i think i put it in there because i had a thought about storing the latency during the fallback event, but i don't think we need to do that, i'll remove it for now
}); | ||
|
||
if (this.rollingPercentilesEnabled) { | ||
acc.latencyTimes.push.apply(acc.latencyTimes, val.latencyTimes || []); |
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.
Why not just call push()
? What's the need for apply
?
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.
we need to concatenate the values in that latencyTimes
so if we just did push, then we would get something like this: [ [1], [2], [3], [4] ]
instead of [1,2,3,4]
. would be nice if we could use the spread syntax here, but i don't think it goes back to node 4
1 similar comment
Hmm - I think ultimately we probably want to measure fallback latency as
well. Maybe we can add that as another issue.
…On Mon, Apr 17, 2017 at 3:54 PM Lucas Holmquist ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In lib/circuit.js
<#55 (comment)>:
> if (fb) resolve(fb);
else reject(error);
}
-function fallback (circuit, err, args) {
+function fallback (circuit, err, args, latencyEndTime) {
ah, doesn't look like it is, i think i put it in there because i had a
thought about storing the latency during the fallback event, but i don't
think we need to do that, i'll remove it for now
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#55 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAA-UAgc0FTzq0DD8pOOF8AE__6NJiBQks5rw73-gaJpZM4M6lcy>
.
|
22f226b
to
e4f6a8d
Compare
088ea05
to
3130e7c
Compare
a new option has been added: rollingPercentilesEnabled, which defaults to true. If this is false, all latency's and means are -1
e61c7d7
to
ce7b50d
Compare
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'll fix those wording issues in the merge
breaker.fire(1); | ||
}); | ||
|
||
test('Circuit Breaker timeout event emits latency', (t) => { |
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.
This should say "Breaker failure event". And the one below should say "Breaker timeout event" :-)
connects to #38