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

StatsD::Instrument::Environment improvements #197

Closed wvanbergen closed 4 years ago

wvanbergen commented 4 years ago
wvanbergen commented 4 years ago

The goal has always been that you can configure StatsD fully with environment variables, so that you don't have to use initializers, etc. In the past we used this to easily configure StatsD properly for all our heroku apps, now we can use this for cloud platform apps.

The Environment class/singleton does not hold configuration. Rather, it parses configuration from ENV. Because the logic is more complicated than simply reading environment variables, this has been extracted into a separate module.

I prefer using a class rather than a singleton for this because it easier to test (no need to stub values in ENV, etc).

I agree that the implementation is a bit messy because it serves both the legacy client as well as the new client, and tries to be backwards compatible. Once we drop the legacy client, we can clean this class up.