class AppDynamics::BackgroundMetrics
Constants
Attributes
instrumenter[R]
sample_rate[RW]
Public Class Methods
new(instrumenter)
click to toggle source
# File lib/app_dynamics/background_metrics.rb, line 144 def initialize(instrumenter) @instrumenter = instrumenter # The AppDynamics Controller will sum all metrics reported on a server in a # 1-minute period. Since we can't distinguish individual Ruby processes, we want to # report the 1-minute values once a minute and display the total across all processes. # Barnes reports two types of values: # * Counters: tracked over the given interval (e.g. number of GCs, CPU time) # * Gauges: value at the specific point in time (e.g. number of objects currently allocated) # How often, in seconds, to instrument and report interval = 60 # The minimal aggregation period in use, in seconds. # This value appears to be hardcoded in Barnes::Periodic, but that's ok because it's the # same as what the AppDynamics collector uses aggregation_period = 60 # To further increase accuracy, we could decrease the interval and then average the data # locally before sending to AppDynamics. sample_rate = interval.to_f / aggregation_period.to_f panels = [Barnes::ResourceUsage.new(sample_rate), Panel.new(config, sample_rate)] @periodic = Barnes::Periodic.new(reporter: self, sample_rate: sample_rate, panels: panels) (COUNTERS.values + GAUGES.values).each do |name| native_define_metric(name) end end
Public Instance Methods
config()
click to toggle source
# File lib/app_dynamics/background_metrics.rb, line 175 def config instrumenter.config end
report(env)
click to toggle source
# File lib/app_dynamics/background_metrics.rb, line 183 def report(env) COUNTERS.each do |metric, name| # These are sampled, so we need to convert the value accordingly value = env[Barnes::COUNTERS][metric] / sample_rate native_report_metric(name, value) end GAUGES.each do |metric, name| value = env[Barnes::GAUGES][metric] native_report_metric(name, value) end end
stop()
click to toggle source
# File lib/app_dynamics/background_metrics.rb, line 179 def stop @periodic.stop end