Module: InfluxReporter

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

Defined Under Namespace

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

Constant Summary collapse

VERSION =
'1.2.2'

Class Method Summary collapse

Class Method Details

.capture(&block) ⇒ Object

Captures any exceptions raised inside the block



137
138
139
140
141
142
143
144
# File 'lib/influx_reporter.rb', line 137

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

  client.capture(&block)
end

.flush_transactionsObject



74
75
76
# File 'lib/influx_reporter.rb', line 74

def self.flush_transactions
  client&.flush_transactions
end

.flush_transactions_if_neededObject



78
79
80
# File 'lib/influx_reporter.rb', line 78

def self.flush_transactions_if_needed
  client&.flush_transactions_if_needed
end

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

Send an exception to InfluxReporter

Parameters:

  • exception (Exception)
  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • :rack_env (Hash)

    A rack env object

Returns:

  • (Net::HTTPResponse)


108
109
110
111
112
113
114
115
# File 'lib/influx_reporter.rb', line 108

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

  client.report exception, opts
end

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

Send an event to InfluxReporter

Parameters:

  • message (String)
  • opts (Hash) (defaults to: {})

Returns:

  • (Net::HTTPResponse)


131
132
133
# File 'lib/influx_reporter.rb', line 131

def self.report_event(message, opts = {})
  client&.report_event message, opts
end

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

Send an exception to InfluxReporter

Parameters:

  • message (String)
  • opts (Hash) (defaults to: {})

Returns:

  • (Net::HTTPResponse)


122
123
124
# File 'lib/influx_reporter.rb', line 122

def self.report_message(message, opts = {})
  client&.report_message message, opts
end

.set_context(context) ⇒ Object

Sets context for future errors

Parameters:

  • context (Hash)


85
86
87
# File 'lib/influx_reporter.rb', line 85

def self.set_context(context)
  client&.set_context context
end

.start!(conf) ⇒ Object

Start the InfluxReporter client

Parameters:



29
30
31
# File 'lib/influx_reporter.rb', line 29

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

.started?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/influx_reporter.rb', line 38

def self.started?
  !!Client.inst
end

.stop!Object

Stop the InfluxReporter client



34
35
36
# File 'lib/influx_reporter.rb', line 34

def self.stop!
  Client.stop!
end

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

Starts a new trace under the current Transaction

Parameters:

  • signature (String)

    A description of the trace, eq ‘SELECT FROM “users”`

  • kind (String) (defaults to: nil)

    The kind of trace, eq ‘db.mysql2.query`

  • extra (Hash) (defaults to: nil)

    Extra information about the trace

Yields:

  • (Trace)

    Optional block encapsulating trace

Returns:

  • (Trace)

    Unless block given



65
66
67
68
69
70
71
72
# File 'lib/influx_reporter.rb', line 65

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) {|InfluxReporter::Transaction| ... } ⇒ InfluxReporter::Transaction

Start a new transaction or return the currently running

Parameters:

  • endpoint (String)

    A description of the transaction, eg ‘ExamplesController#index`

  • kind (String) (defaults to: nil)

    The kind of the transaction, eg ‘app.request.get` or `db.mysql2.query`

  • result (Object) (defaults to: nil)

    Result of the transaction, eq ‘200` for a HTTP server

Yields:

Returns:



49
50
51
52
53
54
55
56
# File 'lib/influx_reporter.rb', line 49

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) {|Trace| ... } ⇒ Object

Updates context for errors within the block

Parameters:

  • context (Hash)

Yields:

  • (Trace)

    Block in which the context is used



93
94
95
96
97
98
99
100
# File 'lib/influx_reporter.rb', line 93

def self.with_context(context, &block)
  unless client
    return yield if block_given?
    return nil
  end

  client.with_context context, &block
end