Skip to content

Commit

Permalink
Make mock sink thread safe (#23) (#24)
Browse files Browse the repository at this point in the history
* race-safe

* remove nl
  • Loading branch information
parkwherever authored and rodaine committed Mar 8, 2018
1 parent 9c23c53 commit 26800ee
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions tcp_sink.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ func (s *tcpStatsdSink) FlushCounter(name string, value uint64) {
default:
new := atomic.AddUint64(&s.droppedCounters, 1)
if new%logOnEveryNDropped == 0 {
logger.Errorf(
"statsd channel full, discarding counter flush value, dropped so far %v",
new)
logger.WithField("total_dropped_records", new).
Error("statsd channel full, discarding counter flush value")
}
}

Expand All @@ -51,9 +50,8 @@ func (s *tcpStatsdSink) FlushGauge(name string, value uint64) {
default:
new := atomic.AddUint64(&s.droppedGauges, 1)
if new%logOnEveryNDropped == 0 {
logger.Errorf(
"statsd channel full, discarding gauge flush value, dropped so far %v",
new)
logger.WithField("total_dropped_records", new).
Error("statsd channel full, discarding guage flush value")
}
}
}
Expand All @@ -64,9 +62,8 @@ func (s *tcpStatsdSink) FlushTimer(name string, value float64) {
default:
new := atomic.AddUint64(&s.droppedTimers, 1)
if new%logOnEveryNDropped == 0 {
logger.Errorf(
"statsd channel full, discarding timer flush value, dropped so far %v",
new)
logger.WithField("total_dropped_records", new).
Error("statsd channel full, discarding timer flush value")
}
}
}
Expand Down

0 comments on commit 26800ee

Please sign in to comment.