Skip to content

Commit

Permalink
Removing the enabled flag as it isn't very useful
Browse files Browse the repository at this point in the history
  • Loading branch information
raykrueger committed Jun 24, 2011
1 parent 1682317 commit f8a090f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 21 deletions.
9 changes: 3 additions & 6 deletions lib/statsd.rb
Expand Up @@ -15,7 +15,6 @@
class Statsd
# A namespace to prepend to all statsd calls.
attr_accessor :namespace
attr_accessor :enabled

#characters that will be replaced with _ in stat names
RESERVED_CHARS_REGEX = /[\:\|\@]/
Expand All @@ -28,8 +27,8 @@ class << self

# @param [String] host your statsd host
# @param [Integer] port your statsd port
def initialize(host, port=8125, enabled=true)
@host, @port, @enabled = host, port, enabled
def initialize(host, port=8125)
@host, @port = host, port
end

# Sends an increment (count = 1) for the given stat to the statsd server.
Expand Down Expand Up @@ -78,8 +77,6 @@ def time(stat, sample_rate=1)
result
end

def enabled?; enabled end

private

def sampled(sample_rate)
Expand All @@ -94,7 +91,7 @@ def send(stat, delta, type, sample_rate)

def send_to_socket(message)
self.class.logger.debug {"Statsd: #{message}"} if self.class.logger
socket.send(message, 0, @host, @port) if @enabled
socket.send(message, 0, @host, @port)
end

def socket; @socket ||= UDPSocket.new end
Expand Down
15 changes: 0 additions & 15 deletions spec/statsd_spec.rb
Expand Up @@ -157,21 +157,6 @@ def socket; @socket ||= FakeUDPSocket.new end
@log.string.must_be_empty
end

describe "while disabled" do
before { @statsd.enabled = false }

it "should be disabled" do
@statsd.enabled.must_equal false
@statsd.enabled?.must_equal false
end

it "should not send data to the socket but should still log" do
@statsd.increment('foo', 1)
@statsd.socket.recv.must_be_nil
@log.string.must_match "Statsd: foo:1|c"
end

end
end

describe "stat names" do
Expand Down

0 comments on commit f8a090f

Please sign in to comment.