Module: Airbrake
- Defined in:
- lib/airbrake-ruby.rb,
lib/airbrake-ruby/stat.rb,
lib/airbrake-ruby/query.rb,
lib/airbrake-ruby/queue.rb,
lib/airbrake-ruby/config.rb,
lib/airbrake-ruby/notice.rb,
lib/airbrake-ruby/backlog.rb,
lib/airbrake-ruby/context.rb,
lib/airbrake-ruby/promise.rb,
lib/airbrake-ruby/request.rb,
lib/airbrake-ruby/tdigest.rb,
lib/airbrake-ruby/version.rb,
lib/airbrake-ruby/loggable.rb,
lib/airbrake-ruby/response.rb,
lib/airbrake-ruby/backtrace.rb,
lib/airbrake-ruby/benchmark.rb,
lib/airbrake-ruby/code_hunk.rb,
lib/airbrake-ruby/ignorable.rb,
lib/airbrake-ruby/mergeable.rb,
lib/airbrake-ruby/stashable.rb,
lib/airbrake-ruby/truncator.rb,
lib/airbrake-ruby/file_cache.rb,
lib/airbrake-ruby/grouppable.rb,
lib/airbrake-ruby/inspectable.rb,
lib/airbrake-ruby/sync_sender.rb,
lib/airbrake-ruby/thread_pool.rb,
lib/airbrake-ruby/timed_trace.rb,
lib/airbrake-ruby/async_sender.rb,
lib/airbrake-ruby/filter_chain.rb,
lib/airbrake-ruby/hash_keyable.rb,
lib/airbrake-ruby/time_truncate.rb,
lib/airbrake-ruby/monotonic_time.rb,
lib/airbrake-ruby/deploy_notifier.rb,
lib/airbrake-ruby/notice_notifier.rb,
lib/airbrake-ruby/remote_settings.rb,
lib/airbrake-ruby/config/processor.rb,
lib/airbrake-ruby/config/validator.rb,
lib/airbrake-ruby/nested_exception.rb,
lib/airbrake-ruby/filters/sql_filter.rb,
lib/airbrake-ruby/filters/keys_filter.rb,
lib/airbrake-ruby/performance_notifier.rb,
lib/airbrake-ruby/filters/thread_filter.rb,
lib/airbrake-ruby/performance_breakdown.rb,
lib/airbrake-ruby/filters/context_filter.rb,
lib/airbrake-ruby/filters/keys_allowlist.rb,
lib/airbrake-ruby/filters/keys_blocklist.rb,
lib/airbrake-ruby/filters/gem_root_filter.rb,
lib/airbrake-ruby/remote_settings/callback.rb,
lib/airbrake-ruby/filters/dependency_filter.rb,
lib/airbrake-ruby/filters/system_exit_filter.rb,
lib/airbrake-ruby/filters/git_revision_filter.rb,
lib/airbrake-ruby/filters/git_repository_filter.rb,
lib/airbrake-ruby/filters/root_directory_filter.rb,
lib/airbrake-ruby/remote_settings/settings_data.rb,
lib/airbrake-ruby/filters/git_last_checkout_filter.rb,
lib/airbrake-ruby/filters/exception_attributes_filter.rb
Overview
We use Semantic Versioning v2.0.0 More information: semver.org/
Defined Under Namespace
Modules: Backtrace, FileCache, Filters, Grouppable, HashKeyable, Ignorable, Inspectable, Loggable, Mergeable, MonotonicTime, Response, Stashable, TimeTruncate Classes: AsyncSender, Backlog, Benchmark, CodeHunk, Config, Context, DeployNotifier, FilterChain, NestedException, Notice, NoticeNotifier, PerformanceBreakdown, PerformanceNotifier, Promise, Query, Queue, RemoteSettings, Request, Stat, SyncSender, TDigest, ThreadPool, TimedTrace, Truncator
Constant Summary collapse
- Error =
The general error that this library uses when it wants to raise.
Class.new(StandardError)
- LOG_LABEL =
Returns the label to be prepended to the log output.
'**Airbrake:'.freeze
- JRUBY =
Returns true if current Ruby is JRuby. The result is used for special cases where we need to work around older implementations.
(RUBY_ENGINE == 'jruby')
- HAS_SAFE_LEVEL =
Returns true if this Ruby supports safe levels and tainting, to guard against using deprecated or unsupported features.
( RUBY_ENGINE == 'ruby' && Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.7') )
- AIRBRAKE_RUBY_VERSION =
Returns the library version.
'6.2.2'.freeze
- NOTIFIER_INFO =
Returns the information about the notifier library.
{ name: 'airbrake-ruby'.freeze, version: Airbrake::AIRBRAKE_RUBY_VERSION, url: 'https://github.com/airbrake/airbrake-ruby'.freeze, }.freeze
Class Attribute Summary collapse
- .deploy_notifier ⇒ Object private
- .notice_notifier ⇒ Object private
- .performance_notifier ⇒ Object private
Class Method Summary collapse
-
.add_filter(filter = nil) {|notice| ... } ⇒ void
Runs a callback before Airbrake.notify or Airbrake.notify_sync kicks in.
-
.add_performance_filter(filter = nil) {|metric| ... } ⇒ void
Runs a callback before Airbrake.notify_request, Airbrake.notify_query, Airbrake.notify_queue or Airbrake.notify_performance_breakdown kicks in.
-
.build_notice(exception, params = {}) ⇒ Airbrake::Notice
Builds an Airbrake notice.
-
.close ⇒ nil
Makes the notice notifier a no-op, which means you cannot use the Airbrake.notify and Airbrake.notify_sync methods anymore.
-
.configure {|config| ... } ⇒ void
Configures the Airbrake notifier.
-
.configured? ⇒ Boolean
True if the notifier was configured, false otherwise.
-
.delete_filter(filter_class) ⇒ void
Deletes a filter added via Airbrake.add_filter.
-
.delete_performance_filter(filter_class) ⇒ void
Deletes a filter added via Airbrake.add_performance_filter.
-
.merge_context(context) ⇒ void
Merges
context
with the current context. -
.notify(exception, params = {}) {|notice| ... } ⇒ Airbrake::Promise
Sends an exception to Airbrake asynchronously.
-
.notify_deploy(deploy_info) ⇒ void
Pings the Airbrake Deploy API endpoint about the occurred deploy.
-
.notify_performance_breakdown(breakdown_info, stash = {}) ⇒ void
Increments performance breakdown statistics of a certain route.
-
.notify_performance_breakdown_sync(breakdown_info, stash = {}) ⇒ Object
Increments performance breakdown statistics of a certain route synchronously.
-
.notify_query(query_info, stash = {}) ⇒ void
Increments SQL statistics of a certain
query
. -
.notify_query_sync(query_info, stash = {}) ⇒ Object
Synchronously increments SQL statistics of a certain
query
. -
.notify_queue(queue_info, stash = {}) ⇒ void
Increments statistics of a certain queue (worker).
-
.notify_queue_sync(queue_info, stash = {}) ⇒ Object
Increments statistics of a certain queue (worker) synchronously.
-
.notify_request(request_info, stash = {}) ⇒ void
Increments request statistics of a certain
route
invoked withmethod
, which returnedstatus_code
. -
.notify_request_sync(request_info, stash = {}) ⇒ Object
Synchronously increments request statistics of a certain
route
invoked withmethod
, which returnedstatus_code
. -
.notify_sync(exception, params = {}) {|notice| ... } ⇒ Airbrake::Promise
Sends an exception to Airbrake synchronously.
-
.reset ⇒ void
Resets all notifiers, including its filters.
Class Attribute Details
.deploy_notifier ⇒ 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.
151 152 153 |
# File 'lib/airbrake-ruby.rb', line 151 def deploy_notifier @deploy_notifier ||= DeployNotifier.new end |
.notice_notifier ⇒ 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.
145 146 147 |
# File 'lib/airbrake-ruby.rb', line 145 def notice_notifier @notice_notifier ||= NoticeNotifier.new end |
.performance_notifier ⇒ 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.
139 140 141 |
# File 'lib/airbrake-ruby.rb', line 139 def performance_notifier @performance_notifier ||= PerformanceNotifier.new end |
Class Method Details
.add_filter(filter = nil) {|notice| ... } ⇒ void
This method returns an undefined value.
Runs a callback before notify or notify_sync kicks in. This is useful if you want to ignore specific notices or filter the data the notice contains.
230 231 232 |
# File 'lib/airbrake-ruby.rb', line 230 def add_filter(filter = nil, &block) notice_notifier.add_filter(filter, &block) end |
.add_performance_filter(filter = nil) {|metric| ... } ⇒ void
This method returns an undefined value.
Runs a callback before notify_request, notify_query, notify_queue or notify_performance_breakdown kicks in. This is useful if you want to ignore specific metrics or filter the data the metric contains.
558 559 560 |
# File 'lib/airbrake-ruby.rb', line 558 def add_performance_filter(filter = nil, &block) performance_notifier.add_filter(filter, &block) end |
.build_notice(exception, params = {}) ⇒ Airbrake::Notice
Builds an Airbrake notice. This is useful, if you want to add or modify a value only for a specific notice. When you’re done modifying the notice, send it with notify or notify_sync.
265 266 267 |
# File 'lib/airbrake-ruby.rb', line 265 def build_notice(exception, params = {}) notice_notifier.build_notice(exception, params) end |
.close ⇒ nil
Makes the notice notifier a no-op, which means you cannot use the notify and notify_sync methods anymore. It also stops the notice notifier’s worker threads.
rubocop:disable Style/IfUnlessModifier
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
# File 'lib/airbrake-ruby.rb', line 279 def close if defined?(@notice_notifier) && @notice_notifier @notice_notifier.close end if defined?(@performance_notifier) && @performance_notifier @performance_notifier.close end if defined?(@remote_settings) && @remote_settings @remote_settings.stop_polling end nil end |
.configure {|config| ... } ⇒ void
This method returns an undefined value.
Configures the Airbrake notifier.
123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/airbrake-ruby.rb', line 123 def configure yield config = Airbrake::Config.instance Airbrake::Loggable.instance = config.logger config_processor = Airbrake::Config::Processor.new(config) config_processor.process_blocklist(notice_notifier) config_processor.process_allowlist(notice_notifier) @remote_settings ||= config_processor.process_remote_configuration config_processor.add_filters(notice_notifier) end |
.configured? ⇒ Boolean
Returns true if the notifier was configured, false otherwise.
157 158 159 |
# File 'lib/airbrake-ruby.rb', line 157 def configured? @notice_notifier && @notice_notifier.configured? end |
.delete_filter(filter_class) ⇒ void
This method cannot delete filters assigned via the Proc form.
This method returns an undefined value.
Deletes a filter added via add_filter.
247 248 249 |
# File 'lib/airbrake-ruby.rb', line 247 def delete_filter(filter_class) notice_notifier.delete_filter(filter_class) end |
.delete_performance_filter(filter_class) ⇒ void
This method cannot delete filters assigned via the Proc form.
This method returns an undefined value.
Deletes a filter added via add_performance_filter.
576 577 578 |
# File 'lib/airbrake-ruby.rb', line 576 def delete_performance_filter(filter_class) performance_notifier.delete_filter(filter_class) end |
.merge_context(context) ⇒ void
This method returns an undefined value.
Merges context
with the current context.
The context will be attached to the notice object upon a notify call and cleared after it’s attached. The context data is attached to the ‘params/airbrake_context` key.
353 354 355 |
# File 'lib/airbrake-ruby.rb', line 353 def merge_context(context) notice_notifier.merge_context(context) end |
.notify(exception, params = {}) {|notice| ... } ⇒ Airbrake::Promise
Sends an exception to Airbrake asynchronously.
182 183 184 |
# File 'lib/airbrake-ruby.rb', line 182 def notify(exception, params = {}, &block) notice_notifier.notify(exception, params, &block) end |
.notify_deploy(deploy_info) ⇒ void
This method returns an undefined value.
Pings the Airbrake Deploy API endpoint about the occurred deploy.
305 306 307 |
# File 'lib/airbrake-ruby.rb', line 305 def notify_deploy(deploy_info) deploy_notifier.notify(deploy_info) end |
.notify_performance_breakdown(breakdown_info, stash = {}) ⇒ void
This method returns an undefined value.
Increments performance breakdown statistics of a certain route.
474 475 476 477 478 |
# File 'lib/airbrake-ruby.rb', line 474 def notify_performance_breakdown(breakdown_info, stash = {}) performance_breakdown = PerformanceBreakdown.new(**breakdown_info) performance_breakdown.stash.merge!(stash) performance_notifier.notify(performance_breakdown) end |
.notify_performance_breakdown_sync(breakdown_info, stash = {}) ⇒ Object
Increments performance breakdown statistics of a certain route synchronously.
484 485 486 487 488 |
# File 'lib/airbrake-ruby.rb', line 484 def notify_performance_breakdown_sync(breakdown_info, stash = {}) performance_breakdown = PerformanceBreakdown.new(**breakdown_info) performance_breakdown.stash.merge!(stash) performance_notifier.notify_sync(performance_breakdown) end |
.notify_query(query_info, stash = {}) ⇒ void
This method returns an undefined value.
Increments SQL statistics of a certain query
. When method
and route
are provided, the query is grouped by these parameters.
After a certain amount of time (n seconds) the aggregated query information will be sent to Airbrake.
435 436 437 438 439 |
# File 'lib/airbrake-ruby.rb', line 435 def notify_query(query_info, stash = {}) query = Query.new(**query_info) query.stash.merge!(stash) performance_notifier.notify(query) end |
.notify_query_sync(query_info, stash = {}) ⇒ Object
Synchronously increments SQL statistics of a certain query
. When method
and route
are provided, the query is grouped by these parameters.
446 447 448 449 450 |
# File 'lib/airbrake-ruby.rb', line 446 def notify_query_sync(query_info, stash = {}) query = Query.new(**query_info) query.stash.merge!(stash) performance_notifier.notify_sync(query) end |
.notify_queue(queue_info, stash = {}) ⇒ void
This method returns an undefined value.
Increments statistics of a certain queue (worker).
512 513 514 515 516 |
# File 'lib/airbrake-ruby.rb', line 512 def notify_queue(queue_info, stash = {}) queue = Queue.new(**queue_info) queue.stash.merge!(stash) performance_notifier.notify(queue) end |
.notify_queue_sync(queue_info, stash = {}) ⇒ Object
Increments statistics of a certain queue (worker) synchronously.
521 522 523 524 525 |
# File 'lib/airbrake-ruby.rb', line 521 def notify_queue_sync(queue_info, stash = {}) queue = Queue.new(**queue_info) queue.stash.merge!(stash) performance_notifier.notify_sync(queue) end |
.notify_request(request_info, stash = {}) ⇒ void
This method returns an undefined value.
Increments request statistics of a certain route
invoked with method
, which returned status_code
.
After a certain amount of time (n seconds) the aggregated route information will be sent to Airbrake.
383 384 385 386 387 |
# File 'lib/airbrake-ruby.rb', line 383 def notify_request(request_info, stash = {}) request = Request.new(**request_info) request.stash.merge!(stash) performance_notifier.notify(request) end |
.notify_request_sync(request_info, stash = {}) ⇒ Object
Synchronously increments request statistics of a certain route
invoked with method
, which returned status_code
.
393 394 395 396 397 |
# File 'lib/airbrake-ruby.rb', line 393 def notify_request_sync(request_info, stash = {}) request = Request.new(**request_info) request.stash.merge!(stash) performance_notifier.notify_sync(request) end |
.notify_sync(exception, params = {}) {|notice| ... } ⇒ Airbrake::Promise
Sends an exception to Airbrake synchronously.
202 203 204 |
# File 'lib/airbrake-ruby.rb', line 202 def notify_sync(exception, params = {}, &block) notice_notifier.notify_sync(exception, params, &block) end |
.reset ⇒ void
This method returns an undefined value.
Resets all notifiers, including its filters
583 584 585 586 587 588 589 |
# File 'lib/airbrake-ruby.rb', line 583 def reset close self.performance_notifier = PerformanceNotifier.new self.notice_notifier = NoticeNotifier.new self.deploy_notifier = DeployNotifier.new end |