reinh / statsd

A Ruby Statsd client that isn't a direct port of the Python example code. Because Ruby isn't Python.
MIT License
411 stars 154 forks source link

Timed explicit returns #51

Closed Ajedi32 closed 8 years ago

Ajedi32 commented 10 years ago

Allow explicit returns in timed blocks. Previously, metrics would not be sent if you explicitly returned from a method from inside a timed block. E.g.

$statsd = Statsd.new '::1', 9125
def some_method
  $statsd.time('test') do
    sleep 1
    return "Explicitly returned string" 
  end
end
puts some_method
Ajedi32 commented 10 years ago

No idea why the build is failing. The tests run fine on my computer, I'm having weird issues with my proxy so I can't check Travis.

Ajedi32 commented 10 years ago

Okay, proxy issues resolved. The failure seems to be unrelated to my change. Apparently require 'json' is failing on Ruby 1.8.7.

Ajedi32 commented 10 years ago

Okay, so #53 fixes the failure in the build here.

Unfortunately, it seems that these changes actually do fail on 1.8.7, even with the fix in #53. I guess in Ruby 1.8.7, you can't explicitly return from a block that's inside a lambda? Do you want to continue supporting 1.8.7?

raggi commented 8 years ago

Thank you for the PR. I reimplemented this a little for simplicity.