class Airbrake::Config

rubocop:disable Metrics/ClassLength
@since v1.0.0
@api public
can use to configure an Airbrake instance.
Represents the Airbrake config. A config contains all the options that you

def blacklist_keys=(keys)

def blacklist_keys=(keys)
  loc = caller_locations(1..1).first
  Kernel.warn(
    "#{loc.path}:#{loc.lineno}: warning: blacklist_keys= is deprecated " \
    "use blocklist_keys= instead",
  )
  self.blocklist_keys = keys
end

def check_configuration

Returns:
  • (Promise) - resolved promise if config is valid & can notify,
def check_configuration
  promise = validate
  return promise if promise.rejected?
  check_notify_ability
end

def check_notify_ability

Other tags:
    See: Validator.check_notify_ability -

Returns:
  • (Promise) -
def check_notify_ability
  Validator.check_notify_ability(self)
end

def check_performance_options(resource)

Returns:
  • (Promise) - resolved promise if neither of the performance options
def check_performance_options(resource)
  promise = Airbrake::Promise.new
  if !performance_stats
    promise.reject("The Performance Stats feature is disabled")
  elsif resource.is_a?(Airbrake::Query) && !query_stats
    promise.reject("The Query Stats feature is disabled")
  elsif resource.is_a?(Airbrake::Queue) && !job_stats
    promise.reject("The Job Stats feature is disabled")
  else
    promise
  end
end

def error_endpoint

Returns:
  • (URI) - the endpoint address
def error_endpoint
  @error_endpoint ||=
    begin
      self.error_host = ('https://' << error_host) if error_host !~ %r{\Ahttps?://}
      api = "api/v3/projects/#{project_id}/notices"
      URI.join(error_host, api)
    end
end

def ignored_environment?

Returns:
  • (Boolean) - true if the config ignores current environment, false
def ignored_environment?
  check_notify_ability.rejected?
end

def initialize(user_config = {})

Parameters:
  • user_config (Hash{Symbol=>Object}) -- the hash to be used to build the
def initialize(user_config = {})
  self.proxy = {}
  self.queue_size = 100
  self.workers = 1
  self.code_hunks = true
  self.logger = ::Logger.new(File::NULL).tap { |l| l.level = Logger::WARN }
  self.project_id = user_config[:project_id]
  self.project_key = user_config[:project_key]
  self.error_host = 'https://api.airbrake.io'
  self.apm_host = 'https://api.airbrake.io'
  self.ignore_environments = []
  self.timeout = user_config[:timeout]
  self.blocklist_keys = []
  self.allowlist_keys = []
  self.root_directory = File.realpath(
    (defined?(Bundler) && Bundler.root) ||
    Dir.pwd,
  )
  self.versions = {}
  self.performance_stats = true
  self.performance_stats_flush_period = 15
  self.query_stats = true
  self.job_stats = true
  self.error_notifications = true
  self.__remote_configuration = false
  merge(user_config)
end

def instance

Returns:
  • (Config) -
def instance
  @instance ||= new
end

def logger=(logger)

Returns:
  • (Logger) - the logger
def logger=(logger)
  @logger = logger || @logger
end

def merge(config_hash)

Returns:
  • (self) - the merged config
def merge(config_hash)
  config_hash.each_pair { |option, value| set_option(option, value) }
  self
end

def set_option(option, value)

def set_option(option, value)
  __send__("#{option}=", value)
rescue NoMethodError
  raise Airbrake::Error, "unknown option '#{option}'"
end

def valid?

Returns:
  • (Boolean) - true if the config meets the requirements, false
def valid?
  validate.resolved?
end

def validate

Other tags:
    See: Validator.validate -

Returns:
  • (Promise) -
def validate
  Validator.validate(self)
end

def whitelist_keys=(keys)

def whitelist_keys=(keys)
  loc = caller_locations(1..1).first
  Kernel.warn(
    "#{loc.path}:#{loc.lineno}: warning: whitelist_keys= is deprecated " \
    "use allowlist_keys= instead",
  )
  self.allowlist_keys = keys
end