Skip to content

Commit

Permalink
statsd: do not log every dropped metric.
Browse files Browse the repository at this point in the history
closes #1340
  • Loading branch information
sparrc committed Jun 10, 2016
1 parent ea2521b commit ff3f576
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions plugins/inputs/statsd/statsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ const (
defaultSeparator = "_"
)

var dropwarn = "ERROR: Message queue full. Discarding line [%s] " +
var dropwarn = "ERROR: statsd message queue full. " +
"We have dropped %d messages so far. " +
"You may want to increase allowed_pending_messages in the config\n"

var prevInstance *Statsd
Expand Down Expand Up @@ -65,6 +66,8 @@ type Statsd struct {

sync.Mutex
wg sync.WaitGroup
// drops tracks the number of dropped metrics.
drops int

// Channel for all incoming statsd packets
in chan []byte
Expand Down Expand Up @@ -291,7 +294,10 @@ func (s *Statsd) udpListen() error {
select {
case s.in <- bufCopy:
default:
log.Printf(dropwarn, string(buf[:n]))
s.drops++
if s.drops == 1 || s.drops%s.AllowedPendingMessages == 0 {
log.Printf(dropwarn, s.drops)
}
}
}
}
Expand Down

0 comments on commit ff3f576

Please sign in to comment.