Add read_buffer_size option to statsd input (#4598)

This commit is contained in:
Daniel Nelson 2018-08-27 14:47:04 -07:00 committed by GitHub
parent 61e5d500ba
commit e2b1a6bc89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View File

@ -58,6 +58,10 @@
## calculation of percentiles. Raising this limit increases the accuracy ## calculation of percentiles. Raising this limit increases the accuracy
## of percentiles but also increases the memory usage and cpu time. ## of percentiles but also increases the memory usage and cpu time.
percentile_limit = 1000 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 ### Description

View File

@ -76,6 +76,8 @@ type Statsd struct {
// see https://github.com/influxdata/telegraf/pull/992 // see https://github.com/influxdata/telegraf/pull/992
UDPPacketSize int `toml:"udp_packet_size"` UDPPacketSize int `toml:"udp_packet_size"`
ReadBufferSize int `toml:"read_buffer_size"`
sync.Mutex sync.Mutex
// Lock for preventing a data race during resource cleanup // Lock for preventing a data race during resource cleanup
cleanup sync.Mutex cleanup sync.Mutex
@ -411,6 +413,10 @@ func (s *Statsd) udpListen() error {
} }
log.Println("I! Statsd UDP listener listening on: ", s.UDPlistener.LocalAddr().String()) 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) buf := make([]byte, UDP_MAX_PACKET_SIZE)
for { for {
select { select {