Skip to content

Commit

Permalink
setting host should clear out the ip addr
Browse files Browse the repository at this point in the history
  • Loading branch information
bvandenbos committed Apr 21, 2011
1 parent 8a415e8 commit d1ac4ca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/statsd.rb
Expand Up @@ -15,6 +15,11 @@ def host_ip_addr
end
end

def host=(h)
@host_ip_addr = nil
@host = h
end

# +stat+ to log timing for
# +time+ is the time to log in ms
def timing(stat, time, sample_rate = 1)
Expand Down
6 changes: 6 additions & 0 deletions test/statsd_test.rb
Expand Up @@ -96,6 +96,12 @@ def setup
assert_equal '127.0.0.1', Statsd.host_ip_addr
end

should "be cleared when host is set" do
assert_equal '127.0.0.1', Statsd.host_ip_addr
Statsd.host = 'statsd-01'
assert_nil Statsd.instance_variable_get(:@host_ip_addr)
end

end

private
Expand Down

0 comments on commit d1ac4ca

Please sign in to comment.