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

Refactor BatchedUDPSink to use a SizedQueue #316

Closed casperisfine closed 2 years ago

casperisfine commented 2 years ago

Closes: #315

Ruby's Queue offer cheap thread switching, which improve latency.

We first attempt to insert emitted events into the queue, but if it is full or somehow the dispatch thread can't be used (e.g. trap context), we fallback to sending it synchronously.

The throughput compared to the previous implementation is a bit reduced, 531343.2/s -> 494629.0/s, but this implementation is much simpler and degrade much more cleanly.