Class: Honeybadger::Config::Ruby Private

Inherits:
Mash
  • Object
show all
Defined in:
lib/honeybadger/config/ruby.rb

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

Constant Summary

Constants inherited from Mash

Mash::KEYS

Instance Method Summary collapse

Methods inherited from Mash

#initialize, #to_hash

Constructor Details

This class inherits a constructor from Honeybadger::Config::Mash

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Honeybadger::Config::Mash

Instance Method Details

#after_notify(action = nil) {|notice, response| ... } ⇒ Array<Proc>

Run a hook after each error notice delivery attempt.

The hook is called for every backend response, including successful deliveries. Response codes are usually HTTP status integers, but may be symbols such as :stubbed or :error for non-server backends or connection failures. Filter with exact response codes (e.g. ‘response.code == 413`) rather than broad integer comparisons, or use `response.success?`. (Note: `response.error_message` may raise for non-HTTP responses like `:stubbed`.)

Prefer ‘Honeybadger.event` for reporting failed notice deliveries. Calling `Honeybadger.notify` from this hook can trigger another after_notify call; guard against self-reporting loops if a notice must be sent.

Examples:

Report oversized notice payloads

config.after_notify do |notice, response|
  next unless response.code == 413

  Honeybadger.event("honeybadger.notice_rejected", {
    reason: "payload_too_large",
    notice_id: notice.id,
    payload_bytes: notice.to_json.bytesize
  })
end

Yield Parameters:

Returns:

  • (Array<Proc>)

    configured hooks



129
130
131
132
133
134
135
136
137
138
139
# File 'lib/honeybadger/config/ruby.rb', line 129

def after_notify(action = nil, &block)
  hooks = Array(get(:after_notify)).dup

  if action && validate_hook_action(action, "after notify", 2)
    hooks << action
  elsif block_given? && validate_hook_action(block, "after notify", 2)
    hooks << block
  end

  hash[:after_notify] = hooks
end

#backendObject

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.



85
86
87
# File 'lib/honeybadger/config/ruby.rb', line 85

def backend
  get(:backend) || config.backend
end

#backend=(backend) ⇒ 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.



81
82
83
# File 'lib/honeybadger/config/ruby.rb', line 81

def backend=(backend)
  hash[:backend] = backend
end

#backtrace_filter(&block) ⇒ 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.



153
154
155
156
157
158
159
160
# File 'lib/honeybadger/config/ruby.rb', line 153

def backtrace_filter(&block)
  if block_given?
    logger.warn("DEPRECATED: backtrace_filter is deprecated. Please use before_notify instead. See https://docs.honeybadger.io/ruby/support/v4-upgrade#backtrace_filter")
    hash[:backtrace_filter] = block if block_given?
  end

  get(:backtrace_filter)
end

#before_event(action = nil, &block) ⇒ 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.



141
142
143
144
145
146
147
148
149
150
151
# File 'lib/honeybadger/config/ruby.rb', line 141

def before_event(action = nil, &block)
  hooks = Array(get(:before_event)).dup

  if action && validate_hook_action(action, "before event", 1)
    hooks << action
  elsif block_given? && validate_hook_action(block, "before event", 1)
    hooks << block
  end

  hash[:before_event] = hooks
end

#before_notify(action = nil, &block) ⇒ 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.



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

def before_notify(action = nil, &block)
  hooks = Array(get(:before_notify)).dup

  if action && validate_hook_action(action, "before notify", 1)
    hooks << action
  elsif block_given? && validate_hook_action(block, "before notify", 1)
    hooks << block
  end

  hash[:before_notify] = hooks
end

#exception_filter(&block) ⇒ 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.



162
163
164
165
166
167
168
169
# File 'lib/honeybadger/config/ruby.rb', line 162

def exception_filter(&block)
  if block_given?
    logger.warn("DEPRECATED: exception_filter is deprecated. Please use before_notify instead. See https://docs.honeybadger.io/ruby/support/v4-upgrade#exception_filter")
    hash[:exception_filter] = block
  end

  get(:exception_filter)
end

#exception_fingerprint(&block) ⇒ 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.



171
172
173
174
175
176
177
178
# File 'lib/honeybadger/config/ruby.rb', line 171

def exception_fingerprint(&block)
  if block_given?
    logger.warn("DEPRECATED: exception_fingerprint is deprecated. Please use before_notify instead. See https://docs.honeybadger.io/ruby/support/v4-upgrade#exception_fingerprint")
    hash[:exception_fingerprint] = block
  end

  get(:exception_fingerprint)
end

#loggerObject

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.



77
78
79
# File 'lib/honeybadger/config/ruby.rb', line 77

def logger
  get(:logger) || config.logger
end

#logger=(logger) ⇒ 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.



73
74
75
# File 'lib/honeybadger/config/ruby.rb', line 73

def logger=(logger)
  hash[:logger] = logger
end