class InfluxDB::Rails::Configuration

rubocop:disable Metrics/ClassLength

Constants

DEFAULTS

Attributes

aggregated_exception_classes[RW]
application_name[RW]
application_root[RW]
async[RW]
backtrace_filters[RW]
debug[RW]
environment[RW]
environment_variable_filters[RW]
environment_variables[RW]
framework[RW]
framework_version[RW]
ignored_environments[RW]
ignored_exception_messages[RW]
ignored_exceptions[RW]
ignored_reports[RW]
ignored_user_agents[RW]
influxdb_database[RW]
influxdb_hosts[RW]
influxdb_password[RW]
influxdb_port[RW]
influxdb_username[RW]
instrumentation_enabled[RW]
language[RW]
language_version[RW]
logger[RW]
max_delay[RW]
open_timeout[RW]
rails_app_name[RW]
read_timeout[RW]
retry[RW]
series_name_for_controller_runtimes[RW]
series_name_for_db_runtimes[RW]
series_name_for_exceptions[RW]
series_name_for_instrumentation[RW]
series_name_for_render_collection[RW]
series_name_for_render_partial[RW]
series_name_for_render_template[RW]
series_name_for_sql[RW]
series_name_for_view_runtimes[RW]
tags_middleware[RW]
time_precision[RW]
use_ssl[RW]

Public Class Methods

new() click to toggle source

rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize

# File lib/influxdb/rails/configuration.rb, line 118
def initialize
  @influxdb_hosts     = DEFAULTS[:influxdb_hosts]
  @influxdb_port      = DEFAULTS[:influxdb_port]
  @influxdb_username  = DEFAULTS[:influxdb_username]
  @influxdb_password  = DEFAULTS[:influxdb_password]
  @influxdb_database  = DEFAULTS[:influxdb_database]
  @async              = DEFAULTS[:async]
  @use_ssl            = DEFAULTS[:use_ssl]
  @retry              = DEFAULTS[:retry]
  @open_timeout       = DEFAULTS[:open_timeout]
  @read_timeout       = DEFAULTS[:read_timeout]
  @max_delay          = DEFAULTS[:max_delay]
  @time_precision     = DEFAULTS[:time_precision]

  @series_name_for_controller_runtimes  = DEFAULTS[:series_name_for_controller_runtimes]
  @series_name_for_view_runtimes        = DEFAULTS[:series_name_for_view_runtimes]
  @series_name_for_db_runtimes          = DEFAULTS[:series_name_for_db_runtimes]
  @series_name_for_exceptions           = DEFAULTS[:series_name_for_exceptions]
  @series_name_for_instrumentation      = DEFAULTS[:series_name_for_instrumentation]
  @series_name_for_render_template      = DEFAULTS[:series_name_for_render_template]
  @series_name_for_render_partial       = DEFAULTS[:series_name_for_render_partial]
  @series_name_for_render_collection    = DEFAULTS[:series_name_for_render_collection]
  @series_name_for_sql                  = DEFAULTS[:series_name_for_sql]

  @tags_middleware = DEFAULTS[:tags_middleware]
  @rails_app_name = DEFAULTS[:rails_app_name]

  @ignored_exceptions           = DEFAULTS[:ignored_exceptions].dup
  @ignored_exception_messages   = DEFAULTS[:ignored_exception_messages].dup
  @ignored_reports              = DEFAULTS[:ignored_reports].dup
  @ignored_environments         = DEFAULTS[:ignored_environments].dup
  @ignored_user_agents          = DEFAULTS[:ignored_user_agents].dup
  @backtrace_filters            = DEFAULTS[:backtrace_filters].dup
  @environment_variable_filters = DEFAULTS[:environment_variable_filters]
  @aggregated_exception_classes = []

  @debug                    = false
  @rescue_global_exceptions = false
  @instrumentation_enabled  = true
end

Public Instance Methods

add_custom_exception_data(exception_presenter) click to toggle source
# File lib/influxdb/rails/configuration.rb, line 189
def add_custom_exception_data(exception_presenter)
  @custom_exception_data_handler&.call(exception_presenter)
end
debug?() click to toggle source

rubocop:enable Metrics/MethodLength rubocop:enable Metrics/AbcSize

# File lib/influxdb/rails/configuration.rb, line 162
def debug?
  !!@debug # rubocop:disable Style/DoubleNegation
end
define_custom_exception_data(&block) click to toggle source
# File lib/influxdb/rails/configuration.rb, line 185
def define_custom_exception_data(&block)
  @custom_exception_data_handler = block
end
ignore_current_environment?() click to toggle source
# File lib/influxdb/rails/configuration.rb, line 176
def ignore_current_environment?
  ignored_environments.include?(environment)
end
ignore_exception?(ex) click to toggle source
# File lib/influxdb/rails/configuration.rb, line 180
def ignore_exception?(ex)
  !ignored_exception_messages.find { |msg| /.*#{msg}.*/ =~ ex.message }.nil? ||
    ignored_exceptions.include?(ex.class.to_s)
end
ignore_user_agent?(incoming_user_agent) click to toggle source
# File lib/influxdb/rails/configuration.rb, line 170
def ignore_user_agent?(incoming_user_agent)
  return false if ignored_user_agents.nil?

  ignored_user_agents.any? { |agent| incoming_user_agent =~ /#{agent}/ }
end
instrumentation_enabled?() click to toggle source
# File lib/influxdb/rails/configuration.rb, line 166
def instrumentation_enabled?
  !!@instrumentation_enabled # rubocop:disable Style/DoubleNegation
end
load_rails_defaults() click to toggle source
# File lib/influxdb/rails/configuration.rb, line 193
def load_rails_defaults
  @logger           ||= ::Rails.logger
  @environment      ||= ::Rails.env
  @application_root ||= ::Rails.root
  @application_name ||= if ::Rails::VERSION::MAJOR >= 6
                          ::Rails.application.class.module_parent_name
                        else
                          ::Rails.application.class.parent_name
                        end
  @framework          = "Rails"
  @framework_version  = ::Rails.version
end

Private Instance Methods

initialize_http_connection() click to toggle source
# File lib/influxdb/rails/configuration.rb, line 208
def initialize_http_connection
  Net::HTTP.new(@app_host, "80")
end