Module: Raven
- Defined in:
- lib/raven/backtrace.rb,
lib/raven.rb,
lib/raven/cli.rb,
lib/raven/rack.rb,
lib/raven/error.rb,
lib/raven/event.rb,
lib/raven/client.rb,
lib/raven/logger.rb,
lib/raven/context.rb,
lib/raven/railtie.rb,
lib/raven/sidekiq.rb,
lib/raven/version.rb,
lib/raven/linecache.rb,
lib/raven/processor.rb,
lib/raven/interfaces.rb,
lib/raven/transports.rb,
lib/raven/configuration.rb,
lib/raven/transports/udp.rb,
lib/raven/interfaces/http.rb,
lib/raven/transports/http.rb,
lib/raven/interfaces/message.rb,
lib/raven/interfaces/exception.rb,
lib/raven/interfaces/stack_trace.rb,
lib/raven/processors/sanitizedata.rb,
lib/raven/rails/controller_methods.rb,
lib/raven/rails/middleware/debug_exceptions_catcher.rb
Overview
A much simpler source line cacher because linecache sucks at platform compat
Defined Under Namespace
Modules: Processor, Rails, Transports Classes: Backtrace, CLI, Client, Configuration, Context, Error, Event, ExceptionInterface, HttpInterface, Interface, LineCache, Logger, MessageInterface, Rack, Railtie, Sidekiq, StacktraceInterface
Constant Summary collapse
- VERSION =
"0.4.8"
- INTERFACES =
{}
Class Attribute Summary collapse
-
.client ⇒ Object
The client object is responsible for delivering formatted data to the Sentry server.
-
.configuration ⇒ Object
The configuration object.
Class Method Summary collapse
-
.capture(options = {}, &block) ⇒ Object
Capture and process any exceptions from the given block, or globally if no block is given.
- .capture_exception(exception, options = {}) ⇒ Object (also: captureException)
- .capture_message(message, options = {}) ⇒ Object (also: captureMessage)
-
.configure(silent = false) ⇒ Object
Call this method to modify defaults in your initializers.
- .context ⇒ Object
-
.extra_context(options = {}) ⇒ Object
Bind extra context.
- .find_interface(name) ⇒ Object
- .logger ⇒ Object
- .rack_context(env) ⇒ Object
- .register_interface(mapping) ⇒ Object
-
.report_ready ⇒ Object
Tell the log that the client is good to go.
-
.send(evt) ⇒ Object
Send an event to the configured Sentry server.
-
.tags_context(options = {}) ⇒ Object
Bind tags context.
-
.user_context(options = {}) ⇒ Object
Bind user context.
Class Attribute Details
.client ⇒ Object
The client object is responsible for delivering formatted data to the Sentry server.
45 46 47 |
# File 'lib/raven.rb', line 45 def client @client ||= Client.new(configuration) end |
.configuration ⇒ Object
The configuration object.
40 41 42 |
# File 'lib/raven.rb', line 40 def configuration @configuration ||= Configuration.new end |
Class Method Details
.capture(options = {}, &block) ⇒ Object
Capture and process any exceptions from the given block, or globally if no block is given
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/raven.rb', line 86 def capture(={}, &block) if block begin block.call rescue Error => e raise # Don't capture Raven errors rescue Exception => e capture_exception(e, ) raise end else # Install at_exit hook at_exit do if $! logger.debug "Caught a post-mortem exception: #{$!.inspect}" capture_exception($!, ) end end end end |
.capture_exception(exception, options = {}) ⇒ Object Also known as: captureException
107 108 109 110 111 112 |
# File 'lib/raven.rb', line 107 def capture_exception(exception, ={}) if evt = Event.from_exception(exception, ) yield evt if block_given? send(evt) end end |
.capture_message(message, options = {}) ⇒ Object Also known as: captureMessage
114 115 116 117 118 119 |
# File 'lib/raven.rb', line 114 def (, ={}) if evt = Event.(, ) yield evt if block_given? send(evt) end end |
.configure(silent = false) ⇒ Object
Call this method to modify defaults in your initializers.
60 61 62 63 64 65 66 67 68 |
# File 'lib/raven.rb', line 60 def configure(silent = false) if block_given? yield(configuration) end self.client = Client.new(configuration) report_ready unless silent self.client end |
.extra_context(options = {}) ⇒ Object
Bind extra context. Merges with existing context (if any).
Extra context shows up as Additional Data within Sentry, and is completely arbitrary.
149 150 151 |
# File 'lib/raven.rb', line 149 def extra_context(={}) self.context.extra.merge!() end |
.find_interface(name) ⇒ Object
33 34 35 |
# File 'lib/raven/interfaces.rb', line 33 def self.find_interface(name) INTERFACES[name.to_s] end |
.logger ⇒ Object
34 35 36 |
# File 'lib/raven.rb', line 34 def logger @logger ||= Logger.new end |
.rack_context(env) ⇒ Object
153 154 155 |
# File 'lib/raven.rb', line 153 def rack_context(env) self.context.rack_env = env end |
.register_interface(mapping) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/raven/interfaces.rb', line 26 def self.register_interface(mapping) mapping.each_pair do |key, klass| INTERFACES[key.to_s] = klass INTERFACES[klass.name] = klass end end |
.report_ready ⇒ Object
Tell the log that the client is good to go
50 51 52 |
# File 'lib/raven.rb', line 50 def report_ready self.logger.info "Raven #{VERSION} ready to catch errors" end |
.send(evt) ⇒ Object
Send an event to the configured Sentry server
75 76 77 |
# File 'lib/raven.rb', line 75 def send(evt) client.send(evt) end |
.tags_context(options = {}) ⇒ Object
Bind tags context. Merges with existing context (if any).
Tags are key / value pairs which generally represent things like application version, environment, role, and server names.
139 140 141 |
# File 'lib/raven.rb', line 139 def (={}) self.context..merge!() end |
.user_context(options = {}) ⇒ Object
Bind user context. Merges with existing context (if any).
It is recommending that you send at least the “id“ and “email“ values. All other values are arbitrary.
128 129 130 |
# File 'lib/raven.rb', line 128 def user_context(={}) self.context.user.merge!() end |