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/flipper.rb,
lib/honeybadger/plugins/flipper.rb,
lib/honeybadger/plugins/karafka.rb,
lib/honeybadger/plugins/sidekiq.rb,
lib/honeybadger/plugins/net_http.rb,
lib/honeybadger/plugins/ruby_llm.rb,
lib/honeybadger/plugins/ruby_llm.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/active_agent.rb,
lib/honeybadger/plugins/active_agent.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, ActiveAgentSubscriber, ActiveJobSubscriber, ActiveRecordSubscriber, ActiveStorageSubscriber, ActiveSupportCacheMultiSubscriber, ActiveSupportCacheSubscriber, Agent, Backtrace, Config, ContextManager, Counter, Event, EventsWorker, FlipperSubscriber, Gauge, Histogram, Instrumentation, Metric, MetricsWorker, Notice, NotificationSubscriber, Plugin, PumaPlugin, RailsSubscriber, Registry, RegistryExecution, RubyLLMSubscriber, 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.

API:

  • private

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

API:

  • private

"[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.

API:

  • private

"[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).

API:

  • private

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

API:

  • private

/\S/
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 ./

API:

  • private

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.

API:

  • private

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.

API:

  • private

Binding.method_defined?(:source_location)
VERSION =

The current String Honeybadger version.

"6.9.1".freeze

Instance Method Summary collapse

Instance Method Details

#add_breadcrumb(...) ⇒ Object



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

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

#backtrace_filter(...) ⇒ Object



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

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


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

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



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

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

#collect(...) ⇒ Object



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

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.

See Also:

API:

  • private



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

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

#configure(...) ⇒ Object



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

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



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

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

#event(...) ⇒ Object



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

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

#event_context(...) ⇒ Object



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

def_delegator :"Honeybadger::Agent.instance", :event_context

#exception_filter(...) ⇒ Object



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

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

#exception_fingerprint(...) ⇒ Object



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

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

#flush(...) ⇒ Object



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

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

#gauge(...) ⇒ Object



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

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

#get_context(...) ⇒ Object



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

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

#get_event_context(...) ⇒ Object



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

def_delegator :"Honeybadger::Agent.instance", :get_event_context

#histogram(...) ⇒ Object



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

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

#increment_counter(...) ⇒ Object



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

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.

See Also:

API:

  • private



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

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.

API:

  • private



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

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



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

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.

API:

  • private



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

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

#notify(...) ⇒ Object



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

def notify(exception_or_opts = nil, **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

#registry(...) ⇒ Object



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

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

#start(config = {}) ⇒ Object

Deprecated.

Raises:



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

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



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

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

#time(...) ⇒ Object



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

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

#track_deployment(...) ⇒ Object



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

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.

See Also:

API:

  • private



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

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