module Opbeat
A much simpler source line cacher because linecache sucks at platform compat
Constants
- INTERFACES
- VERSION
Attributes
client[RW]
The client object is responsible for delivering formatted data to the Opbeat
server. Must respond to send_event. See Opbeat::Client
.
configuration[W]
A Opbeat
configuration object. Must act like a hash and return sensible values for all Opbeat
configuration options. See Opbeat::Configuration
.
Public Class Methods
capture(&block)
click to toggle source
Capture and process any exceptions from the given block, or globally if no block is given
@example
Opbeat.capture do MyApp.run end
# File lib/opbeat.rb, line 72 def capture(&block) if block begin block.call rescue Error => e raise # Don't capture Opbeat errors rescue Exception => e self.captureException(e) raise end else # Install at_exit hook at_exit do if $! logger.debug "Caught a post-mortem exception: #{$!.inspect}" self.capture_exception($!) end end end end
capture_exception(exception, options={})
click to toggle source
# File lib/opbeat.rb, line 93 def capture_exception(exception, options={}) exception.set_backtrace caller unless exception.backtrace if (evt = Event.from_exception(exception, options)) if self.configuration.async? self.configuration.async.call(evt) else send(evt) end end end
Also aliased as: captureException
capture_message(message, options={})
click to toggle source
# File lib/opbeat.rb, line 115 def capture_message(message, options={}) if (evt = Event.from_message(message, caller, options)) if self.configuration.async? self.configuration.async.call(evt) else send(evt) end end end
Also aliased as: captureMessage
capture_rack_exception(exception, env, options={})
click to toggle source
# File lib/opbeat.rb, line 104 def capture_rack_exception(exception, env, options={}) exception.set_backtrace caller unless exception.backtrace if (evt = Event.from_rack_exception(exception, env, options)) if self.configuration.async? self.configuration.async.call(evt) else send(evt) end end end
configuration()
click to toggle source
The configuration object. @see Opbeat.configure
# File lib/opbeat.rb, line 39 def configuration @configuration ||= Configuration.new end
configure(silent = false) { |configuration| ... }
click to toggle source
Call this method to modify defaults in your initializers.
@example
Opbeat.configure do |config| config.server = 'http://...' end
# File lib/opbeat.rb, line 49 def configure(silent = false) yield(configuration) self.client = Client.new(configuration) report_ready unless silent self.client end
find_interface(name)
click to toggle source
# File lib/opbeat/interfaces.rb, line 31 def self.find_interface(name) INTERFACES[name.to_s] end
logger()
click to toggle source
# File lib/opbeat.rb, line 28 def logger @logger ||= Logger.new end
register_interface(mapping)
click to toggle source
# File lib/opbeat/interfaces.rb, line 24 def self.register_interface(mapping) mapping.each_pair do |key, klass| INTERFACES[key.to_s] = klass INTERFACES[klass.name] = klass end end
report_ready()
click to toggle source
Tell the log that the client is good to go
# File lib/opbeat.rb, line 33 def report_ready self.logger.info "Opbeat #{VERSION} ready to catch errors" end
send(evt)
click to toggle source
Send an event to the configured Opbeat
server
@example
evt = Opbeat::Event.new(:message => "An error") Opbeat.send(evt)
# File lib/opbeat.rb, line 61 def send(evt) @client.send_event(evt) if @client end
set_context(options={})
click to toggle source
# File lib/opbeat.rb, line 125 def set_context(options={}) Event.set_context(options) end