class TingYun::Metrics::MetricData
Attributes
metric_id[RW]
nil or a cached integer ID for the metric from the collector.
metric_spec[R]
nil, or a TingYun::Metrics::MetricSpec
object if we have no cached ID
quantile[R]
stats[RW]
the actual statistics object
Public Class Methods
new(metric_spec, stats, metric_id, quantile = [])
click to toggle source
# File lib/ting_yun/metrics/metric_data.rb, line 18 def initialize(metric_spec, stats, metric_id, quantile = []) @metric_spec = metric_spec @stats = stats @metric_id = metric_id @quantile = quantile end
Public Instance Methods
eql?(o)
click to toggle source
# File lib/ting_yun/metrics/metric_data.rb, line 25 def eql?(o) (metric_spec.eql? o.metric_spec) && (stats.eql? o.stats) end
hash()
click to toggle source
# File lib/ting_yun/metrics/metric_data.rb, line 29 def hash metric_spec.hash ^ stats.hash end
inspect()
click to toggle source
# File lib/ting_yun/metrics/metric_data.rb, line 46 def inspect "#<MetricData metric_spec:#{metric_spec.inspect}, stats:#{stats.inspect}, metric_id:#{metric_id.inspect}>" end
metrics(stat_key)
click to toggle source
# File lib/ting_yun/metrics/metric_data.rb, line 64 def metrics(stat_key) stats.metrics(stat_key) end
to_collector_array(encoder=nil)
click to toggle source
# File lib/ting_yun/metrics/metric_data.rb, line 51 def to_collector_array(encoder=nil) stat_key = metric_id || to_hash if quantile.empty? [stat_key, metrics(stat_key)] else [stat_key, metrics(stat_key), quantile] end end
to_hash()
click to toggle source
# File lib/ting_yun/metrics/metric_data.rb, line 60 def to_hash metric_spec.to_hash end
to_json(*a)
click to toggle source
Serialize with all attributes, but if the metric id is not nil, then don't send the metric spec
# File lib/ting_yun/metrics/metric_data.rb, line 34 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()
click to toggle source
# File lib/ting_yun/metrics/metric_data.rb, line 38 def to_s if metric_spec "#{metric_spec.name}(#{metric_spec.scope}): #{stats}" else "#{metric_id}: #{stats}" end end