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/util/sql.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/breadcrumbs.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/util/lambda.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/events_worker.rb,
lib/honeybadger/plugins/rails.rb,
lib/honeybadger/util/revision.rb,
lib/honeybadger/backend/server.rb,
lib/honeybadger/plugins/lambda.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/faktory.rb,
lib/honeybadger/plugins/karafka.rb,
lib/honeybadger/plugins/sidekiq.rb,
lib/honeybadger/plugins/passenger.rb,
lib/honeybadger/plugins/shoryuken.rb,
lib/honeybadger/util/request_hash.rb,
lib/honeybadger/plugins/active_job.rb,
lib/honeybadger/rack/user_feedback.rb,
lib/honeybadger/rack/user_informer.rb,
lib/honeybadger/breadcrumbs/logging.rb,
lib/honeybadger/plugins/breadcrumbs.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/breadcrumbs/collector.rb,
lib/honeybadger/breadcrumbs/breadcrumb.rb,
lib/honeybadger/breadcrumbs/ring_buffer.rb,
lib/honeybadger/plugins/local_variables.rb,
lib/honeybadger/breadcrumbs/active_support.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, Breadcrumbs, CLI, Conversions, Init, Logging, Plugins, Rack, RakeHandler, Util Classes: Agent, Backtrace, Config, ContextManager, EventsWorker, 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
BINDING_HAS_SOURCE_LOCATION =

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.

Binding#source_location was added in Ruby 2.6.

Binding.method_defined?(:source_location)
VERSION =

The current String Honeybadger version.

'5.8.0'.freeze

Instance Method Summary collapse

Instance Method Details

#add_breadcrumb(...) ⇒ Object



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

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

#backtrace_filter(...) ⇒ Object



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

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


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

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

#check_in(...) ⇒ Object



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

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

#clear!(...) ⇒ Object



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

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

#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.



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

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

#event(...) ⇒ Object



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

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

#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.



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

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.



70
71
72
73
74
75
76
77
78
# File 'lib/honeybadger/singleton.rb', line 70

def install_at_exit_callback
  at_exit do
    if $! && !ignored_exception?($!) && 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.



62
63
64
65
66
67
# File 'lib/honeybadger/singleton.rb', line 62

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

#notify(...) ⇒ Object



55
56
57
58
59
# File 'lib/honeybadger/singleton.rb', line 55

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

#start(config = {}) ⇒ Object

Deprecated.

Raises:

  • (NoMethodError)


81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/honeybadger/singleton.rb', line 81

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

#track_deployment(...) ⇒ Object



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

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

#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.



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

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