1
0
Fork 0

Logger and Leaks

This commit is contained in:
Ludovic Fernandez 2018-02-12 17:24:03 +01:00 committed by Traefiker Bot
parent 91fa727c74
commit 38a4c80995
11 changed files with 108 additions and 82 deletions

View file

@ -126,7 +126,7 @@ func (c *CircuitBreaker) activateFallback(w http.ResponseWriter, req *http.Reque
c.m.Lock()
defer c.m.Unlock()
log.Infof("%v is in error state", c)
log.Warnf("%v is in error state", c)
switch c.state {
case stateStandby:
@ -197,7 +197,7 @@ func (c *CircuitBreaker) exec(s SideEffect) {
}
func (c *CircuitBreaker) setState(new cbState, until time.Time) {
log.Infof("%v setting state to %v, until %v", c, new, until)
log.Debugf("%v setting state to %v, until %v", c, new, until)
c.state = new
c.until = until
switch new {
@ -230,7 +230,7 @@ func (c *CircuitBreaker) checkAndSet() {
c.lastCheck = c.clock.UtcNow().Add(c.checkPeriod)
if c.state == stateTripped {
log.Infof("%v skip set tripped", c)
log.Debugf("%v skip set tripped", c)
return
}

View file

@ -73,6 +73,6 @@ func (w *WebhookSideEffect) Exec() error {
if err != nil {
return err
}
log.Infof("%v got response: (%s): %s", w, re.Status, string(body))
log.Debugf("%v got response: (%s): %s", w, re.Status, string(body))
return nil
}

View file

@ -34,17 +34,17 @@ func (r *ratioController) String() string {
}
func (r *ratioController) allowRequest() bool {
log.Infof("%v", r)
log.Debugf("%v", r)
t := r.targetRatio()
// This condition answers the question - would we satisfy the target ratio if we allow this request?
e := r.computeRatio(r.allowed+1, r.denied)
if e < t {
r.allowed++
log.Infof("%v allowed", r)
log.Debugf("%v allowed", r)
return true
}
r.denied++
log.Infof("%v denied", r)
log.Debugf("%v denied", r)
return false
}