Module: Contrast::Extension::Protect::Kernel

Extended by:
Components::Interface
Defined in:
lib/contrast/extension/protect/kernel.rb,
ext/cs__protect_kernel/cs__protect_kernel.c

Overview

This Module functions as our patch into the Kernel class for Protect, allowing us to track activity as it crosses spawned processes.

Class Method Summary collapse

Methods included from Components::Interface

included

Class Method Details

.build_wrapperObject



16
17
18
19
20
21
22
# File 'lib/contrast/extension/protect/kernel.rb', line 16

def build_wrapper
  lambda {
    proc_start
    yield
    # AtExitHook handles sending any messages generated in the new forked process
  }
end

.instrumentObject



31
32
33
34
35
36
37
38
39
# File 'lib/contrast/extension/protect/kernel.rb', line 31

def instrument
  @_instrument ||= begin
    require 'cs__protect_kernel/cs__protect_kernel'
    true
  end
rescue StandardError, LoadError => e
  logger.error('Error loading kernel protect patch', e)
  false
end

.proc_startObject



24
25
26
27
28
29
# File 'lib/contrast/extension/protect/kernel.rb', line 24

def proc_start
  context = Contrast::Agent::REQUEST_TRACKER.current
  return unless context

  context.reset_activity
end