module InfluxDB::Rails
InfluxDB::Rails
contains the glue code needed to integrate with InfluxDB
and Rails
. This is a singleton class.
Constants
- VERSION
Attributes
client[W]
configuration[W]
Public Class Methods
client()
click to toggle source
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize
# File lib/asklytics-influxdb-rails.rb, line 42 def client @client ||= InfluxDB::Client.new \ database: configuration.influxdb_database, username: configuration.influxdb_username, password: configuration.influxdb_password, hosts: configuration.influxdb_hosts, port: configuration.influxdb_port, async: configuration.async, use_ssl: configuration.use_ssl, retry: configuration.retry, open_timeout: configuration.open_timeout, read_timeout: configuration.read_timeout, max_delay: configuration.max_delay, time_precision: configuration.time_precision end
configuration()
click to toggle source
rubocop:enable Metrics/MethodLength rubocop:enable Metrics/AbcSize
# File lib/asklytics-influxdb-rails.rb, line 61 def configuration @configuration ||= InfluxDB::Rails::Configuration.new end
configure(_silent = false) { |configuration| ... }
click to toggle source
# File lib/asklytics-influxdb-rails.rb, line 30 def configure(_silent = false) yield(configuration) # if we change configuration, reload the client self.client = nil InfluxDB::Logging.logger = configuration.logger unless configuration.logger.nil? end
current()
click to toggle source
def configuration_http_tracing
HttpLog.configure do |config| config.enable_http_tracing = configuration.enable_http_tracing config.http_tracing_id = configuration.http_tracing_id config.series_name_for_http_client_log = configuration.series_name_for_http_client_log end
end
# File lib/asklytics-influxdb-rails.rb, line 75 def current @current ||= InfluxDB::Rails::Context.new end
current_timestamp()
click to toggle source
rubocop:enable Metrics/MethodLength rubocop:enable Metrics/AbcSize
# File lib/asklytics-influxdb-rails.rb, line 110 def current_timestamp InfluxDB.now(configuration.time_precision) end
ignorable_exception?(ex)
click to toggle source
# File lib/asklytics-influxdb-rails.rb, line 114 def ignorable_exception?(ex) configuration.ignore_current_environment? || configuration.ignore_exception?(ex) end
report_exception(ex, env = {})
click to toggle source
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize
# File lib/asklytics-influxdb-rails.rb, line 87 def report_exception(ex, env = {}) timestamp = InfluxDB::Rails.current_timestamp env = influxdb_request_data if env.empty? && defined? influxdb_request_data exception_presenter = ExceptionPresenter.new(ex, env) log :info, "Exception: #{exception_presenter.to_json[0..512]}..." tags = configuration.tags_middleware.call( exception_presenter.context.merge(exception_presenter.dimensions) ) client.write_point \ configuration.series_name_for_exceptions, values: exception_presenter.values.merge(ts: timestamp), tags: tags, timestamp: timestamp rescue StandardError => ex log :info, "[InfluxDB::Rails] Something went terribly wrong." \ " Exception failed to take off! #{ex.class}: #{ex.message}" end
Also aliased as: transmit
report_exception_unless_ignorable(ex, env = {})
click to toggle source
# File lib/asklytics-influxdb-rails.rb, line 79 def report_exception_unless_ignorable(ex, env = {}) report_exception(ex, env) unless ignorable_exception?(ex) end
Also aliased as: transmit_unless_ignorable
rescue() { || ... }
click to toggle source
# File lib/asklytics-influxdb-rails.rb, line 118 def rescue yield rescue StandardError => ex raise ex if configuration.ignore_current_environment? transmit_unless_ignorable(ex) end
rescue_and_reraise() { || ... }
click to toggle source
# File lib/asklytics-influxdb-rails.rb, line 126 def rescue_and_reraise yield rescue StandardError => ex transmit_unless_ignorable(ex) raise ex end