Module: Opbeat

Defined in:
lib/opbeat.rb,
lib/opbeat/util.rb,
lib/opbeat/error.rb,
lib/opbeat/trace.rb,
lib/opbeat/client.rb,
lib/opbeat/filter.rb,
lib/opbeat/worker.rb,
lib/opbeat/version.rb,
lib/opbeat/logging.rb,
lib/opbeat/line_cache.rb,
lib/opbeat/middleware.rb,
lib/opbeat/injections.rb,
lib/opbeat/subscriber.rb,
lib/opbeat/transaction.rb,
lib/opbeat/http_client.rb,
lib/opbeat/normalizers.rb,
lib/opbeat/trace_helpers.rb,
lib/opbeat/error_message.rb,
lib/opbeat/data_builders.rb,
lib/opbeat/configuration.rb,
lib/opbeat/util/inspector.rb,
lib/opbeat/sql_summarizer.rb,
lib/opbeat/injections/json.rb,
lib/opbeat/injections/redis.rb,
lib/opbeat/util/constantize.rb,
lib/opbeat/injections/sequel.rb,
lib/opbeat/error_message/http.rb,
lib/opbeat/error_message/user.rb,
lib/opbeat/injections/sinatra.rb,
lib/opbeat/data_builders/error.rb,
lib/opbeat/injections/net_http.rb,
lib/opbeat/normalizers/action_view.rb,
lib/opbeat/error_message/exception.rb,
lib/opbeat/error_message/stacktrace.rb,
lib/opbeat/normalizers/active_record.rb,
lib/opbeat/data_builders/transactions.rb,
lib/opbeat/normalizers/action_controller.rb

Defined Under Namespace

Modules: TraceHelpers Classes: BodyProxy, Configuration, ErrorMessage, Middleware, Trace, Transaction

Constant Summary collapse

VERSION =
"3.0.0"

Class Method Summary collapse

Class Method Details

.capture(&block) ⇒ Object

Captures any exceptions raised inside the block


112
113
114
115
116
117
118
119
# File 'lib/opbeat.rb', line 112

def self.capture &block
  unless client
    return yield if block_given?
    return nil
  end

  client.capture(&block)
end

.flush_transactionsObject


72
73
74
75
76
77
78
79
# 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 = {}) ⇒ Net::HTTPResponse

Notify Opbeat of a release

Options Hash (rel):

  • :rev (String)

    Revision

  • :branch (String)

127
128
129
130
131
132
133
134
# File 'lib/opbeat.rb', line 127

def self.release rel, opts = {}
  unless client
    return yield if block_given?
    return nil
  end

  client.release rel, opts
end

.report(exception, opts = {}) ⇒ Net::HTTPResponse

Send an exception to Opbeat

Options Hash (opts):

  • :rack_env (Hash)

    A rack env object


87
88
89
90
91
92
93
94
# File 'lib/opbeat.rb', line 87

def self.report exception, opts = {}
  unless client
    return yield if block_given?
    return nil
  end

  client.report exception, opts
end

.report_message(message, opts = {}) ⇒ Net::HTTPResponse

Send an exception to Opbeat


101
102
103
104
105
106
107
108
# File 'lib/opbeat.rb', line 101

def self.report_message message, opts = {}
  unless client
    return yield if block_given?
    return nil
  end

  client.report_message message, opts
end

.start!(conf) ⇒ Object

Start the Opbeat client


27
28
29
# File 'lib/opbeat.rb', line 27

def self.start! conf
  Client.start! conf
end

.started?Boolean


36
37
38
# File 'lib/opbeat.rb', line 36

def self.started?
  !!Client.inst
end

.stop!Object

Stop the Opbeat client


32
33
34
# File 'lib/opbeat.rb', line 32

def self.stop!
  Client.stop!
end

.trace(signature, kind = nil, extra = nil) {|Trace| ... } ⇒ Trace

Starts a new trace under the current Transaction

Yields:

  • (Trace)

    Optional block encapsulating trace


63
64
65
66
67
68
69
70
# 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) {|Transaction| ... } ⇒ Transaction

Start a new transaction or return the currently running

Yields:

  • (Transaction)

    Optional block encapsulating transaction


47
48
49
50
51
52
53
54
# 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