module OneApm::Manager

Public Instance Methods

add_custom_parameters(params) click to toggle source
# File lib/one_apm/manager.rb, line 210
def add_custom_parameters(params)
  if params.is_a? Hash
    txn = Transaction.tl_current
    txn.add_custom_parameters(params) if txn
  else
    ::OneApm::Manager.logger.warn("Bad argument passed to #add_custom_parameters. Expected Hash but got #{params.class}")
  end
end
add_instrumentation(file_pattern) click to toggle source
# File lib/one_apm/manager.rb, line 125
def add_instrumentation(file_pattern)
  OneApm::Probe.instance.add_instrumentation file_pattern
end
after_fork(options = {}) click to toggle source
# File lib/one_apm/manager.rb, line 105
def after_fork(options = {})
  agent.after_fork(options)
end
agent() click to toggle source
# File lib/one_apm/manager.rb, line 52
def agent
  return @agent if @agent
  OneApm::Manager.logger.warn("Agent unavailable as it hasn't been started.")
  OneApm::Manager.logger.warn(caller.join("\n"))
  nil
end
agent=(new_agent) click to toggle source
# File lib/one_apm/manager.rb, line 59
def agent=(new_agent)
  @agent = new_agent
end
agent_should_start?() click to toggle source
# File lib/one_apm/manager.rb, line 249
def agent_should_start?
    !blacklisted_constants? &&
    !blacklisted_executables? &&
    !in_blacklisted_rake_task?
end
blacklisted?(value, &block) click to toggle source
# File lib/one_apm/manager.rb, line 267
def blacklisted?(value, &block)
  value.split(/\s*,\s*/).any?(&block)
end
blacklisted_constants?() click to toggle source
# File lib/one_apm/manager.rb, line 255
def blacklisted_constants?
  blacklisted?(OneApm::Manager.config[:'autostart.blacklisted_constants']) do |name|
    OneApm::LanguageSupport.constant_is_defined?(name)
  end
end
blacklisted_executables?() click to toggle source
# File lib/one_apm/manager.rb, line 261
def blacklisted_executables?
  blacklisted?(OneApm::Manager.config[:'autostart.blacklisted_executables']) do |bin|
    File.basename($0) == bin
  end
end
browser_timing_header() click to toggle source
# File lib/one_apm/manager.rb, line 240
def browser_timing_header
  agent.javascript_instrumentor.browser_timing_header
end
config() click to toggle source
# File lib/one_apm/manager.rb, line 92
def config
  @config ||= OneApm::Configuration::Manager.new
end
disable_all_tracing() { || ... } click to toggle source
# File lib/one_apm/manager.rb, line 166
def disable_all_tracing
  agent.push_trace_execution_flag(false)
  yield
ensure
  agent.pop_trace_execution_flag
end
disable_sql_recording() { || ... } click to toggle source
# File lib/one_apm/manager.rb, line 133
def disable_sql_recording
  state = agent.set_record_sql(false)
  begin
    yield
  ensure
    agent.set_record_sql(state)
  end
end
disable_transaction_tracing() { || ... } click to toggle source
# File lib/one_apm/manager.rb, line 142
def disable_transaction_tracing
  state = agent.set_record_tt(false)
  begin
    yield
  ensure
    agent.set_record_tt(state)
  end
end
drop_buffered_data() click to toggle source
# File lib/one_apm/manager.rb, line 121
def drop_buffered_data
  agent.drop_buffered_data
end
get_transaction_name() click to toggle source
# File lib/one_apm/manager.rb, line 223
def get_transaction_name
  txn = Transaction.tl_current
  if txn
    txn.best_name.sub(Regexp.new("\\A#{Regexp.escape(OneApm::TransactionNamer.prefix_for_category(txn))}"), '')
  end
end
ignore_apdex() click to toggle source
# File lib/one_apm/manager.rb, line 156
def ignore_apdex
  txn = OneApm::Transaction.tl_current
  txn.ignore_apdex! if txn
end
ignore_enduser() click to toggle source
# File lib/one_apm/manager.rb, line 161
def ignore_enduser
  txn = OneApm::Transaction.tl_current
  txn.ignore_enduser! if txn
end
ignore_error_filter(&block) click to toggle source
# File lib/one_apm/manager.rb, line 192
def ignore_error_filter(&block)
  if block
    OneApm::Collector::ErrorCollector.ignore_error_filter = block
  else
    OneApm::Collector::ErrorCollector.ignore_error_filter
  end
end
ignore_transaction() click to toggle source
# File lib/one_apm/manager.rb, line 151
def ignore_transaction
  txn = OneApm::Transaction.tl_current
  txn.ignore! if txn
end
in_blacklisted_rake_task?() click to toggle source
# File lib/one_apm/manager.rb, line 271
def in_blacklisted_rake_task?
  tasks = begin
            ::Rake.application.top_level_tasks
          rescue => e
            OneApm::Manager.logger.debug("Not in Rake environment so skipping blacklisted_rake_tasks check: #{e}")
            []
          end
  !(tasks & OneApm::Manager.config[:'autostart.blacklisted_rake_tasks'].split(/\s*,\s*/)).empty?
end
increment_metric(metric_name, amount = 1) click to toggle source
# File lib/one_apm/manager.rb, line 115
def increment_metric(metric_name, amount = 1)
  agent.stats_engine.tl_record_unscoped_metrics(metric_name) do |stats|
    stats.increment_count(amount)
  end
end
logger() click to toggle source
# File lib/one_apm/manager.rb, line 84
def logger
  @logger || OneApm::Logger::StartupLogger.instance
end
logger=(log) click to toggle source
# File lib/one_apm/manager.rb, line 88
def logger=(log)
  @logger = log
end
manual_start(options = {})
Alias for: start
notice_error(exception, options = {}) click to toggle source
# File lib/one_apm/manager.rb, line 200
def notice_error(exception, options = {})
  Transaction.notice_error(exception, options)
  nil
end
notice_sql(sql, metric, config, elapsed_time, state, &explainer) click to toggle source
# File lib/one_apm/manager.rb, line 205
def notice_sql(sql, metric, config, elapsed_time, state, &explainer)
  agent.transaction_sampler.notice_sql(sql, config, elapsed_time, state, &explainer)
  agent.sql_sampler.notice_sql(sql, metric, config, elapsed_time, state, &explainer)
end
notify(event_type, *args) click to toggle source
# File lib/one_apm/manager.rb, line 234
def notify(event_type, *args)
  agent.events.notify( event_type, *args )
rescue
  OneApm::Manager.logger.debug "Ignoring exception during %p event notification" % [event_type]
end
record_custom_event(event_type, event_attrs) click to toggle source
# File lib/one_apm/manager.rb, line 173
def record_custom_event(event_type, event_attrs)
  if agent && OneApm::Manager.config[:'custom_insights_events.enabled']
    agent.custom_event_aggregator.record(event_type, event_attrs)
  end
  nil
end
record_metric(metric_name, value) click to toggle source
# File lib/one_apm/manager.rb, line 109
def record_metric(metric_name, value)
  value_to_store = value
  value_to_store = OneApm::Metrics::Stats.create_from_hash(value) if value.is_a?(Hash)
  agent.stats_engine.tl_record_unscoped_metrics(metric_name, value_to_store)
end
require_test_helper() click to toggle source
# File lib/one_apm/manager.rb, line 244
def require_test_helper
  path = File.join(__FILE__, '..', '..', '..', 'test', 'agent_helper')
  require File.expand_path(path)
end
reset_config() click to toggle source
# File lib/one_apm/manager.rb, line 96
def reset_config
  @config.reset_to_defaults
end
restart() click to toggle source
# File lib/one_apm/manager.rb, line 75
def restart
  shutdown
  agent.harvest_samplers.clear
  agent.instance_variable_set(:@connect_state, :pending)
  agent.instance_variable_set(:@worker_thread, nil)
  agent.harvester.instance_variable_set(:@starting_pid, nil)
  OneApm::Probe.init({:agent_enabled => true, :sync_startup => true})
end
revert_to_default_configuration() click to toggle source
# File lib/one_apm/manager.rb, line 100
def revert_to_default_configuration
  @config.remove_config_type(:manual)
  @config.remove_config_type(:server)
end
set_sql_obfuscator(type = :replace, &block) click to toggle source
# File lib/one_apm/manager.rb, line 129
def set_sql_obfuscator(type = :replace, &block)
  OneApm::Agent::Database.set_sql_obfuscator(type, &block)
end
set_transaction_name(name, options={}) click to toggle source
# File lib/one_apm/manager.rb, line 219
def set_transaction_name(name, options={})
  Transaction.set_overriding_transaction_name(name, options[:category])
end
shutdown(options={}) click to toggle source
# File lib/one_apm/manager.rb, line 71
def shutdown(options={})
  agent.shutdown(options) if agent
end
start(options = {}) click to toggle source
# File lib/one_apm/manager.rb, line 63
def start(options = {})
  raise "Options must be a hash" unless Hash === options
  OneApm::Support::ForkedProcessChannel.listener.start if options[:start_channel_listener]
  OneApm::Probe.init({:agent_enabled => true, :sync_startup => true}.merge(options))
end
Also aliased as: manual_start
subscribe(event_type, &handler) click to toggle source
# File lib/one_apm/manager.rb, line 230
def subscribe(event_type, &handler)
  agent.events.subscribe( event_type, &handler )
end
tl_is_execution_traced?() click to toggle source
# File lib/one_apm/manager.rb, line 180
def tl_is_execution_traced?
  OneApm::TransactionState.tl_get.is_execution_traced?
end
tl_is_sql_recorded?() click to toggle source
# File lib/one_apm/manager.rb, line 188
def tl_is_sql_recorded?
  OneApm::TransactionState.tl_get.is_sql_recorded?
end
tl_is_transaction_traced?() click to toggle source
# File lib/one_apm/manager.rb, line 184
def tl_is_transaction_traced?
  OneApm::TransactionState.tl_get.is_transaction_traced?
end