Shopify / statsd-instrument

A StatsD client for Ruby apps. Provides metaprogramming methods to inject StatsD instrumentation into your code.
http://shopify.github.io/statsd-instrument
MIT License
574 stars 97 forks source link

UDS Sink + async UDS sink batched #372

Closed pedro-stanaka closed 2 months ago

pedro-stanaka commented 3 months ago

Summary

Using UDS (Unix Domain Sockets) is one of the main recommendation from Datadog to achieve higher throughput for StatsD traffic. So far, this client did not provide such a sink.

In this PR I am introducing a UDS sink that uses same batching logic from UDP sink.

Follow up improvements

Ended up merging this PR above and squashing the other commits, when reviewing, one can review the commits separately.

Benchmarks

We can see from benchmarks that using larger batches improves client throughput with a considerable margin:

▶ RUBY_YJIT_ENABLE=true ./benchmark/local-udp-throughput                                                                                                                                                                                                                                             
Logs are stored in /var/folders/9v/vqq8s1cd2n53w68813dwjz4c0000gn/T/statsd-instrument-benchmarks
===== UDP sync throughput (5 threads) - total events: 150000 =====
events: 138,061.4/s
===== UDP batched throughput (5 threads) - total events: 150000 =====
events: 734,325.8/s
===== UDS batched with small packet throughput (5 threads) - total events: 150000 =====
events: 1,386,411.3/s
===== UDS batched with jumbo packet throughput (5 threads) - total events: 150000 =====
events: 1,248,824.0/s