Module: Honeybadger

Extended by:
Forwardable, Honeybadger
Included in:
Honeybadger
Defined in:
lib/honeybadger/singleton.rb,
lib/honeybadger/cli.rb,
lib/honeybadger/agent.rb,
lib/honeybadger/const.rb,
lib/honeybadger/config.rb,
lib/honeybadger/notice.rb,
lib/honeybadger/plugin.rb,
lib/honeybadger/worker.rb,
lib/honeybadger/backend.rb,
lib/honeybadger/logging.rb,
lib/honeybadger/version.rb,
lib/honeybadger/cli/exec.rb,
lib/honeybadger/cli/main.rb,
lib/honeybadger/cli/test.rb,
lib/honeybadger/backtrace.rb,
lib/honeybadger/init/rake.rb,
lib/honeybadger/util/http.rb,
lib/honeybadger/cli/deploy.rb,
lib/honeybadger/cli/heroku.rb,
lib/honeybadger/cli/notify.rb,
lib/honeybadger/config/env.rb,
lib/honeybadger/init/rails.rb,
lib/honeybadger/util/stats.rb,
lib/honeybadger/cli/helpers.rb,
lib/honeybadger/cli/install.rb,
lib/honeybadger/config/ruby.rb,
lib/honeybadger/config/yaml.rb,
lib/honeybadger/conversions.rb,
lib/honeybadger/backend/base.rb,
lib/honeybadger/backend/null.rb,
lib/honeybadger/backend/test.rb,
lib/honeybadger/init/sinatra.rb,
lib/honeybadger/plugins/thor.rb,
lib/honeybadger/backend/debug.rb,
lib/honeybadger/plugins/rails.rb,
lib/honeybadger/util/revision.rb,
lib/honeybadger/backend/server.rb,
lib/honeybadger/plugins/resque.rb,
lib/honeybadger/plugins/warden.rb,
lib/honeybadger/util/sanitizer.rb,
lib/honeybadger/config/defaults.rb,
lib/honeybadger/context_manager.rb,
lib/honeybadger/plugins/sidekiq.rb,
lib/honeybadger/plugins/passenger.rb,
lib/honeybadger/plugins/shoryuken.rb,
lib/honeybadger/util/request_hash.rb,
lib/honeybadger/rack/user_feedback.rb,
lib/honeybadger/rack/user_informer.rb,
lib/honeybadger/plugins/delayed_job.rb,
lib/honeybadger/rack/error_notifier.rb,
lib/honeybadger/plugins/sucker_punch.rb,
lib/honeybadger/util/request_payload.rb,
lib/honeybadger/plugins/local_variables.rb,
lib/honeybadger/plugins/delayed_job/plugin.rb

Overview

Honeybadger's public API is made up of two parts: the Honeybadger singleton module, and the Agent class. The singleton module delegates its methods to a global agent instance, Agent.instance; this allows methods to be accessed directly, for example when calling Honeybadger.notify:

begin
  raise 'testing an error report'
rescue => err
  Honeybadger.notify(err)
end

Custom agents may also be created by users who want to report to multiple Honeybadger projects in the same app (or have fine-grained control over configuration), however most users will use the global agent.

See Also:

Defined Under Namespace

Modules: Backend, CLI, Conversions, Init, Logging, Plugins, Rack, RakeHandler, Util Classes: Agent, Backtrace, Config, ContextManager, Notice, Plugin, Worker

Constant Summary collapse

NOTIFIER =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

{
  name: 'honeybadger-ruby'.freeze,
  url: 'https://github.com/honeybadger-io/honeybadger-ruby'.freeze,
  version: VERSION,
  language: 'ruby'.freeze
}.freeze
GEM_ROOT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Substitution for gem root in backtrace lines.

'[GEM_ROOT]'.freeze
PROJECT_ROOT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Substitution for project root in backtrace lines.

'[PROJECT_ROOT]'.freeze
STRING_EMPTY =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Empty String (used for equality comparisons and assignment).

''.freeze
NOT_BLANK =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

A Regexp which matches non-blank characters.

/\S/.freeze
RELATIVE_ROOT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Matches lines beginning with ./

Regexp.new('^\.\/').freeze
MAX_EXCEPTION_CAUSES =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

5
VERSION =

The current String Honeybadger version.

'3.3.0'.freeze

Instance Method Summary collapse

Instance Method Details

#backtrace_filter(...) ⇒ Object



36
# File 'lib/honeybadger/singleton.rb', line 36

def_delegator :'Honeybadger::Agent.instance', :backtrace_filter

#check_in(...) ⇒ Object



28
# File 'lib/honeybadger/singleton.rb', line 28

def_delegator :'Honeybadger::Agent.instance', :check_in

#config(...) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Forwards to Honeybadger::Agent.instance.



43
# File 'lib/honeybadger/singleton.rb', line 43

def_delegator :'Honeybadger::Agent.instance', :config

#configure(...) ⇒ Object



30
# File 'lib/honeybadger/singleton.rb', line 30

def_delegator :'Honeybadger::Agent.instance', :configure

#context(...) ⇒ Object



29
# File 'lib/honeybadger/singleton.rb', line 29

def_delegator :'Honeybadger::Agent.instance', :context

#exception_filter(...) ⇒ Object



34
# File 'lib/honeybadger/singleton.rb', line 34

def_delegator :'Honeybadger::Agent.instance', :exception_filter

#exception_fingerprint(...) ⇒ Object



35
# File 'lib/honeybadger/singleton.rb', line 35

def_delegator :'Honeybadger::Agent.instance', :exception_fingerprint

#flush(...) ⇒ Object



32
# File 'lib/honeybadger/singleton.rb', line 32

def_delegator :'Honeybadger::Agent.instance', :flush

#get_context(...) ⇒ Object



31
# File 'lib/honeybadger/singleton.rb', line 31

def_delegator :'Honeybadger::Agent.instance', :get_context

#init!(...) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Forwards to Honeybadger::Agent.instance.



44
# File 'lib/honeybadger/singleton.rb', line 44

def_delegator :'Honeybadger::Agent.instance', :init!

#install_at_exit_callbackObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



65
66
67
68
69
70
71
72
73
# File 'lib/honeybadger/singleton.rb', line 65

def install_at_exit_callback
  at_exit do
    if $! && !$!.is_a?(SystemExit) && Honeybadger.config[:'exceptions.notify_at_exit']
      Honeybadger.notify($!, component: 'at_exit', sync: true)
    end

    Honeybadger.stop if Honeybadger.config[:'send_data_at_exit']
  end
end

#load_plugins!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



57
58
59
60
61
62
# File 'lib/honeybadger/singleton.rb', line 57

def load_plugins!
  Dir[File.expand_path('../plugins/*.rb', __FILE__)].each do |plugin|
    require plugin
  end
  Plugin.load!(self.config)
end

#notify(...) ⇒ Object



50
51
52
53
54
# File 'lib/honeybadger/singleton.rb', line 50

def notify(exception_or_opts, opts = {})
  # Note this is defined directly (instead of via forwardable) so that
  # generated stack traces work as expected.
  Agent.instance.notify(exception_or_opts, opts)
end

#start(config = {}) ⇒ Object

Deprecated.

Raises:

  • (NoMethodError)


76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/honeybadger/singleton.rb', line 76

def start(config = {})
  raise NoMethodError, <<-WARNING
`Honeybadger.start` is no longer necessary and has been removed.

Use `Honeybadger.configure` to explicitly configure the agent from Ruby moving forward:

Honeybadger.configure do |config|
  config.api_key = 'project api key'
  config.exceptions.ignore += [CustomError]
end
WARNING
end

#stop(...) ⇒ Object



33
# File 'lib/honeybadger/singleton.rb', line 33

def_delegator :'Honeybadger::Agent.instance', :stop

#with_rack_env(...) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Forwards to Honeybadger::Agent.instance.



45
# File 'lib/honeybadger/singleton.rb', line 45

def_delegator :'Honeybadger::Agent.instance', :with_rack_env