netuitive_rails_agent 0.9.7 → 0.9.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/netuitive/gc.rb +15 -0
- data/lib/netuitive/objectspace.rb +13 -0
- data/lib/netuitive/scheduler.rb +23 -0
- data/lib/netuitive_rails_agent.rb +3 -1
- metadata +5 -2
    
        data/lib/netuitive/gc.rb
    ADDED
    
    | @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            class GCStatsCollector
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            	def self.collect()
         | 
| 4 | 
            +
            		if GC::Profiler.enabled?
         | 
| 5 | 
            +
            			begin
         | 
| 6 | 
            +
            				GC.stat.each do |key, value|
         | 
| 7 | 
            +
            					NetuitiveRubyAPI::netuitivedServer.aggregateMetric("GC.stat.#{key}", value)
         | 
| 8 | 
            +
            				end
         | 
| 9 | 
            +
            				NetuitiveRubyAPI::netuitivedServer.aggregateMetric("GC.profiler.total_time", GC::Profiler.total_time)
         | 
| 10 | 
            +
            			rescue
         | 
| 11 | 
            +
            				NetuitiveLogger.log.error "failure to communicate to netuitived"
         | 
| 12 | 
            +
            			end
         | 
| 13 | 
            +
            		end
         | 
| 14 | 
            +
            	end
         | 
| 15 | 
            +
            end
         | 
| @@ -0,0 +1,13 @@ | |
| 1 | 
            +
            class ObjectSpaceStatsCollector
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            	def self.collect()
         | 
| 4 | 
            +
            		begin
         | 
| 5 | 
            +
            			ObjectSpace.count_objects.each do |key, value|
         | 
| 6 | 
            +
            				NetuitiveLogger.log.debug "ObjectSpace.count_objects.#{key}"
         | 
| 7 | 
            +
            				NetuitiveRubyAPI::netuitivedServer.aggregateMetric("ObjectSpace.count_objects.#{key}", value)
         | 
| 8 | 
            +
            			end
         | 
| 9 | 
            +
            		rescue
         | 
| 10 | 
            +
            			NetuitiveLogger.log.error "failure to communicate to netuitived"
         | 
| 11 | 
            +
            		end
         | 
| 12 | 
            +
            	end
         | 
| 13 | 
            +
            end
         | 
| @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            require 'netuitive/netuitive_rails_logger'
         | 
| 2 | 
            +
            require 'netuitive/gc'
         | 
| 3 | 
            +
            require 'netuitive/objectspace'
         | 
| 4 | 
            +
            class Scheduler
         | 
| 5 | 
            +
            	def self.startSchedule
         | 
| 6 | 
            +
            		Thread.new do
         | 
| 7 | 
            +
                 while true do
         | 
| 8 | 
            +
                  interval = 60
         | 
| 9 | 
            +
                  begin
         | 
| 10 | 
            +
                    interval = NetuitiveRubyAPI::netuitivedServer.interval
         | 
| 11 | 
            +
                  rescue
         | 
| 12 | 
            +
                    NetuitiveLogger.log.info "unable to retrieve netuitived interval defaulting to 60"
         | 
| 13 | 
            +
                  end
         | 
| 14 | 
            +
                  collectMetrics
         | 
| 15 | 
            +
                  sleep(interval)
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
            end
         | 
| 19 | 
            +
            def self.collectMetrics
         | 
| 20 | 
            +
              GCStatsCollector::collect
         | 
| 21 | 
            +
              ObjectSpaceStatsCollector::collect
         | 
| 22 | 
            +
            end
         | 
| 23 | 
            +
            end 
         | 
| @@ -7,6 +7,7 @@ require 'netuitive/action_mailer' | |
| 7 7 | 
             
            require 'netuitive/active_support'
         | 
| 8 8 | 
             
            require 'netuitive/active_job'
         | 
| 9 9 | 
             
            require 'netuitive/rails_config_manager'
         | 
| 10 | 
            +
            require 'netuitive/scheduler'
         | 
| 10 11 |  | 
| 11 12 | 
             
            NetuitiveActionControllerSub::subscribe
         | 
| 12 13 | 
             
            NetuitiveActiveRecordSub::subscribe
         | 
| @@ -15,4 +16,5 @@ NetuitiveActionMailer::subscribe | |
| 15 16 | 
             
            NetuitiveActiveSupportSub::subscribe
         | 
| 16 17 | 
             
            NetuitiveActiveJobSub::subscribe
         | 
| 17 18 |  | 
| 18 | 
            -
            ConfigManager::setup
         | 
| 19 | 
            +
            ConfigManager::setup
         | 
| 20 | 
            +
            Scheduler::startSchedule
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: netuitive_rails_agent
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.9. | 
| 4 | 
            +
              version: 0.9.9
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors:
         | 
| @@ -9,7 +9,7 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date:  | 
| 12 | 
            +
            date: 2016-01-04 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: netuitive_ruby_api
         | 
| @@ -35,12 +35,15 @@ extra_rdoc_files: [] | |
| 35 35 | 
             
            files:
         | 
| 36 36 | 
             
            - lib/netuitive_rails_agent.rb
         | 
| 37 37 | 
             
            - lib/netuitive/action_mailer.rb
         | 
| 38 | 
            +
            - lib/netuitive/objectspace.rb
         | 
| 38 39 | 
             
            - lib/netuitive/netuitive_rails_logger.rb
         | 
| 39 40 | 
             
            - lib/netuitive/action_view.rb
         | 
| 41 | 
            +
            - lib/netuitive/scheduler.rb
         | 
| 40 42 | 
             
            - lib/netuitive/active_job.rb
         | 
| 41 43 | 
             
            - lib/netuitive/rails_config_manager.rb
         | 
| 42 44 | 
             
            - lib/netuitive/action_controller.rb
         | 
| 43 45 | 
             
            - lib/netuitive/active_record.rb
         | 
| 46 | 
            +
            - lib/netuitive/gc.rb
         | 
| 44 47 | 
             
            - lib/netuitive/active_support.rb
         | 
| 45 48 | 
             
            - config/agent.yml
         | 
| 46 49 | 
             
            - ./LICENSE
         |