Skip to content

Commit

Permalink
Send timing results even when exceptions occur
Browse files Browse the repository at this point in the history
Closes #48
  • Loading branch information
raggi committed Jan 17, 2016
1 parent 6e1fee4 commit 3366c7d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 12 deletions.
2 changes: 1 addition & 1 deletion lib/statsd.rb
Expand Up @@ -393,7 +393,7 @@ def time(stat, sample_rate=1)
start = Time.now
result = yield
ensure
timing(stat, ((Time.now - start) * 1000).round, sample_rate) unless $!
timing(stat, ((Time.now - start) * 1000).round, sample_rate)
result
end

Expand Down
11 changes: 0 additions & 11 deletions spec/statsd_spec.rb
Expand Up @@ -182,17 +182,6 @@ class Statsd
end
end

describe "when given a block which throws an exception" do
it "should not send" do
@statsd.time('foobar') { raise 'test' } rescue nil
@socket.recv.must_equal nil
end

it "should not block the exception" do
proc { @statsd.time('foobar') { raise 'test' } }.must_raise RuntimeError
end
end

describe "with a sample rate" do
before { class << @statsd; def rand; 0; end; end } # ensure delivery

Expand Down

0 comments on commit 3366c7d

Please sign in to comment.