Class: NewRelic::MetricData
Instance Attribute Summary collapse
-
#metric_id ⇒ Object
Returns the value of attribute metric_id.
-
#metric_spec ⇒ Object
Returns the value of attribute metric_spec.
-
#stats ⇒ Object
Returns the value of attribute stats.
Instance Method Summary collapse
- #eql?(o) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(metric_spec, stats, metric_id) ⇒ MetricData
constructor
A new instance of MetricData.
- #original_spec ⇒ Object
-
#to_json(*a) ⇒ Object
Serialize with all attributes, but if the metric id is not nil, then don’t send the metric spec.
- #to_s ⇒ Object
Constructor Details
#initialize(metric_spec, stats, metric_id) ⇒ MetricData
Returns a new instance of MetricData.
7 8 9 10 11 |
# File 'lib/new_relic/metric_data.rb', line 7 def initialize(metric_spec, stats, metric_id) @metric_spec = metric_spec self.stats = stats self.metric_id = metric_id end |
Instance Attribute Details
#metric_id ⇒ Object
Returns the value of attribute metric_id.
4 5 6 |
# File 'lib/new_relic/metric_data.rb', line 4 def metric_id @metric_id end |
#metric_spec ⇒ Object
Returns the value of attribute metric_spec.
3 4 5 |
# File 'lib/new_relic/metric_data.rb', line 3 def metric_spec @metric_spec end |
#stats ⇒ Object
Returns the value of attribute stats.
5 6 7 |
# File 'lib/new_relic/metric_data.rb', line 5 def stats @stats end |
Instance Method Details
#eql?(o) ⇒ Boolean
13 14 15 |
# File 'lib/new_relic/metric_data.rb', line 13 def eql?(o) (metric_spec.eql? o.metric_spec) && (stats.eql? o.stats) end |
#hash ⇒ Object
28 29 30 |
# File 'lib/new_relic/metric_data.rb', line 28 def hash metric_spec.hash ^ stats.hash end |
#original_spec ⇒ Object
17 18 19 |
# File 'lib/new_relic/metric_data.rb', line 17 def original_spec @original_spec || @metric_spec end |
#to_json(*a) ⇒ Object
Serialize with all attributes, but if the metric id is not nil, then don’t send the metric spec
33 34 35 |
# File 'lib/new_relic/metric_data.rb', line 33 def to_json(*a) %Q[{"metric_spec":#{metric_id ? 'null' : metric_spec.to_json},"stats":{"total_exclusive_time":#{stats.total_exclusive_time},"min_call_time":#{stats.min_call_time},"call_count":#{stats.call_count},"sum_of_squares":#{stats.sum_of_squares},"total_call_time":#{stats.total_call_time},"max_call_time":#{stats.max_call_time}},"metric_id":#{metric_id ? metric_id : 'null'}}] end |
#to_s ⇒ Object
37 38 39 40 |
# File 'lib/new_relic/metric_data.rb', line 37 def to_s "#{metric_spec.name}(#{metric_spec.scope}): #{stats}" if metric_spec "#{metric_id}: #{stats}" if metric_spec.nil? end |