Class: ScoutApm::AppServerLoad
- Inherits:
-
Object
- Object
- ScoutApm::AppServerLoad
- Defined in:
- lib/scout_apm/app_server_load.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
- #data ⇒ Object
- #environment ⇒ Object
-
#initialize(context) ⇒ AppServerLoad
constructor
A new instance of AppServerLoad.
- #run ⇒ Object
-
#to_s_safe(obj) ⇒ Object
Calls ‘.to_s` on the object passed in.
Constructor Details
#initialize(context) ⇒ AppServerLoad
Returns a new instance of AppServerLoad.
6 7 8 9 |
# File 'lib/scout_apm/app_server_load.rb', line 6 def initialize(context) @context = context @logger = context.logger end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
4 5 6 |
# File 'lib/scout_apm/app_server_load.rb', line 4 def context @context end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
3 4 5 |
# File 'lib/scout_apm/app_server_load.rb', line 3 def logger @logger end |
Instance Method Details
#data ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/scout_apm/app_server_load.rb', line 31 def data { :server_time => to_s_safe(Time.now), :framework => to_s_safe(environment.framework_integration.human_name), :framework_version => to_s_safe(environment.framework_integration.version), :environment => to_s_safe(environment.framework_integration.env), :app_server => to_s_safe(environment.app_server), :ruby_version => RUBY_VERSION, :hostname => to_s_safe(environment.hostname), :database_engine => to_s_safe(environment.database_engine), # Detected :database_adapter => to_s_safe(environment.raw_database_adapter), # Raw :application_name => to_s_safe(environment.application_name), :libraries => ScoutApm::Utils::InstalledGems.new(context).run, :paas => to_s_safe(environment.platform_integration.name), :git_sha => to_s_safe(environment.git_revision.sha) } ensure # Sometimes :database_engine and :database_adapter can cause a reference to an AR connection. # Make sure we release all AR connections held by this thread. ActiveRecord::Base.clear_active_connections! if Utils::KlassHelper.defined?("ActiveRecord::Base") end |
#environment ⇒ Object
62 63 64 |
# File 'lib/scout_apm/app_server_load.rb', line 62 def environment context.environment end |
#run ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/scout_apm/app_server_load.rb', line 11 def run @thread = Thread.new do begin logger.info "Sending Application Startup Info - App Server: #{data[:app_server]}, Framework: #{data[:framework]}, Framework Version: #{data[:framework_version]}, Database Engine: #{data[:database_engine]}" logger.debug("Full Application Startup Info: #{data.inspect}") payload = ScoutApm::Serializers::AppServerLoadSerializer.serialize(data) reporter = Reporter.new(context, :app_server_load) reporter.report(payload) logger.debug("Finished sending Startup Info") rescue => e logger.info("Failed Sending Application Startup Info - #{e.}") logger.debug(e.backtrace.join("\t\n")) end end rescue => e logger.debug("Failed Startup Info - #{e.} \n\t#{e.backtrace.join("\t\n")}") end |
#to_s_safe(obj) ⇒ Object
Calls ‘.to_s` on the object passed in. Returns literal string ’to_s error’ if the object does not respond to .to_s
54 55 56 57 58 59 60 |
# File 'lib/scout_apm/app_server_load.rb', line 54 def to_s_safe(obj) if obj.respond_to?(:to_s) obj.to_s else 'to_s error' end end |