Module: Rollbar
- Extended by:
- Forwardable
- Defined in:
- lib/rollbar.rb,
lib/rollbar/js.rb,
lib/rollbar/item.rb,
lib/rollbar/json.rb,
lib/rollbar/util.rb,
lib/rollbar/rails.rb,
lib/rollbar/logger.rb,
lib/rollbar/plugin.rb,
lib/rollbar/json/oj.rb,
lib/rollbar/plugins.rb,
lib/rollbar/version.rb,
lib/rollbar/encoding.rb,
lib/rollbar/notifier.rb,
lib/rollbar/scrubbers.rb,
lib/rollbar/util/hash.rb,
lib/rollbar/capistrano.rb,
lib/rollbar/exceptions.rb,
lib/rollbar/item/frame.rb,
lib/rollbar/lazy_store.rb,
lib/rollbar/truncation.rb,
lib/rollbar/delay/resque.rb,
lib/rollbar/delay/thread.rb,
lib/rollbar/json/default.rb,
lib/rollbar/logger_proxy.rb,
lib/rollbar/configuration.rb,
lib/rollbar/delay/sidekiq.rb,
lib/rollbar/middleware/js.rb,
lib/rollbar/scrubbers/url.rb,
lib/rollbar/item/backtrace.rb,
lib/rollbar/delay/shoryuken.rb,
lib/rollbar/middleware/rack.rb,
lib/rollbar/encoding/encoder.rb,
lib/rollbar/language_support.rb,
lib/rollbar/scrubbers/params.rb,
lib/rollbar/truncation/mixin.rb,
lib/rollbar/delay/delayed_job.rb,
lib/rollbar/delay/girl_friday.rb,
lib/rollbar/delay/sucker_punch.rb,
lib/rollbar/exception_reporter.rb,
lib/rollbar/middleware/sinatra.rb,
lib/rollbar/plugins/active_job.rb,
lib/rollbar/util/ip_obfuscator.rb,
lib/rollbar/plugins/sidekiq/plugin.rb,
lib/rollbar/request_data_extractor.rb,
lib/rollbar/encoding/legacy_encoder.rb,
lib/rollbar/middleware/rack/builder.rb,
lib/rollbar/plugins/rails/railtie30.rb,
lib/rollbar/plugins/rails/railtie32.rb,
lib/rollbar/truncation/raw_strategy.rb,
lib/rollbar/middleware/rails/rollbar.rb,
lib/rollbar/plugins/delayed_job/plugin.rb,
lib/rollbar/truncation/frames_strategy.rb,
lib/rollbar/plugins/rails/railtie_mixin.rb,
lib/rollbar/truncation/strings_strategy.rb,
lib/generators/rollbar/rollbar_generator.rb,
lib/rollbar/middleware/rack/test_session.rb,
lib/rollbar/plugins/delayed_job/job_data.rb,
lib/rollbar/truncation/min_body_strategy.rb,
lib/rollbar/middleware/rails/show_exceptions.rb,
lib/rollbar/plugins/rails/controller_methods.rb
Overview
The Rollbar module. It stores a Rollbar::Notifier per thread and provides some module methods in order to use the current thread notifier.
Defined Under Namespace
Modules: ActiveJob, Capistrano, Delay, Delayed, Encoding, ExceptionReporter, Generators, JSON, Js, LanguageSupport, Middleware, Rails, RailtieMixin, RequestDataExtractor, Scrubbers, Truncation, Util Classes: Configuration, Ignore, Item, LazyStore, Logger, LoggerProxy, Notifier, Plugin, Plugins, Railtie, Sidekiq
Constant Summary collapse
- PUBLIC_NOTIFIER_METHODS =
%w(debug info warn warning error critical log logger process_item process_from_async_handler scope send_failsafe log_info log_debug log_warning log_error silenced scope_object).freeze
- VERSION =
'2.15.6'
Class Attribute Summary collapse
- .plugins ⇒ Object
-
.root_notifier ⇒ Object
It’s the first notifier instantiated in the process.
Class Method Summary collapse
-
.clear_notifier! ⇒ Object
Clears the current thread notifier and the root notifier.
-
.configuration ⇒ Object
Returns the configuration for the current notifier.
-
.configure(&block) ⇒ Object
Configures the root notifier and loads the plugins.
- .last_report ⇒ Object
- .last_report=(report) ⇒ Object
- .notifier ⇒ Object
- .notifier=(notifier) ⇒ Object
- .preconfigure(&block) ⇒ Object
-
.reconfigure(&block) ⇒ Object
Reconfigures the root notifier.
-
.report_exception(exception, request_data = nil, person_data = nil, level = 'error') ⇒ Object
Backwards compatibility methods.
- .report_message(message, level = 'info', extra_data = nil) ⇒ Object
- .report_message_with_request(message, level = 'info', request_data = nil, person_data = nil, extra_data = nil) ⇒ Object
-
.reset_notifier! ⇒ Object
Resets the scope for the current thread notifier.
- .safely? ⇒ Boolean
- .scope!(options = {}) ⇒ Object
-
.scoped(options = {}, config_overrides = {}) ⇒ Object
Create a new Notifier instance using the received options and set it as the current thread notifier.
-
.unconfigure ⇒ Object
Unconfigures the root notifier.
-
.with_config(overrides, &block) ⇒ Object
Create a new Notifier instance with a new configuration using the current one but merging the passed options.
Class Attribute Details
.plugins ⇒ Object
93 94 95 |
# File 'lib/rollbar.rb', line 93 def plugins @plugins ||= ::Plugins.new end |
.root_notifier ⇒ Object
It’s the first notifier instantiated in the process. We store it so all the next per-thread notifiers can inherit its configuration The methods Rollbar.configure, Rollbar.reconfigure, Rollbar.preconfigure and Rollbar.unconfigure work on this notifier. Before v2.13.0 these methods worked on the global configuration, so in the practice the behavior is the same, since they work on the root notifier’s configuration
57 58 59 |
# File 'lib/rollbar.rb', line 57 def root_notifier @root_notifier ||= notifier end |
Class Method Details
.clear_notifier! ⇒ Object
Clears the current thread notifier and the root notifier. In the practice this should be used only on the specs
120 121 122 123 |
# File 'lib/rollbar.rb', line 120 def clear_notifier! self.notifier = nil self.root_notifier = nil end |
.configuration ⇒ Object
Returns the configuration for the current notifier. The current notifier is Rollbar.notifier and exists one per thread.
85 86 87 |
# File 'lib/rollbar.rb', line 85 def configuration notifier.configuration end |
.configure(&block) ⇒ Object
Configures the root notifier and loads the plugins
66 67 68 69 70 |
# File 'lib/rollbar.rb', line 66 def configure(&block) root_notifier.configure(&block) plugins.load! end |
.last_report ⇒ Object
97 98 99 |
# File 'lib/rollbar.rb', line 97 def last_report Thread.current[:_rollbar_last_report] end |
.last_report=(report) ⇒ Object
101 102 103 |
# File 'lib/rollbar.rb', line 101 def last_report=(report) Thread.current[:_rollbar_last_report] = report end |
.notifier ⇒ Object
38 39 40 41 42 |
# File 'lib/rollbar.rb', line 38 def notifier # Use the global instance @root_notifier so we don't fall # in a infinite loop Thread.current[:_rollbar_notifier] ||= Notifier.new(@root_notifier) end |
.notifier=(notifier) ⇒ Object
44 45 46 |
# File 'lib/rollbar.rb', line 44 def notifier=(notifier) Thread.current[:_rollbar_notifier] = notifier end |
.preconfigure(&block) ⇒ Object
61 62 63 |
# File 'lib/rollbar.rb', line 61 def preconfigure(&block) root_notifier.preconfigure(&block) end |
.reconfigure(&block) ⇒ Object
Reconfigures the root notifier
73 74 75 |
# File 'lib/rollbar.rb', line 73 def reconfigure(&block) root_notifier.reconfigure(&block) end |
.report_exception(exception, request_data = nil, person_data = nil, level = 'error') ⇒ Object
Backwards compatibility methods
164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/rollbar.rb', line 164 def report_exception(exception, request_data = nil, person_data = nil, level = 'error') Kernel.warn('[DEPRECATION] Rollbar.report_exception has been deprecated, please use log() or one of the level functions') scope = {} scope[:request] = request_data if request_data scope[:person] = person_data if person_data .scoped(scope) do .notifier.log(level, exception, :use_exception_level_filters => true) end end |
.report_message(message, level = 'info', extra_data = nil) ⇒ Object
176 177 178 179 180 |
# File 'lib/rollbar.rb', line 176 def (, level = 'info', extra_data = nil) Kernel.warn('[DEPRECATION] Rollbar.report_message has been deprecated, please use log() or one of the level functions') .notifier.log(level, , extra_data) end |
.report_message_with_request(message, level = 'info', request_data = nil, person_data = nil, extra_data = nil) ⇒ Object
182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/rollbar.rb', line 182 def (, level = 'info', request_data = nil, person_data = nil, extra_data = nil) Kernel.warn('[DEPRECATION] Rollbar.report_message_with_request has been deprecated, please use log() or one of the level functions') scope = {} scope[:request] = request_data if request_data scope[:person] = person_data if person_data .scoped(:request => request_data, :person => person_data) do .notifier.log(level, , extra_data) end end |
.reset_notifier! ⇒ Object
Resets the scope for the current thread notifier. The notifier reference is kept so we reuse the notifier. This is a change from version 2.13.0. Before this version this method clears the notifier.
It was used in order to reset the scope and reusing the global configuration Rollbar.configuration. Since now Rollbar.configuration points to the current notifier configuration, we can resue the notifier instance and just reset the scope.
114 115 116 |
# File 'lib/rollbar.rb', line 114 def reset_notifier! notifier.reset! end |
.safely? ⇒ Boolean
89 90 91 |
# File 'lib/rollbar.rb', line 89 def safely? configuration.safely? end |
.scope!(options = {}) ⇒ Object
158 159 160 |
# File 'lib/rollbar.rb', line 158 def scope!( = {}) notifier.scope!() end |
.scoped(options = {}, config_overrides = {}) ⇒ Object
Create a new Notifier instance using the received options and set it as the current thread notifier. The calls to Rollbar inside the received block will use then this new Notifier object.
142 143 144 145 146 147 148 149 150 |
# File 'lib/rollbar.rb', line 142 def scoped( = {}, config_overrides = {}) old_notifier = notifier self.notifier = old_notifier.scope(, config_overrides) result = yield result ensure self.notifier = old_notifier end |
.unconfigure ⇒ Object
Unconfigures the root notifier
78 79 80 |
# File 'lib/rollbar.rb', line 78 def unconfigure root_notifier.unconfigure end |
.with_config(overrides, &block) ⇒ Object
Create a new Notifier instance with a new configuration using the current one but merging the passed options.
154 155 156 |
# File 'lib/rollbar.rb', line 154 def with_config(overrides, &block) scoped(nil, overrides, &block) end |