module Opbeat

Constants

VERSION

Public Class Methods

capture() { || ... } click to toggle source

Captures any exceptions raised inside the block

# File lib/opbeat.rb, line 133
def self.capture &block
  unless client
    return yield if block_given?
    return nil
  end

  client.capture(&block)
end
flush_transactions() { || ... } click to toggle source
# File lib/opbeat.rb, line 72
def self.flush_transactions
  unless client
    return yield if block_given?
    return nil
  end

  client.flush_transactions
end
release(rel, opts = {}) { || ... } click to toggle source

Notify Opbeat of a release

@param rel [Hash] @option rel [String] :rev Revision @option rel [String] :branch @return [Net::HTTPResponse]

# File lib/opbeat.rb, line 148
def self.release rel, opts = {}
  unless client
    return yield if block_given?
    return nil
  end

  client.release rel, opts
end
report(exception, opts = {}) { || ... } click to toggle source

Send an exception to Opbeat

@param exception [Exception] @param opts [Hash] @option opts [Hash] :rack_env A rack env object @return [Net::HTTPResponse]

# File lib/opbeat.rb, line 108
def self.report exception, opts = {}
  unless client
    return yield if block_given?
    return nil
  end

  client.report exception, opts
end
report_message(message, opts = {}) { || ... } click to toggle source

Send an exception to Opbeat

@param message [String] @param opts [Hash] @return [Net::HTTPResponse]

# File lib/opbeat.rb, line 122
def self.report_message message, opts = {}
  unless client
    return yield if block_given?
    return nil
  end

  client.report_message message, opts
end
set_context(context) click to toggle source

Sets context for future errors

@param context [Hash]

# File lib/opbeat.rb, line 84
def self.set_context context
  return nil unless client
  client.set_context context
end
start!(conf) click to toggle source

Start the Opbeat client

@param conf [Configuration] An Configuration object

# File lib/opbeat.rb, line 27
def self.start! conf
  Client.start! conf
end
started?() click to toggle source
# File lib/opbeat.rb, line 36
def self.started?
  !!Client.inst
end
stop!() click to toggle source

Stop the Opbeat client

# File lib/opbeat.rb, line 32
def self.stop!
  Client.stop!
end
trace(signature, kind = nil, extra = nil) { || ... } click to toggle source

Starts a new trace under the current Transaction

@param signature [String] A description of the trace, eq `SELECT FROM “users”` @param kind [String] The kind of trace, eq `db.mysql2.query` @param extra [Hash] Extra information about the trace @yield [Trace] Optional block encapsulating trace @return [Trace] Unless block given

# File lib/opbeat.rb, line 63
def self.trace signature, kind = nil, extra = nil, &block
  unless client
    return yield if block_given?
    return nil
  end

  client.trace signature, kind, extra, &block
end
transaction(endpoint, kind = nil, result = nil) { || ... } click to toggle source

Start a new transaction or return the currently running

@param endpoint [String] A description of the transaction, eg `ExamplesController#index` @param kind [String] The kind of the transaction, eg `app.request.get` or `db.mysql2.query` @param result [Object] Result of the transaction, eq `200` for a HTTP server @yield [Transaction] Optional block encapsulating transaction @return [Transaction] Unless block given

# File lib/opbeat.rb, line 47
def self.transaction endpoint, kind = nil, result = nil, &block
  unless client
    return yield if block_given?
    return nil
  end

  client.transaction endpoint, kind, result, &block
end
with_context(context) { || ... } click to toggle source

Updates context for errors within the block

@param context [Hash] @yield [Trace] Block in which the context is used

# File lib/opbeat.rb, line 93
def self.with_context context, &block
  unless client
    return yield if block_given?
    return nil
  end

  client.context context, &block
end

Private Class Methods

client() click to toggle source
# File lib/opbeat.rb, line 159
def self.client
  Client.inst
end