module InfluxReporter

Constants

VERSION

Public Class Methods

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

Captures any exceptions raised inside the block

# 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_transactions() click to toggle source
# File lib/influx_reporter.rb, line 74
def self.flush_transactions
  client&.flush_transactions
end
flush_transactions_if_needed() click to toggle source
# File lib/influx_reporter.rb, line 78
def self.flush_transactions_if_needed
  client&.flush_transactions_if_needed
end
report(exception, opts = {}) { || ... } click to toggle source

Send an exception to InfluxReporter

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

# 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 = {}) click to toggle source

Send an event to InfluxReporter

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

# File lib/influx_reporter.rb, line 131
def self.report_event(message, opts = {})
  client&.report_event message, opts
end
report_message(message, opts = {}) click to toggle source

Send an exception to InfluxReporter

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

# File lib/influx_reporter.rb, line 122
def self.report_message(message, opts = {})
  client&.report_message message, opts
end
set_context(context) click to toggle source

Sets context for future errors

@param context [Hash]

# File lib/influx_reporter.rb, line 85
def self.set_context(context)
  client&.set_context context
end
start!(conf) click to toggle source

Start the InfluxReporter client

@param conf [Configuration] An Configuration object

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

Stop the InfluxReporter client

# File lib/influx_reporter.rb, line 34
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/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) { || ... } 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 [InfluxReporter::Transaction] Optional block encapsulating transaction @return [InfluxReporter::Transaction] Unless block given

# 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) { || ... } 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/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

Private Class Methods

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