lib/contrast/agent/middleware.rb in contrast-agent-3.12.2 vs lib/contrast/agent/middleware.rb in contrast-agent-3.13.0

- old
+ new

@@ -5,20 +5,17 @@ cs__scoped_require 'json' cs__scoped_require 'rack' cs__scoped_require 'contrast/security_exception' cs__scoped_require 'contrast/utils/object_share' -cs__scoped_require 'contrast/agent/service_heartbeat' cs__scoped_require 'contrast/components/interface' cs__scoped_require 'contrast/utils/heap_dump_util' cs__scoped_require 'contrast/agent/request_handler' cs__scoped_require 'contrast/agent/static_analysis' cs__scoped_require 'contrast/utils/timer' cs__scoped_require 'contrast/utils/freeze_util' -cs__scoped_require 'contrast/utils/service_sender_util' -cs__scoped_require 'contrast/utils/service_response_util' module Contrast module Agent # This class allows the Agent to plug into the Rack middleware stack. When the # application is first started, we initialize ourselves as a rack middleware @@ -58,11 +55,11 @@ # we didn't see get loaded # - enable TracePoint, which handles all class loads and required # instrumentation going forward def agent_startup_routine logger.debug_with_time('middleware: starting service') do - run_service_threads + Contrast::Agent.thread_watcher.ensure_running? end logger.debug_with_time('middleware: instrument shared libraries and patch') do Contrast::Agent::Patching::Policy::Patcher.patch end @@ -108,10 +105,11 @@ # This is where we process each request we intercept as a middleware. We make the request context # available globally so that it can be accessed from anywhere. A RequestHandler object is made # for each request, which handles prefilter and postfilter operations. def call_with_agent env + Contrast::Agent.thread_watcher.ensure_running? return unless AGENT.enabled? framework_request = Contrast::Agent.framework_manager.retrieve_request(env) context = Contrast::Agent::RequestContext.new(framework_request) response = nil @@ -173,19 +171,9 @@ [exception_control[:status], {}, [exception_control[:message]]] else logger.debug('Re-throwing original error', exception) raise exception end - end - - # TODO: RUBY-920 - # Move this somewhere that controls our threads, ensuring they're - # recreated on Fork - # - # Rspec stubs over these methods for simplicity's sake in testing - def run_service_threads - Contrast::Utils::ServiceSenderUtil.start - Contrast::Agent::ServiceHeartbeat.new.start end end end end