Class: Metricize::Client
Instance Method Summary
collapse
#establish_redis_connection
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
5
6
7
8
9
10
|
# File 'lib/metricize/client.rb', line 5
def initialize(options = {})
@prefix = options[:prefix]
@log_sampling_ratio = options[:log_sampling_ratio] || 0.10
establish_logger(options)
initialize_redis(options)
end
|
Instance Method Details
#increment(name, options = {}) ⇒ Object
12
13
14
15
|
# File 'lib/metricize/client.rb', line 12
def increment(name, options = {})
count = options.delete(:by) || 1
enqueue_count(name, count, options)
end
|
#measure(name, value, options = {}) ⇒ Object
17
18
19
|
# File 'lib/metricize/client.rb', line 17
def measure(name, value, options = {})
enqueue_value(name, value, options)
end
|
#time(name, options = {}) ⇒ Object
21
22
23
24
25
26
27
|
# File 'lib/metricize/client.rb', line 21
def time(name, options = {})
raise ArgumentError, "must be invoked with a block to time" unless block_given?
start_time = Time.now
block_result = yield
measure(name + '.time', time_delta_ms(start_time), options)
return block_result
end
|