Class: NetuitiveRailsAgent::GCStatsCollector
- Inherits:
-
Object
- Object
- NetuitiveRailsAgent::GCStatsCollector
- Defined in:
- lib/netuitive_rails_agent/gc.rb
Instance Attribute Summary collapse
-
#interaction ⇒ Object
readonly
Returns the value of attribute interaction.
Instance Method Summary collapse
- #collect ⇒ Object
-
#initialize(interaction) ⇒ GCStatsCollector
constructor
A new instance of GCStatsCollector.
Constructor Details
#initialize(interaction) ⇒ GCStatsCollector
Returns a new instance of GCStatsCollector.
4 5 6 |
# File 'lib/netuitive_rails_agent/gc.rb', line 4 def initialize(interaction) @interaction = interaction end |
Instance Attribute Details
#interaction ⇒ Object (readonly)
Returns the value of attribute interaction.
3 4 5 |
# File 'lib/netuitive_rails_agent/gc.rb', line 3 def interaction @interaction end |
Instance Method Details
#collect ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/netuitive_rails_agent/gc.rb', line 8 def collect unless GC::Profiler.enabled? NetuitiveRailsAgent::NetuitiveLogger.log.warn 'gc profiler not enabled' return end NetuitiveRailsAgent::NetuitiveLogger.log.debug 'collecting gc metrics' NetuitiveRailsAgent::ErrorLogger.guard('error during collecting gc metrics') do GC.stat.each do |key, value| NetuitiveRailsAgent::NetuitiveLogger.log.debug "GC stat key: #{key}" if (key.to_s == 'total_allocated_object') || (key.to_s == 'total_freed_object') || (key.to_s == 'count') NetuitiveRailsAgent::NetuitiveLogger.log.debug "sending aggregateCounterMetric GC.stat.#{key}" interaction.aggregate_counter_metric("GC.stat.#{key}", value) else NetuitiveRailsAgent::NetuitiveLogger.log.debug "sending aggregateMetric GC.stat.#{key}" interaction.aggregate_metric("GC.stat.#{key}", value) end end NetuitiveRailsAgent::NetuitiveLogger.log.debug 'sending aggregateCounterMetric GC.profiler.total_time' interaction.aggregate_counter_metric('GC.profiler.total_time', GC::Profiler.total_time) end NetuitiveRailsAgent::NetuitiveLogger.log.debug 'finished collecting gc metrics' end |