Module: Funchook

Includes:
Contrast::Components::Interface
Defined in:
lib/contrast/funchook/funchook.rb,
ext/cs__common/cs__common.c

Overview

This module is used to find funchook library and determine availability

Constant Summary collapse

ACCEPTABLE_FILES =

Possible platform library files

%w[libfunchook.dylib libfunchook.so].cs__freeze
SEARCH_DIRS =

Top level agent directories that should have the funchook libraries

[
  File.join('ext'),
  File.join('shared_libraries'),
  File.join('funchook', 'src')
].cs__freeze
AGENT_ROOT =
File.join(__dir__, '..', '..', '..')

Instance Attribute Summary collapse

Class Method Summary collapse

Methods included from Contrast::Components::Interface

included

Instance Attribute Details

#pathObject

Returns the value of attribute path.



9
10
11
# File 'lib/contrast/funchook/funchook.rb', line 9

def path
  @path
end

Class Method Details

.absolute_path(path_array) ⇒ Object



38
39
40
# File 'lib/contrast/funchook/funchook.rb', line 38

def self.absolute_path path_array
  File.absolute_path(File.join(AGENT_ROOT, *path_array))
end

.available?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/contrast/funchook/funchook.rb', line 42

def self.available?
  @_available ||= !!resolve_path!
end

.resolve_path!Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/contrast/funchook/funchook.rb', line 23

def self.resolve_path!
  actual_path_segments = SEARCH_DIRS.product(ACCEPTABLE_FILES).find do |potential_funchook_path|
    load_path = absolute_path(potential_funchook_path)
    File.exist?(load_path)
  end

  if actual_path_segments.nil?
    logger.warn('Unable to find funchook')
  else
    @path = absolute_path(actual_path_segments)
    logger.info('Funchook found', path: @path)
  end
  @path
end