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/deploy.rb,
lib/rollbar/logger.rb,
lib/rollbar/plugin.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/item/locals.rb,
lib/rollbar/delay/resque.rb,
lib/rollbar/delay/thread.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/capistrano_tasks.rb,
lib/rollbar/delay/active_job.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_anonymizer.rb,
lib/rollbar/util/ip_obfuscator.rb,
lib/rollbar/plugins/sidekiq/plugin.rb,
lib/rollbar/request_data_extractor.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/js/json_value.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/notifier/trace_with_bindings.rb,
lib/rollbar/plugins/delayed_job/job_data.rb,
lib/rollbar/truncation/min_body_strategy.rb,
lib/rollbar/plugins/rails/error_subscriber.rb,
lib/rollbar/middleware/rails/show_exceptions.rb,
lib/rollbar/plugins/rails/controller_methods.rb,
lib/rollbar/truncation/remove_extra_strategy.rb,
lib/rollbar/truncation/remove_any_key_strategy.rb,
lib/rollbar/truncation/remove_request_strategy.rb
Overview
Allows a Ruby String to be used to pass native Javascript objects/functions when calling JSON#generate with a Rollbar::JSON::JsOptionsState instance.
Example: JSON.generate(
{ foo: Rollbar::JSON::Value.new('function(){ alert("bar") }') },
Rollbar::JSON::JsOptionsState.new
)
> ‘alert("bar") }’
MUST use the Ruby JSON encoder, as in the example. The ActiveSupport encoder, which is installed with Rails, is invoked when calling Hash#to_json and #as_json, and will not work.
Defined Under Namespace
Modules: ActiveJob, Capistrano2, CapistranoTasks, Delay, Delayed, Deploy, Encoding, ExceptionReporter, Generators, JSON, Js, LanguageSupport, Middleware, Rails, RailtieMixin, RequestDataExtractor, Scrubbers, Truncation, Util Classes: Configuration, ConfiguredOptions, ErrorSubscriber, 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 =
'3.6.0'.freeze
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
92 93 94 |
# File 'lib/rollbar.rb', line 92 def plugins @plugins ||= Rollbar::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
56 57 58 |
# File 'lib/rollbar.rb', line 56 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
119 120 121 122 |
# File 'lib/rollbar.rb', line 119 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.
84 85 86 |
# File 'lib/rollbar.rb', line 84 def configuration notifier.configuration end |
.configure(&block) ⇒ Object
Configures the root notifier and loads the plugins
65 66 67 68 69 |
# File 'lib/rollbar.rb', line 65 def configure(&block) root_notifier.configure(&block) plugins.load! end |
.last_report ⇒ Object
96 97 98 |
# File 'lib/rollbar.rb', line 96 def last_report Thread.current[:_rollbar_last_report] end |
.last_report=(report) ⇒ Object
100 101 102 |
# File 'lib/rollbar.rb', line 100 def last_report=(report) Thread.current[:_rollbar_last_report] = report end |
.notifier ⇒ Object
37 38 39 40 41 |
# File 'lib/rollbar.rb', line 37 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
43 44 45 |
# File 'lib/rollbar.rb', line 43 def notifier=(notifier) Thread.current[:_rollbar_notifier] = notifier end |
.preconfigure(&block) ⇒ Object
60 61 62 |
# File 'lib/rollbar.rb', line 60 def preconfigure(&block) root_notifier.preconfigure(&block) end |
.reconfigure(&block) ⇒ Object
Reconfigures the root notifier
72 73 74 |
# File 'lib/rollbar.rb', line 72 def reconfigure(&block) root_notifier.reconfigure(&block) end |
.report_exception(exception, request_data = nil, person_data = nil, level = 'error') ⇒ Object
Backwards compatibility methods
163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/rollbar.rb', line 163 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 Rollbar.scoped(scope) do Rollbar.notifier.log(level, exception, :use_exception_level_filters => true) end end |
.report_message(message, level = 'info', extra_data = nil) ⇒ Object
177 178 179 180 181 182 |
# File 'lib/rollbar.rb', line 177 def (, level = 'info', extra_data = nil) Kernel.warn('[DEPRECATION] Rollbar.report_message has been deprecated, ' \ 'please use log() or one of the level functions') Rollbar.notifier.log(level, , extra_data) end |
.report_message_with_request(message, level = 'info', request_data = nil, person_data = nil, extra_data = nil) ⇒ Object
184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/rollbar.rb', line 184 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 Rollbar.scoped(:request => request_data, :person => person_data) do Rollbar.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.
113 114 115 |
# File 'lib/rollbar.rb', line 113 def reset_notifier! notifier.reset! end |
.safely? ⇒ Boolean
88 89 90 |
# File 'lib/rollbar.rb', line 88 def safely? configuration.safely? end |
.scope!(options = {}) ⇒ Object
157 158 159 |
# File 'lib/rollbar.rb', line 157 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.
141 142 143 144 145 146 147 148 149 |
# File 'lib/rollbar.rb', line 141 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
77 78 79 |
# File 'lib/rollbar.rb', line 77 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.
153 154 155 |
# File 'lib/rollbar.rb', line 153 def with_config(overrides, &block) scoped(nil, overrides, &block) end |