Skip to content

Commit

Permalink
Log hysterix metrics every 10 seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
kvigen committed Jan 10, 2018
1 parent 2a07f84 commit a3a74f6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions _hardcoded/doer.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,12 @@ func (d *circuitBreakerDoer) init() {

go http.Serve(listener, hystrixStreamHandler)
go func() {
logFrequency := 30 * time.Second
// We log every 10 seconds because the hysterix metrics are on a 10-second
// rolling window. This let's us sum up the hysterix metrics to get fairly
// accurate total numbers (note that this isn't perfect because our timing
// doesn't perfectly match hysterix's, and we also log when the circuit breaker
// status changes)
logFrequency := 10 * time.Second
lastEventSeen := map[string]HystrixSSEEvent{}
lastEventLogTime := map[string]time.Time{}

Expand Down Expand Up @@ -277,7 +282,7 @@ func (d *circuitBreakerDoer) init() {
// log the circuit state if it's either
// (1) the first event we've seen for the circuit or
// (2) the circuit open state has changed or
// (3) 30 seconds have passed since we logged something for the circuit
// (3) 10 seconds have passed since we logged something for the circuit
if !ok {
lastEventLogTime[e.Name] = time.Now()
logEvent(d.logger, e)
Expand Down

0 comments on commit a3a74f6

Please sign in to comment.