Class: Cassandra::Utils::Statsd

Inherits:
Object
  • Object
show all
Defined in:
lib/cassandra/utils/statsd.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(metric_name) ⇒ Statsd

Returns a new instance of Statsd.



8
9
10
11
12
# File 'lib/cassandra/utils/statsd.rb', line 8

def initialize(metric_name)
  @statsd ||= ::Statsd.new('localhost', 8125)
  @metric_name = metric_name
  self
end

Instance Attribute Details

#metric_nameObject (readonly)

Returns the value of attribute metric_name.



6
7
8
# File 'lib/cassandra/utils/statsd.rb', line 6

def metric_name
  @metric_name
end

#statsdObject (readonly)

Returns the value of attribute statsd.



6
7
8
# File 'lib/cassandra/utils/statsd.rb', line 6

def statsd
  @statsd
end

#valueObject (readonly)

Returns the value of attribute value.



6
7
8
# File 'lib/cassandra/utils/statsd.rb', line 6

def value
  @value
end

Instance Method Details

#push!(value = @value) ⇒ Object



19
20
21
# File 'lib/cassandra/utils/statsd.rb', line 19

def push!(value = @value)
  statsd.gauge(metric_name, value)
end

#to_dd(value) ⇒ Object



14
15
16
17
# File 'lib/cassandra/utils/statsd.rb', line 14

def to_dd(value)
  @value = (value == true ? 1 : 0)
  self
end