module Statue
Constants
- VERSION
Attributes
backend[W]
logger[RW]
namespace[RW]
Public Instance Methods
backend()
click to toggle source
# File lib/statue.rb, line 47 def backend @backend ||= UDPBackend.from_uri("statsd://127.0.0.1:8125") end
debug(text, &block)
click to toggle source
# File lib/statue.rb, line 51 def debug(text, &block) logger.debug(text, &block) if logger end
error(text, &block)
click to toggle source
# File lib/statue.rb, line 55 def error(text, &block) logger.error(text, &block) if logger end
report_duration(metric_name, duration = nil, options = {}, &block)
click to toggle source
# File lib/statue.rb, line 14 def report_duration(metric_name, duration = nil, options = {}, &block) result = nil backend << Metric.measure(metric_name, options.merge(duration: duration)) do result = block.call end result end
report_gauge(metric_name, value, options = {})
click to toggle source
# File lib/statue.rb, line 26 def report_gauge(metric_name, value, options = {}) backend << Metric.gauge(metric_name, value, options) end
report_increment(metric_name, value = 1, options = {})
click to toggle source
# File lib/statue.rb, line 22 def report_increment(metric_name, value = 1, options = {}) backend << Metric.counter(metric_name, value, options) end
report_success_or_failure(metric_name, options = {}, &block)
click to toggle source
# File lib/statue.rb, line 30 def report_success_or_failure(metric_name, options = {}, &block) success_method = options.delete(:success_method) result = block.call success = success_method ? result.public_send(success_method) : result report_increment("#{metric_name}.#{success ? "success" : "failure"}", 1, options) result rescue report_increment("#{metric_name}.failure", 1, options) raise end
stopwatch(metric_name)
click to toggle source
# File lib/statue.rb, line 43 def stopwatch(metric_name) Stopwatch.new(metric_name, reporter: self) end