class AppDynamics::Instrumenter

Attributes

pid[R]

Public Class Methods

new(config) click to toggle source
# File lib/app_dynamics/instrumenter.rb, line 6
def self.new(config)
  config.validate!

  inst = if AppDynamics.native?
    native_new
  else
    allocate
  end

  inst.send(:initialize, SecureRandom.uuid, config)
  inst
end
new(*) click to toggle source
Calls superclass method
# File lib/app_dynamics/instrumenter.rb, line 25
def initialize(*)
  super
  @pid = Process.pid
  @fully_started = false
end
trace_class() click to toggle source
# File lib/app_dynamics/instrumenter.rb, line 19
def self.trace_class
  AppDynamics::Trace
end

Public Instance Methods

add_snapshot_details(details=nil, &block) click to toggle source

Add details to the current trace's snapshot. See {Trace#add_snapshot_details} for more details.

# File lib/app_dynamics/instrumenter.rb, line 95
def add_snapshot_details(details=nil, &block)
  return unless current_trace
  current_trace.add_snapshot_details(details, &block)
end
after_fork() click to toggle source
# File lib/app_dynamics/instrumenter.rb, line 64
def after_fork
  config.after_fork
  log_debug "Generated new index: #{config.node_index} after forking"
end
before_fork() click to toggle source
# File lib/app_dynamics/instrumenter.rb, line 59
def before_fork
  raise "Can't fork after fully started!" if fully_started?
  config.before_fork
end
check_install!() click to toggle source
# File lib/app_dynamics/instrumenter.rb, line 75
def check_install!
  unless AppDynamics.native?
    config.alert_logger.error \
      "[AppDynamics] [#{AppDynamics::VERSION}] The AppDynamics C/C++ SDK was " \
      "not found on your system. No data will be reported! " \
      "To install the SDK, please follow the instructions at: " \
      "https://docs.appdynamics.com/pages/viewpage.action?pageId=42583435."

      # For non-standard locations:
      #   bundle config build.appdynamics --with-appdynamics-dir={INSTALL_PATH}"
      #   bundle exec gem pristine appdynamics
  end
end
finalize_start() click to toggle source
# File lib/app_dynamics/instrumenter.rb, line 37
def finalize_start
  return true if @fully_started

  # FIXME: This is to account for a mocked case during testing and should be improved.
  if self.class == AppDynamics::Instrumenter
    native_start_sdk
  end

  begin
    @background_metrics = BackgroundMetrics.new(self)
  rescue Exception => e
    log_error "failed to start runtime metric tracking; msg=%s", e.message
    t { e.backtrace.join("\n") }
  end

  @fully_started = true
end
fully_started?() click to toggle source
# File lib/app_dynamics/instrumenter.rb, line 55
def fully_started?
  @fully_started
end
is_snapshotting() click to toggle source

Check whether the current trace is snapshotting. See {Trace#is_snapshotting} for more details.

# File lib/app_dynamics/instrumenter.rb, line 90
def is_snapshotting
  current_trace && current_trace.is_snapshotting
end
process_sql(sql) click to toggle source
# File lib/app_dynamics/instrumenter.rb, line 106
def process_sql(sql)
  AppDynamics.lex_sql(sql) if is_snapshotting
rescue => e
  if config[:log_sql_parse_errors]
    config.logger.error "Failed to extract binds from SQL query. " \
                        "It's likely that this query uses more advanced syntax than we currently support. " \
                        "sql=#{sql.inspect}"
  end
  nil
end
set_snapshot_url(url) click to toggle source

Set the URL for the current trace's snapshot. See {Trace#set_snapshot_url} for more details.

# File lib/app_dynamics/instrumenter.rb, line 101
def set_snapshot_url(url)
  return unless current_trace
  current_trace.set_snapshot_url(url)
end
shutdown() click to toggle source
Calls superclass method
# File lib/app_dynamics/instrumenter.rb, line 69
def shutdown
  @background_metrics.stop if @background_metrics
  config.before_shutdown
  super
end
start!() click to toggle source
Calls superclass method
# File lib/app_dynamics/instrumenter.rb, line 31
def start!
  return nil unless super
  finalize_start unless config.get(:lazy_start)
  self
end