Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add read_buffer_size option to statsd input #4598

Merged
merged 1 commit into from
Aug 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions plugins/inputs/statsd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
## calculation of percentiles. Raising this limit increases the accuracy
## of percentiles but also increases the memory usage and cpu time.
percentile_limit = 1000

## Maximum socket buffer size in bytes, once the buffer fills up, metrics
## will start dropping. Defaults to the OS default.
# read_buffer_size = 65535
```

### Description
Expand Down
6 changes: 6 additions & 0 deletions plugins/inputs/statsd/statsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ type Statsd struct {
// see https://github.com/influxdata/telegraf/pull/992
UDPPacketSize int `toml:"udp_packet_size"`

ReadBufferSize int `toml:"read_buffer_size"`

sync.Mutex
// Lock for preventing a data race during resource cleanup
cleanup sync.Mutex
Expand Down Expand Up @@ -411,6 +413,10 @@ func (s *Statsd) udpListen() error {
}
log.Println("I! Statsd UDP listener listening on: ", s.UDPlistener.LocalAddr().String())

if s.ReadBufferSize > 0 {
s.UDPlistener.SetReadBuffer(s.ReadBufferSize)
}

buf := make([]byte, UDP_MAX_PACKET_SIZE)
for {
select {
Expand Down