module SnowAgent
This module loading only for Rails apps
Constants
- VERSION
Attributes
configuration[W]
logger[W]
Public Class Methods
agent()
click to toggle source
# File lib/snowagent.rb, line 30 def agent @agent ||= Agent.new(configuration) end
amount(key, value, context = nil)
click to toggle source
# File lib/snowagent.rb, line 55 def amount(key, value, context = nil) metric(key, value, "amount", context) end
configuration()
click to toggle source
# File lib/snowagent.rb, line 26 def configuration @configuration ||= Configuration.new end
configure() { |configuration| ... }
click to toggle source
# File lib/snowagent.rb, line 59 def configure yield(configuration) # do not trigger initialization if not configured self.agent if configuration.configured? end
increment(key, value = 1, context = nil)
click to toggle source
# File lib/snowagent.rb, line 51 def increment(key, value = 1, context = nil) metric(key, value, "counter", context) end
logger()
click to toggle source
# File lib/snowagent.rb, line 22 def logger @logger ||= Logger.new(STDOUT) end
metric(*args)
click to toggle source
# File lib/snowagent.rb, line 34 def metric(*args) if configuration.configured? agent.metric(*args) else logger.warn "[SnowAgent] Metric '#{args.first}' was not send due to configuration." end nil end
time(key, context = nil) { || ... }
click to toggle source
# File lib/snowagent.rb, line 44 def time(key, context = nil) start = Time.now result = yield metric(key, ((Time.now - start) * 1000).round, "time", context) result end