Class: SimpleMetrics::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_metrics/client.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, port = 8125) ⇒ Client

Returns a new instance of Client.



18
19
20
# File 'lib/simple_metrics/client.rb', line 18

def initialize(host, port = 8125)
  @host, @port = host, port
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



8
9
10
# File 'lib/simple_metrics/client.rb', line 8

def host
  @host
end

#portObject (readonly)

Returns the value of attribute port.



8
9
10
# File 'lib/simple_metrics/client.rb', line 8

def port
  @port
end

Class Method Details

.loggerObject



14
15
16
# File 'lib/simple_metrics/client.rb', line 14

def self.logger
  @@logger ||= Logger.new($stdout)
end

.logger=(logger) ⇒ Object



10
11
12
# File 'lib/simple_metrics/client.rb', line 10

def self.logger=(logger)
  @@logger = logger
end

Instance Method Details

#count(stat, count, sample_rate = 1) ⇒ Object

send relative value



28
29
30
# File 'lib/simple_metrics/client.rb', line 28

def count(stat, count, sample_rate = 1)
  send_data( stat, count, 'c', sample_rate)
end

#gauge(stat, value) ⇒ Object

send absolute value



33
34
35
# File 'lib/simple_metrics/client.rb', line 33

def gauge(stat, value)
  send_data(stat, value, 'g')
end

#increment(stat, sample_rate = 1) ⇒ Object

send relative value



23
24
25
# File 'lib/simple_metrics/client.rb', line 23

def increment(stat, sample_rate = 1)
  count(stat, 1, sample_rate)
end