class CanvasStatsd::BlockStat
Attributes
common_key[RW]
stats[RW]
Public Class Methods
new(common_key, statsd=CanvasStatsd::Statsd)
click to toggle source
# File lib/canvas_statsd/block_stat.rb, line 7 def initialize(common_key, statsd=CanvasStatsd::Statsd) self.common_key = common_key @statsd = statsd @stats = {} end
Public Instance Methods
exclusive_stats()
click to toggle source
# File lib/canvas_statsd/block_stat.rb, line 21 def exclusive_stats return nil unless @exclusives stats.map { |key, value| [key, value - (@exclusives[key] || 0.0)] }.to_h end
report()
click to toggle source
# File lib/canvas_statsd/block_stat.rb, line 26 def report if common_key stats.each do |(key, value)| @statsd.timing("#{common_key}.#{key}", value) end exclusive_stats&.each do |(key, value)| @statsd.timing("#{common_key}.exclusive.#{key}", value) end end end
subtract_exclusives(stats)
click to toggle source
# File lib/canvas_statsd/block_stat.rb, line 13 def subtract_exclusives(stats) @exclusives ||= {} stats.each do |(key, value)| @exclusives[key] ||= 0.0 @exclusives[key] += value end end