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
570 stars 94 forks source link

Always sample datagrams handled by a NullSink. #225

Closed wvanbergen closed 4 years ago

wvanbergen commented 4 years ago

NullSink#sample? currently always returns false, which prevents us from generating a datagram unnecessarily. This seems like a simple performance boost, but comes with a price.

The NullSink is primarily used in the test environment. In this environment, it can make a lot of sense to use a custom DatagramBuilder that enforces certain rules about the metrics you are emitting. But because sample? Returns false, this datagram builder is never called (except when capturing datagrams from the NullSink).

Because high performance is not really the main use case for the test environment, it makes more sense to always return true, so we always go through the datagram builder.