Class: NewRelic::MetricData
- Inherits:
-
Object
- Object
- NewRelic::MetricData
- Defined in:
- lib/new_relic/metric_data.rb
Instance Attribute Summary collapse
-
#metric_id ⇒ Object
nil or a cached integer ID for the metric from the collector.
-
#metric_spec ⇒ Object
nil, or a NewRelic::MetricSpec object if we have no cached ID.
-
#stats ⇒ Object
the actual statistics object.
Instance Method Summary collapse
- #eql?(o) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(metric_spec, stats, metric_id) ⇒ MetricData
constructor
A new instance of MetricData.
- #inspect ⇒ Object
- #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.
10 11 12 13 14 |
# File 'lib/new_relic/metric_data.rb', line 10 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
nil or a cached integer ID for the metric from the collector.
6 7 8 |
# File 'lib/new_relic/metric_data.rb', line 6 def metric_id @metric_id end |
#metric_spec ⇒ Object
nil, or a NewRelic::MetricSpec object if we have no cached ID
4 5 6 |
# File 'lib/new_relic/metric_data.rb', line 4 def metric_spec @metric_spec end |
#stats ⇒ Object
the actual statistics object
8 9 10 |
# File 'lib/new_relic/metric_data.rb', line 8 def stats @stats end |
Instance Method Details
#eql?(o) ⇒ Boolean
16 17 18 |
# File 'lib/new_relic/metric_data.rb', line 16 def eql?(o) (metric_spec.eql? o.metric_spec) && (stats.eql? o.stats) end |
#hash ⇒ Object
31 32 33 |
# File 'lib/new_relic/metric_data.rb', line 31 def hash metric_spec.hash ^ stats.hash end |
#inspect ⇒ Object
47 48 49 |
# File 'lib/new_relic/metric_data.rb', line 47 def inspect "#<MetricData metric_spec:#{metric_spec.inspect}, stats:#{stats.inspect}, metric_id:#{metric_id.inspect}>" end |
#original_spec ⇒ Object
20 21 22 |
# File 'lib/new_relic/metric_data.rb', line 20 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
36 37 38 |
# File 'lib/new_relic/metric_data.rb', line 36 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
40 41 42 43 44 45 46 |
# File 'lib/new_relic/metric_data.rb', line 40 def to_s if metric_spec "#{metric_spec.name}(#{metric_spec.scope}): #{stats}" else "#{metric_id}: #{stats}" end end |