Skip to content

Commit

Permalink
remove trailing newline to avoid esty statsd log messages
Browse files Browse the repository at this point in the history
fixes #17
  • Loading branch information
dropwhile committed Oct 5, 2015
1 parent 6fa055a commit 73107b3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion statsd/client_buffered_test.go
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"log"
"reflect"
"strings"
"testing"
"time"
)
Expand Down Expand Up @@ -133,6 +134,8 @@ func TestBufferedClientBigPacket(t *testing.T) {
expected = expected + tt.Expected + "\n"
}

expected = strings.TrimSuffix(expected, "\n")

time.Sleep(12 * time.Millisecond)
data := make([]byte, 1024)
_, _, err = l.ReadFrom(data)
Expand Down Expand Up @@ -161,7 +164,7 @@ func TestFlushOnClose(t *testing.T) {
c.Inc("count", int64(1), 1.0)
c.Close()

expected := "test.count:1|c\n"
expected := "test.count:1|c"

data := make([]byte, 1024)
_, _, err = l.ReadFrom(data)
Expand Down
2 changes: 1 addition & 1 deletion statsd/sender_buffered.go
Expand Up @@ -122,7 +122,7 @@ func (s *BufferedSender) run() {

// flush the buffer/send to remove endpoint.
func (s *BufferedSender) flush() (int, error) {
n, err := s.sender.Send(s.buffer.Bytes())
n, err := s.sender.Send(bytes.TrimSuffix(s.buffer.Bytes(), []byte("\n")))
s.buffer.Reset() // clear the buffer
return n, err
}
Expand Down

0 comments on commit 73107b3

Please sign in to comment.