quipo / statsd

Golang StatsD client
MIT License
164 stars 51 forks source link

Periodic reconnect to avoid stale UDP connections #51

Open Jonnymcc opened 6 years ago

Jonnymcc commented 6 years ago

What? Allows the client to periodically reconnect to the server.

client := NewStatsdClient(udpAddr.String(), prefix)
client.reconnect = true

Why? We are using this library within Kubernetes and when our statsd servers get recreated (within Kubernetes) a connection to an old service endpoint results in metrics being emitted via UDP and going nowhere. We believe this is due to conntrack keeping the route open because there is at least one client that is connected to it (the app that implements this library).