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/event.rb,
lib/honeybadger/gauge.rb,
lib/honeybadger/timer.rb,
lib/honeybadger/config.rb,
lib/honeybadger/metric.rb,
lib/honeybadger/notice.rb,
lib/honeybadger/plugin.rb,
lib/honeybadger/worker.rb,
lib/honeybadger/backend.rb,
lib/honeybadger/counter.rb,
lib/honeybadger/karafka.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/registry.rb,
lib/honeybadger/util/sql.rb,
lib/honeybadger/backtrace.rb,
lib/honeybadger/histogram.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/puma/plugin/honeybadger.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/metrics_worker.rb,
lib/honeybadger/plugins/lambda.rb,
lib/honeybadger/plugins/resque.rb,
lib/honeybadger/plugins/system.rb,
lib/honeybadger/plugins/warden.rb,
lib/honeybadger/util/sanitizer.rb,
lib/honeybadger/config/defaults.rb,
lib/honeybadger/context_manager.rb,
lib/honeybadger/instrumentation.rb,
lib/honeybadger/plugins/faktory.rb,
lib/honeybadger/plugins/karafka.rb,
lib/honeybadger/plugins/sidekiq.rb,
lib/honeybadger/plugins/net_http.rb,
lib/honeybadger/plugins/autotuner.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/registry_execution.rb,
lib/honeybadger/breadcrumbs/logging.rb,
lib/honeybadger/plugins/breadcrumbs.rb,
lib/honeybadger/plugins/delayed_job.rb,
lib/honeybadger/plugins/solid_queue.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/instrumentation_helper.rb,
lib/honeybadger/breadcrumbs/ring_buffer.rb,
lib/honeybadger/notification_subscriber.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, InstrumentationHelper, Karafka, Logging, Plugins, Rack, RakeHandler, Util Classes: ActionControllerCacheSubscriber, ActionControllerSubscriber, ActionMailerSubscriber, ActionViewSubscriber, ActiveJobSubscriber, ActiveRecordSubscriber, ActiveStorageSubscriber, ActiveSupportCacheMultiSubscriber, ActiveSupportCacheSubscriber, Agent, Backtrace, Config, ContextManager, Counter, Event, EventsWorker, Gauge, Histogram, Instrumentation, Metric, MetricsWorker, Notice, NotificationSubscriber, Plugin, PumaPlugin, Registry, RegistryExecution, Timer, 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.26.1'.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!

#collect(...) ⇒ Object



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

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

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



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

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

#decrement_counter(...) ⇒ Object



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

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

#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

#gauge(...) ⇒ Object



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

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

#get_context(...) ⇒ Object



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

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

#histogram(...) ⇒ Object



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

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

#increment_counter(...) ⇒ Object



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

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

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



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

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.



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

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

#instrumentation(...) ⇒ Object



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

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

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



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

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

#notify(...) ⇒ Object



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

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

#registry(...) ⇒ Object



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

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

#start(config = {}) ⇒ Object

Deprecated.

Raises:

  • (NoMethodError)


89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/honeybadger/singleton.rb', line 89

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

#time(...) ⇒ Object



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

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

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



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

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