Class: FnordMetric::Context
- Inherits:
-
Object
- Object
- FnordMetric::Context
show all
- Includes:
- GaugeModifiers
- Defined in:
- lib/fnordmetric/context.rb
Defined Under Namespace
Classes: Proxy
Instance Method Summary
collapse
#assure_has_series!, #assure_non_progressive!, #assure_series_exists!, #assure_three_dimensional!, #assure_two_dimensional!, #incr, #incr_avg, #incr_denominator, #incr_field, #incr_field_by, #incr_fraction, #incr_numerator, #incr_tick, #incr_uniq, #parse_numeric, #set_field, #set_value
Constructor Details
#initialize(opts, block) ⇒ Context
Returns a new instance of Context.
17
18
19
20
|
# File 'lib/fnordmetric/context.rb', line 17
def initialize(opts, block)
@block = block
@opts = opts
end
|
Instance Method Details
#call(event, redis, namespace) ⇒ Object
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/fnordmetric/context.rb', line 22
def call(event, redis, namespace)
@redis = redis
@event = event
@namespace = namespace
proxy.instance_eval(&@block)
rescue Exception => e
raise e if ENV['FNORDMETRIC_ENV'] == 'test'
puts "error: #{e.message}"
puts e.backtrace.push("").join("\n") if ENV['FNORDMETRIC_ENV'] == 'dev'
end
|
#dispatch(method, *args, &block) ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/fnordmetric/context.rb', line 41
def dispatch(method, *args, &block)
if args.size > 0 && gauges[args[0]].try(:renderable?)
gauges[args.delete_at(0)].execute(method, *args.unshift(self), &block)
else
send(method, *args, &block)
end
rescue Exception => e
raise e if ENV['FNORDMETRIC_ENV'] == 'test'
puts "error: #{e.message}"
puts e.backtrace.push("\n").join("\n") if ENV['FNORDMETRIC_ENV'] == 'dev'
end
|
#namespace ⇒ Object
37
38
39
|
# File 'lib/fnordmetric/context.rb', line 37
def namespace
@namespace
end
|
#proxy ⇒ Object
33
34
35
|
# File 'lib/fnordmetric/context.rb', line 33
def proxy
@proxy ||= Proxy.new(self)
end
|
#redis_exec(*args) ⇒ Object
53
54
55
|
# File 'lib/fnordmetric/context.rb', line 53
def redis_exec(*args)
@redis.send(*args)
end
|