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

Add Proc as a valid type for tag #323

Closed leandromoreira closed 1 year ago

leandromoreira commented 1 year ago

statsd-instrument is enabling the users to pass a lambda function to dynamically set the tags. The strict mode is allowing only nil, hash, or an array. This PR adds Proc as a valid class type for the strict mode.

I couldn't find tests for the strict class. I thought about duplicating the existing test test_statsd_count_with_tags_as_lambda forcing it to run under the strict mode, but it doesn't seem like a future-proof method of testing the strictness.

Adding the error log just to help seo/searchability.

FAIL                                                                                                                                             
XXXXX_duration_via_StatsD
    An exception occurred in the block provided to the StatsD assertion.

    ArgumentError: The tags argument should be a hash or an array, got #<Proc:0x00007f01e0dd3770 /xxxxxxxx:43 (lambda)>
        /xxxxxxxxx:101:in `check_tags_and_sample_rate'
        /xxxxxxxxx:in `distribution'