segmentio / stats

Go package for abstracting stats collection
https://godoc.org/github.com/segmentio/stats
MIT License
208 stars 32 forks source link

Add Datadog UDS support #123

Closed sebcante closed 2 weeks ago

sebcante commented 4 years ago

Goal

Adds Support for connecting to datadog via Unix Domain socket (UDS) instead of UDP

Why

UDS could be useful :

* Bypassing the networking stack brings a significant performance improvement for high traffic.
* While UDP has no error handling, UDS allows the Agent to detect dropped packets and connection errors, while still allowing a non-blocking use.
* DogStatsD can detect the container from which metrics originated and tag those metrics accordingly.

Taken from https://docs.datadoghq.com/developers/dogstatsd/unix_socket/?tab=host ^

Usage to connect to unixgram socket instead of udp

client := NewClient("unixgram:///dir/filename.sock") // unixgram

instead of

client := NewClient("localhost:8125") // udp

What

I hope this PR could be useful, completely open for feedbacks to align this PR to the conventions/style of this library. I gave it a first shot. I inlined comments/questions

Credit

Datadog official client lib , i inspired a lot the code from it.

tony-assembly commented 3 years ago

is it possible to get someone to review this at all?

sebcante commented 3 years ago

We have been using UDS support in production (this PR) for more than 6 months at mx51 it definitely helped us to better manage datadog agent maintenance and go apps reconnecting automatically to it. Something that UDP caused us trouble in the past. @achille-roussel any thoughts if this contribution could be merged ?

kevinburkesegment commented 2 weeks ago

Thank you for this! We just merged this upstream and it is part of the v5.1.0 release.