Class: Scout::Realtime::Metric
- Inherits:
-
Object
- Object
- Scout::Realtime::Metric
show all
- Defined in:
- lib/scout_realtime/lib/metric.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ Metric
Returns a new instance of Metric.
5
6
7
|
# File 'lib/scout_realtime/lib/metric.rb', line 5
def initialize
@historical_metrics = Hash.new
end
|
Instance Attribute Details
#historical_metrics ⇒ Object
Returns the value of attribute historical_metrics.
2
3
4
|
# File 'lib/scout_realtime/lib/metric.rb', line 2
def historical_metrics
@historical_metrics
end
|
#latest_run ⇒ Object
Returns the value of attribute latest_run.
3
4
5
|
# File 'lib/scout_realtime/lib/metric.rb', line 3
def latest_run
@latest_run
end
|
Class Method Details
20
21
22
23
24
25
26
27
|
# File 'lib/scout_realtime/lib/metric.rb', line 20
def self.metadata
meta = self::FIELDS
meta.keys.each_with_object(meta) do |field_name, formatted_meta|
formatted_meta[field_name]['label'] ||= field_name.to_s.capitalize.gsub('_', ' ')
formatted_meta[field_name]['units'] ||= ''
formatted_meta[field_name]['precision'] ||= 1
end
end
|
.short_name ⇒ Object
29
30
31
|
# File 'lib/scout_realtime/lib/metric.rb', line 29
def self.short_name
self.to_s.split('::').last.downcase.to_sym
end
|
Instance Method Details
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/scout_realtime/lib/metric.rb', line 9
def run!
begin
@latest_run = @collector.run
rescue Errno::ENOENT => e
print "#############################################################################"
puts "#{e.class}: #{e.message}"
@latest_run = {}
end
update_historical_metrics(latest_run)
end
|