Skip to content

Commit

Permalink
Merge pull request #196 from xmidt-org/reduce-logging
Browse files Browse the repository at this point in the history
removed log statements
  • Loading branch information
schmidtw authored Apr 17, 2020
2 parents 74f91d7 + 0464f4c commit 8c26728
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
- pared down logging, especially debugging logs [#196](https://github.com/xmidt-org/caduceus/pull/196)

## [v0.2.6]
- reduced time from when cutoff is sent to when queue is emptied
Expand Down
24 changes: 5 additions & 19 deletions outboundSender.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,17 +367,13 @@ func (obs *CaduceusOutboundSender) Queue(msg *wrp.Message) {

now := time.Now()

var debugLog = logging.Debug(obs.logger)
if false == obs.isValidTimeWindow(now, dropUntil, deliverUntil) {
return
}

for _, eventRegex := range events {
if false == eventRegex.MatchString(strings.TrimPrefix(msg.Destination, "event:")) {
debugLog.Log(logging.MessageKey(),
fmt.Sprintf("Regex did not match. got != expected: '%s' != '%s'\n",
msg.Destination, eventRegex.String()))

// regex didn't match; don't do anything
continue
}

Expand Down Expand Up @@ -416,7 +412,6 @@ func (obs *CaduceusOutboundSender) Queue(msg *wrp.Message) {
select {
case obs.queue.Load().(chan *wrp.Message) <- msg:
obs.queueDepthGauge.Add(1.0)
debugLog.Log(logging.MessageKey(), "WRP Sent to obs queue", "url", obs.id)
default:
obs.queueOverflow()
obs.droppedQueueFullCounter.Add(1.0)
Expand All @@ -426,18 +421,14 @@ func (obs *CaduceusOutboundSender) Queue(msg *wrp.Message) {
}

func (obs *CaduceusOutboundSender) isValidTimeWindow(now, dropUntil, deliverUntil time.Time) bool {
var debugLog = logging.Debug(obs.logger)

if false == now.After(dropUntil) || !obs.queueEmpty {
debugLog.Log(logging.MessageKey(), "Client has been cut off",
"now", now, "before", deliverUntil, "after", dropUntil)
// client was cut off
obs.droppedCutoffCounter.Add(1.0)
return false
}

if false == now.Before(deliverUntil) {
debugLog.Log(logging.MessageKey(), "Outside delivery window",
"now", now, "before", deliverUntil, "after", dropUntil)
// outside delivery window
obs.droppedExpiredBeforeQueueCounter.Add(1.0)
return false
}
Expand Down Expand Up @@ -631,12 +622,10 @@ func (obs *CaduceusOutboundSender) queueOverflow() {
obs.mutex.Unlock()

var (
debugLog = logging.Debug(obs.logger)
errorLog = logging.Error(obs.logger)
)

obs.cutOffCounter.Add(1.0)
debugLog.Log(logging.MessageKey(), "Queue overflowed", "url", obs.id)

obs.Empty()

Expand All @@ -646,14 +635,13 @@ func (obs *CaduceusOutboundSender) queueOverflow() {
"for", obs.id, logging.ErrorKey(), err)
return
}
errorLog.Log(logging.MessageKey(), "Cut-off notification", "failureMessage", msg, "for", obs.id)

// Send a "you've been cut off" warning message
// if no URL to send cut off notification to, do nothing
if "" == failureURL {
errorLog.Log(logging.MessageKey(), "No cut-off notification URL specified", "for", obs.id)
return
}

// Send a "you've been cut off" warning message
payload := bytes.NewReader(msg)
req, err := http.NewRequest("POST", failureURL, payload)
if nil != err {
Expand Down Expand Up @@ -689,6 +677,4 @@ func (obs *CaduceusOutboundSender) queueOverflow() {
}

// Success
logging.Info(obs.logger).Log("Able to send cut-off notification", "url", failureURL,
"status", resp.Status)
}

0 comments on commit 8c26728

Please sign in to comment.