Module: StatsD

Defined in:
lib/statsd/instrument.rb

Defined Under Namespace

Modules: Instrument

Constant Summary collapse

TimeoutClass =
defined?(::SystemTimer) ? ::SystemTimer : ::Timeout

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.default_sample_rateObject

Returns the value of attribute default_sample_rate.



14
15
16
# File 'lib/statsd/instrument.rb', line 14

def default_sample_rate
  @default_sample_rate
end

.enabledObject

Returns the value of attribute enabled.



14
15
16
# File 'lib/statsd/instrument.rb', line 14

def enabled
  @enabled
end

.hostObject

Returns the value of attribute host.



14
15
16
# File 'lib/statsd/instrument.rb', line 14

def host
  @host
end

.loggerObject

Returns the value of attribute logger.



14
15
16
# File 'lib/statsd/instrument.rb', line 14

def logger
  @logger
end

.modeObject

Returns the value of attribute mode.



14
15
16
# File 'lib/statsd/instrument.rb', line 14

def mode
  @mode
end

.portObject

Returns the value of attribute port.



14
15
16
# File 'lib/statsd/instrument.rb', line 14

def port
  @port
end

.prefixObject

Returns the value of attribute prefix.



14
15
16
# File 'lib/statsd/instrument.rb', line 14

def prefix
  @prefix
end

Class Method Details

.gauge(key, amount) ⇒ Object

gerbals:30|g



118
119
120
# File 'lib/statsd/instrument.rb', line 118

def self.gauge(key, amount)
  write(key, amount, :gauge)
end

.increment(key, delta = 1, sample_rate = default_sample_rate) ⇒ Object

gorets:1|c



113
114
115
# File 'lib/statsd/instrument.rb', line 113

def self.increment(key, delta = 1, sample_rate = default_sample_rate)
  write(key, delta, :incr, sample_rate)
end

.measure(key, milli = nil) ⇒ Object

glork:320|ms



102
103
104
105
106
107
108
109
110
# File 'lib/statsd/instrument.rb', line 102

def self.measure(key, milli = nil)
  result = nil
  ms = milli || Benchmark.ms do
    result = yield 
  end

  write(key, ms, :ms)
  result
end

.server=(conn) ⇒ Object

StatsD.server = ‘localhost:1234’



23
24
25
26
# File 'lib/statsd/instrument.rb', line 23

def self.server=(conn)
  self.host, port = conn.split(':')
  self.port = port.to_i
end