lib/contrast/components/app_context.rb in contrast-agent-3.11.0 vs lib/contrast/components/app_context.rb in contrast-agent-3.12.0
- old
+ new
@@ -14,17 +14,27 @@
# including the Client, Process, and Server information.
class Interface
include Contrast::Components::ComponentBase
include Contrast::Components::Interface
- access_component :config
+ access_component :agent, :config
DEFAULT_APP_NAME = 'rails'
DEFAULT_APP_PATH = '/'
DEFAULT_SERVER_NAME = 'localhost'
DEFAULT_SERVER_PATH = '/'
+ def ready?
+ @_ready ||= AGENT.enabled? &&
+ Contrast::Utils::ServiceSenderUtil.connection_established? &&
+ Contrast::Utils::ServiceResponseUtil.update_received?
+ end
+
+ def initialize
+ original_pid
+ end
+
def server_type
@_server_type ||= begin
tmp = CONFIG.root.server.type
tmp = Contrast::Agent.framework_manager.server_type unless Contrast::Utils::StringUtils.present?(tmp)
tmp
@@ -115,9 +125,31 @@
@_client_id ||= [name, pgid].join('-')
end
def instrument_middleware_stack?
!Contrast::Utils::JobServersRunning.job_servers_running?
+ end
+
+ def disabled_agent_rake_tasks
+ CONFIG.root.agent.ruby.disabled_agent_rake_tasks
+ end
+
+ # Determines if the Process we're currently in matches that of the
+ # Process in which the App Context instance was created.
+ # If it doesn't, that indicates the running context is in a new
+ # Process.
+ # @return [Boolean] if we're in the original Process in which the
+ # App Context instance was initialized.
+ def in_new_process?
+ current_pid = Process.pid
+ original_pid = pid
+ current_pid != original_pid
+ end
+
+ private
+
+ def original_pid
+ @_original_pid ||= Process.pid
end
end
COMPONENT_INTERFACE = Interface.new
end