Class: Sneakers::Metrics::NewrelicMetrics
- Inherits:
-
Object
- Object
- Sneakers::Metrics::NewrelicMetrics
- Defined in:
- lib/sneakers/metrics/newrelic_metrics.rb
Class Method Summary collapse
Instance Method Summary collapse
- #increment(metric) ⇒ Object
-
#initialize ⇒ NewrelicMetrics
constructor
A new instance of NewrelicMetrics.
- #record_stat(metric, num) ⇒ Object
- #timing(metric, &block) ⇒ Object
Constructor Details
#initialize ⇒ NewrelicMetrics
Returns a new instance of NewrelicMetrics.
9 10 11 |
# File 'lib/sneakers/metrics/newrelic_metrics.rb', line 9 def initialize() #@connection = conn end |
Class Method Details
.eagent(eagent = nil) ⇒ Object
5 6 7 |
# File 'lib/sneakers/metrics/newrelic_metrics.rb', line 5 def self.eagent(eagent = nil) @eagent = eagent || @eagent end |
Instance Method Details
#increment(metric) ⇒ Object
13 14 15 |
# File 'lib/sneakers/metrics/newrelic_metrics.rb', line 13 def increment(metric) record_stat metric, 1 end |
#record_stat(metric, num) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/sneakers/metrics/newrelic_metrics.rb', line 17 def record_stat(metric, num) metric_name = "Custom/#{metric.gsub("\.", "\/")}" NewrelicMetrics.eagent::Agent.record_metric(metric_name, num) rescue Exception => e puts "NewrelicMetrics#record_stat: #{e}" end |
#timing(metric, &block) ⇒ Object
24 25 26 27 28 |
# File 'lib/sneakers/metrics/newrelic_metrics.rb', line 24 def timing(metric, &block) start = Time.now block.call record_stat(metric, ((Time.now - start)*1000).floor) end |