Class: NewRelic::MetricData
- Inherits:
-
Object
- Object
- NewRelic::MetricData
show all
- Includes:
- Coerce
- Defined in:
- lib/new_relic/metric_data.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Coerce
boolean_int!, float, float!, int, int!, int_or_nil, log_failure, scalar, string, value_or_nil
Constructor Details
#initialize(metric_spec, stats) ⇒ MetricData
Returns a new instance of MetricData.
16
17
18
19
20
|
# File 'lib/new_relic/metric_data.rb', line 16
def initialize(metric_spec, stats)
@original_spec = nil
@metric_spec = metric_spec
self.stats = stats
end
|
Instance Attribute Details
#metric_spec ⇒ Object
a NewRelic::MetricSpec object
10
11
12
|
# File 'lib/new_relic/metric_data.rb', line 10
def metric_spec
@metric_spec
end
|
#stats ⇒ Object
a NewRelic::Agent::Stats object
12
13
14
|
# File 'lib/new_relic/metric_data.rb', line 12
def stats
@stats
end
|
Instance Method Details
#eql?(o) ⇒ Boolean
22
23
24
|
# File 'lib/new_relic/metric_data.rb', line 22
def eql?(o)
(metric_spec.eql?(o.metric_spec)) && (stats.eql?(o.stats))
end
|
#hash ⇒ Object
26
27
28
|
# File 'lib/new_relic/metric_data.rb', line 26
def hash
[metric_spec, stats].hash
end
|
#inspect ⇒ Object
30
31
32
|
# File 'lib/new_relic/metric_data.rb', line 30
def inspect
"#<MetricData metric_spec:#{metric_spec.inspect}, stats:#{stats.inspect}>"
end
|
#original_spec ⇒ Object
41
42
43
|
# File 'lib/new_relic/metric_data.rb', line 41
def original_spec
@original_spec || @metric_spec
end
|
#to_collector_array(encoder = nil) ⇒ Object
45
46
47
48
|
# File 'lib/new_relic/metric_data.rb', line 45
def to_collector_array(encoder = nil)
stat_key = {'name' => metric_spec.name, 'scope' => metric_spec.scope}
[stat_key, stats_collector_array(stat_key)]
end
|
#to_json(*a) ⇒ Object
50
51
52
|
# File 'lib/new_relic/metric_data.rb', line 50
def to_json(*a)
%Q({"metric_spec":#{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}}})
end
|
#to_s ⇒ Object
54
55
56
|
# File 'lib/new_relic/metric_data.rb', line 54
def to_s
"#{metric_spec.name}(#{metric_spec.scope}): #{stats}"
end
|