module OneApm::Probe::Instrumentation

Public Instance Methods

add_instrumentation(pattern) click to toggle source
# File lib/one_apm/probe/instrumentation.rb, line 45
def add_instrumentation pattern
  if @instrumented
    load_instrumentation_files pattern
  else
    @instrumentation_files << pattern
  end
end
detect_dependencies() click to toggle source
# File lib/one_apm/probe/instrumentation.rb, line 26
def detect_dependencies
  LibraryDetection.detect!
end
install_instrumentation() click to toggle source
# File lib/one_apm/probe/instrumentation.rb, line 9
def install_instrumentation
  return if @instrumented

  @instrumented = true

  instrumentation_path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'inst'))
  Dir.glob("#{instrumentation_path}/**/*.rb").each do |inst_file|
    load_instrumentation_files inst_file
  end
  detect_dependencies
  OneApm::Manager.logger.info "Finished instrumentation"
end
install_shim() click to toggle source
# File lib/one_apm/probe/instrumentation.rb, line 36
def install_shim
  if @instrumented
    OneApm::Manager.logger.error "Cannot install the Agent shim after instrumentation has already been installed!"
    OneApm::Manager.logger.error caller.join("\n")
  else
    OneApm::Manager.agent = OneApm::Agent::ShimAgent.instance
  end
end
load_instrumentation_files(pattern) click to toggle source
# File lib/one_apm/probe/instrumentation.rb, line 22
def load_instrumentation_files pattern
  Dir.glob(pattern) { |file| require_instrumentation(file.to_s) }
end
require_instrumentation(file) click to toggle source
# File lib/one_apm/probe/instrumentation.rb, line 30
def require_instrumentation file
  require file
rescue => e
  OneApm::Manager.logger.warn "Error loading instrumentation file '#{file}':", e
end