Class: InfluxDB::Rails::Configuration
- Inherits:
-
Object
- Object
- InfluxDB::Rails::Configuration
- Defined in:
- lib/influxdb/rails/configuration.rb
Overview
rubocop:disable Metrics/ClassLength
Constant Summary collapse
- DEFAULTS =
{ influxdb_hosts: ["localhost"].freeze, influxdb_port: 8086, influxdb_username: "root".freeze, influxdb_password: "root".freeze, influxdb_database: nil, async: true, use_ssl: false, retry: nil, open_timeout: 5, read_timeout: 300, max_delay: 30, time_precision: "s".freeze, series_name_for_controller_runtimes: "rails.controller".freeze, series_name_for_view_runtimes: "rails.view".freeze, series_name_for_db_runtimes: "rails.db".freeze, series_name_for_exceptions: "rails.exceptions".freeze, series_name_for_instrumentation: "instrumentation".freeze, series_name_for_render_template: "rails.render_template".freeze, series_name_for_render_partial: "rails.render_partial".freeze, series_name_for_render_collection: "rails.render_collection".freeze, series_name_for_sql: nil, series_name_for_http_client_log: "rails.http_client".freeze, tags_middleware: ->() { }, rails_app_name: nil, ignored_exceptions: %w[ ActiveRecord::RecordNotFound ActionController::RoutingError ].freeze, ignored_exception_messages: [].freeze, ignored_reports: [].freeze, ignored_environments: %w[test cucumber selenium].freeze, ignored_user_agents: %w[GoogleBot].freeze, environment_variable_filters: [ /password/i, /key/i, /secret/i, /ps1/i, /rvm_.*_clr/i, /color/i, ].freeze, backtrace_filters: [ ->(line) { line.gsub(%r{^\./}, "") }, lambda { |line| return line if InfluxDB::Rails.configuration.application_root.to_s.empty? line.gsub(/#{InfluxDB::Rails.configuration.application_root}/, "[APP_ROOT]") }, lambda { |line| if defined?(Gem) && !Gem.path.nil? && !Gem.path.empty? Gem.path.each { |path| line = line.gsub(/#{path}/, "[GEM_ROOT]") } end line }, ].freeze, }.freeze
Instance Attribute Summary collapse
-
#aggregated_exception_classes ⇒ Object
Returns the value of attribute aggregated_exception_classes.
-
#application_name ⇒ Object
Returns the value of attribute application_name.
-
#application_root ⇒ Object
Returns the value of attribute application_root.
-
#async ⇒ Object
Returns the value of attribute async.
-
#backtrace_filters ⇒ Object
Returns the value of attribute backtrace_filters.
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#environment_variable_filters ⇒ Object
Returns the value of attribute environment_variable_filters.
-
#environment_variables ⇒ Object
Returns the value of attribute environment_variables.
-
#framework ⇒ Object
Returns the value of attribute framework.
-
#framework_version ⇒ Object
Returns the value of attribute framework_version.
-
#ignored_environments ⇒ Object
Returns the value of attribute ignored_environments.
-
#ignored_exception_messages ⇒ Object
Returns the value of attribute ignored_exception_messages.
-
#ignored_exceptions ⇒ Object
Returns the value of attribute ignored_exceptions.
-
#ignored_reports ⇒ Object
Returns the value of attribute ignored_reports.
-
#ignored_user_agents ⇒ Object
Returns the value of attribute ignored_user_agents.
-
#influxdb_database ⇒ Object
Returns the value of attribute influxdb_database.
-
#influxdb_hosts ⇒ Object
rubocop:disable Style/Documentation.
-
#influxdb_password ⇒ Object
Returns the value of attribute influxdb_password.
-
#influxdb_port ⇒ Object
Returns the value of attribute influxdb_port.
-
#influxdb_username ⇒ Object
Returns the value of attribute influxdb_username.
-
#instrumentation_enabled ⇒ Object
Returns the value of attribute instrumentation_enabled.
-
#language ⇒ Object
Returns the value of attribute language.
-
#language_version ⇒ Object
Returns the value of attribute language_version.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#max_delay ⇒ Object
Returns the value of attribute max_delay.
-
#open_timeout ⇒ Object
Returns the value of attribute open_timeout.
-
#rails_app_name ⇒ Object
Returns the value of attribute rails_app_name.
-
#read_timeout ⇒ Object
Returns the value of attribute read_timeout.
-
#retry ⇒ Object
Returns the value of attribute retry.
-
#series_name_for_controller_runtimes ⇒ Object
Returns the value of attribute series_name_for_controller_runtimes.
-
#series_name_for_db_runtimes ⇒ Object
Returns the value of attribute series_name_for_db_runtimes.
-
#series_name_for_exceptions ⇒ Object
Returns the value of attribute series_name_for_exceptions.
-
#series_name_for_instrumentation ⇒ Object
Returns the value of attribute series_name_for_instrumentation.
-
#series_name_for_render_collection ⇒ Object
Returns the value of attribute series_name_for_render_collection.
-
#series_name_for_render_partial ⇒ Object
Returns the value of attribute series_name_for_render_partial.
-
#series_name_for_render_template ⇒ Object
Returns the value of attribute series_name_for_render_template.
-
#series_name_for_sql ⇒ Object
Returns the value of attribute series_name_for_sql.
-
#series_name_for_view_runtimes ⇒ Object
Returns the value of attribute series_name_for_view_runtimes.
-
#tags_middleware ⇒ Object
Returns the value of attribute tags_middleware.
-
#time_precision ⇒ Object
Returns the value of attribute time_precision.
-
#use_ssl ⇒ Object
Returns the value of attribute use_ssl.
Instance Method Summary collapse
- #add_custom_exception_data(exception_presenter) ⇒ Object
-
#debug? ⇒ Boolean
rubocop:enable Metrics/MethodLength rubocop:enable Metrics/AbcSize.
- #define_custom_exception_data(&block) ⇒ Object
- #ignore_current_environment? ⇒ Boolean
- #ignore_exception?(ex) ⇒ Boolean
- #ignore_user_agent?(incoming_user_agent) ⇒ Boolean
-
#initialize ⇒ Configuration
constructor
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize.
- #instrumentation_enabled? ⇒ Boolean
- #load_rails_defaults ⇒ Object
Constructor Details
#initialize ⇒ Configuration
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/influxdb/rails/configuration.rb', line 146 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] @series_name_for_http_client_log = DEFAULTS[:series_name_for_http_client_log] = DEFAULTS[:tags_middleware] @rails_app_name = DEFAULTS[:rails_app_name] @ignored_exceptions = DEFAULTS[:ignored_exceptions].dup = 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 # Http logs # @enabled = true # @compact_log = false # @json_log = false # @logger = Logger.new($stdout) # @logger_method = :log # @severity = Logger::Severity::DEBUG # @prefix = LOG_PREFIX # @log_connect = true # @log_request = true # @log_headers = false # @log_data = true # @log_status = true # @log_response = true # @log_benchmark = true # @url_whitelist_pattern = nil # @url_blacklist_pattern = nil # @color = false # @prefix_data_lines = false # @prefix_response_lines = false # @prefix_line_numbers = false # @filter_parameters = [] end |
Instance Attribute Details
#aggregated_exception_classes ⇒ Object
Returns the value of attribute aggregated_exception_classes.
47 48 49 |
# File 'lib/influxdb/rails/configuration.rb', line 47 def aggregated_exception_classes @aggregated_exception_classes end |
#application_name ⇒ Object
Returns the value of attribute application_name.
32 33 34 |
# File 'lib/influxdb/rails/configuration.rb', line 32 def application_name @application_name end |
#application_root ⇒ Object
Returns the value of attribute application_root.
33 34 35 |
# File 'lib/influxdb/rails/configuration.rb', line 33 def application_root @application_root end |
#async ⇒ Object
Returns the value of attribute async.
11 12 13 |
# File 'lib/influxdb/rails/configuration.rb', line 11 def async @async end |
#backtrace_filters ⇒ Object
Returns the value of attribute backtrace_filters.
46 47 48 |
# File 'lib/influxdb/rails/configuration.rb', line 46 def backtrace_filters @backtrace_filters end |
#debug ⇒ Object
Returns the value of attribute debug.
52 53 54 |
# File 'lib/influxdb/rails/configuration.rb', line 52 def debug @debug end |
#environment ⇒ Object
Returns the value of attribute environment.
36 37 38 |
# File 'lib/influxdb/rails/configuration.rb', line 36 def environment @environment end |
#environment_variable_filters ⇒ Object
Returns the value of attribute environment_variable_filters.
49 50 51 |
# File 'lib/influxdb/rails/configuration.rb', line 49 def environment_variable_filters @environment_variable_filters end |
#environment_variables ⇒ Object
Returns the value of attribute environment_variables.
48 49 50 |
# File 'lib/influxdb/rails/configuration.rb', line 48 def environment_variables @environment_variables end |
#framework ⇒ Object
Returns the value of attribute framework.
37 38 39 |
# File 'lib/influxdb/rails/configuration.rb', line 37 def framework @framework end |
#framework_version ⇒ Object
Returns the value of attribute framework_version.
38 39 40 |
# File 'lib/influxdb/rails/configuration.rb', line 38 def framework_version @framework_version end |
#ignored_environments ⇒ Object
Returns the value of attribute ignored_environments.
44 45 46 |
# File 'lib/influxdb/rails/configuration.rb', line 44 def ignored_environments @ignored_environments end |
#ignored_exception_messages ⇒ Object
Returns the value of attribute ignored_exception_messages.
42 43 44 |
# File 'lib/influxdb/rails/configuration.rb', line 42 def end |
#ignored_exceptions ⇒ Object
Returns the value of attribute ignored_exceptions.
41 42 43 |
# File 'lib/influxdb/rails/configuration.rb', line 41 def ignored_exceptions @ignored_exceptions end |
#ignored_reports ⇒ Object
Returns the value of attribute ignored_reports.
43 44 45 |
# File 'lib/influxdb/rails/configuration.rb', line 43 def ignored_reports @ignored_reports end |
#ignored_user_agents ⇒ Object
Returns the value of attribute ignored_user_agents.
45 46 47 |
# File 'lib/influxdb/rails/configuration.rb', line 45 def ignored_user_agents @ignored_user_agents end |
#influxdb_database ⇒ Object
Returns the value of attribute influxdb_database.
10 11 12 |
# File 'lib/influxdb/rails/configuration.rb', line 10 def influxdb_database @influxdb_database end |
#influxdb_hosts ⇒ Object
rubocop:disable Style/Documentation
6 7 8 |
# File 'lib/influxdb/rails/configuration.rb', line 6 def influxdb_hosts @influxdb_hosts end |
#influxdb_password ⇒ Object
Returns the value of attribute influxdb_password.
9 10 11 |
# File 'lib/influxdb/rails/configuration.rb', line 9 def influxdb_password @influxdb_password end |
#influxdb_port ⇒ Object
Returns the value of attribute influxdb_port.
7 8 9 |
# File 'lib/influxdb/rails/configuration.rb', line 7 def influxdb_port @influxdb_port end |
#influxdb_username ⇒ Object
Returns the value of attribute influxdb_username.
8 9 10 |
# File 'lib/influxdb/rails/configuration.rb', line 8 def influxdb_username @influxdb_username end |
#instrumentation_enabled ⇒ Object
Returns the value of attribute instrumentation_enabled.
51 52 53 |
# File 'lib/influxdb/rails/configuration.rb', line 51 def instrumentation_enabled @instrumentation_enabled end |
#language ⇒ Object
Returns the value of attribute language.
39 40 41 |
# File 'lib/influxdb/rails/configuration.rb', line 39 def language @language end |
#language_version ⇒ Object
Returns the value of attribute language_version.
40 41 42 |
# File 'lib/influxdb/rails/configuration.rb', line 40 def language_version @language_version end |
#logger ⇒ Object
Returns the value of attribute logger.
35 36 37 |
# File 'lib/influxdb/rails/configuration.rb', line 35 def logger @logger end |
#max_delay ⇒ Object
Returns the value of attribute max_delay.
16 17 18 |
# File 'lib/influxdb/rails/configuration.rb', line 16 def max_delay @max_delay end |
#open_timeout ⇒ Object
Returns the value of attribute open_timeout.
14 15 16 |
# File 'lib/influxdb/rails/configuration.rb', line 14 def open_timeout @open_timeout end |
#rails_app_name ⇒ Object
Returns the value of attribute rails_app_name.
30 31 32 |
# File 'lib/influxdb/rails/configuration.rb', line 30 def rails_app_name @rails_app_name end |
#read_timeout ⇒ Object
Returns the value of attribute read_timeout.
15 16 17 |
# File 'lib/influxdb/rails/configuration.rb', line 15 def read_timeout @read_timeout end |
#retry ⇒ Object
Returns the value of attribute retry.
13 14 15 |
# File 'lib/influxdb/rails/configuration.rb', line 13 def retry @retry end |
#series_name_for_controller_runtimes ⇒ Object
Returns the value of attribute series_name_for_controller_runtimes.
19 20 21 |
# File 'lib/influxdb/rails/configuration.rb', line 19 def series_name_for_controller_runtimes @series_name_for_controller_runtimes end |
#series_name_for_db_runtimes ⇒ Object
Returns the value of attribute series_name_for_db_runtimes.
21 22 23 |
# File 'lib/influxdb/rails/configuration.rb', line 21 def series_name_for_db_runtimes @series_name_for_db_runtimes end |
#series_name_for_exceptions ⇒ Object
Returns the value of attribute series_name_for_exceptions.
22 23 24 |
# File 'lib/influxdb/rails/configuration.rb', line 22 def series_name_for_exceptions @series_name_for_exceptions end |
#series_name_for_instrumentation ⇒ Object
Returns the value of attribute series_name_for_instrumentation.
23 24 25 |
# File 'lib/influxdb/rails/configuration.rb', line 23 def series_name_for_instrumentation @series_name_for_instrumentation end |
#series_name_for_render_collection ⇒ Object
Returns the value of attribute series_name_for_render_collection.
26 27 28 |
# File 'lib/influxdb/rails/configuration.rb', line 26 def series_name_for_render_collection @series_name_for_render_collection end |
#series_name_for_render_partial ⇒ Object
Returns the value of attribute series_name_for_render_partial.
25 26 27 |
# File 'lib/influxdb/rails/configuration.rb', line 25 def series_name_for_render_partial @series_name_for_render_partial end |
#series_name_for_render_template ⇒ Object
Returns the value of attribute series_name_for_render_template.
24 25 26 |
# File 'lib/influxdb/rails/configuration.rb', line 24 def series_name_for_render_template @series_name_for_render_template end |
#series_name_for_sql ⇒ Object
Returns the value of attribute series_name_for_sql.
27 28 29 |
# File 'lib/influxdb/rails/configuration.rb', line 27 def series_name_for_sql @series_name_for_sql end |
#series_name_for_view_runtimes ⇒ Object
Returns the value of attribute series_name_for_view_runtimes.
20 21 22 |
# File 'lib/influxdb/rails/configuration.rb', line 20 def series_name_for_view_runtimes @series_name_for_view_runtimes end |
#tags_middleware ⇒ Object
Returns the value of attribute tags_middleware.
29 30 31 |
# File 'lib/influxdb/rails/configuration.rb', line 29 def end |
#time_precision ⇒ Object
Returns the value of attribute time_precision.
17 18 19 |
# File 'lib/influxdb/rails/configuration.rb', line 17 def time_precision @time_precision end |
#use_ssl ⇒ Object
Returns the value of attribute use_ssl.
12 13 14 |
# File 'lib/influxdb/rails/configuration.rb', line 12 def use_ssl @use_ssl end |
Instance Method Details
#add_custom_exception_data(exception_presenter) ⇒ Object
241 242 243 |
# File 'lib/influxdb/rails/configuration.rb', line 241 def add_custom_exception_data(exception_presenter) @custom_exception_data_handler&.call(exception_presenter) end |
#debug? ⇒ Boolean
rubocop:enable Metrics/MethodLength rubocop:enable Metrics/AbcSize
214 215 216 |
# File 'lib/influxdb/rails/configuration.rb', line 214 def debug? !!@debug # rubocop:disable Style/DoubleNegation end |
#define_custom_exception_data(&block) ⇒ Object
237 238 239 |
# File 'lib/influxdb/rails/configuration.rb', line 237 def define_custom_exception_data(&block) @custom_exception_data_handler = block end |
#ignore_current_environment? ⇒ Boolean
228 229 230 |
# File 'lib/influxdb/rails/configuration.rb', line 228 def ignore_current_environment? ignored_environments.include?(environment) end |
#ignore_exception?(ex) ⇒ Boolean
232 233 234 235 |
# File 'lib/influxdb/rails/configuration.rb', line 232 def ignore_exception?(ex) !.find { |msg| /.*#{msg}.*/ =~ ex. }.nil? || ignored_exceptions.include?(ex.class.to_s) end |
#ignore_user_agent?(incoming_user_agent) ⇒ Boolean
222 223 224 225 226 |
# File 'lib/influxdb/rails/configuration.rb', line 222 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? ⇒ Boolean
218 219 220 |
# File 'lib/influxdb/rails/configuration.rb', line 218 def instrumentation_enabled? !!@instrumentation_enabled # rubocop:disable Style/DoubleNegation end |
#load_rails_defaults ⇒ Object
245 246 247 248 249 250 251 252 |
# File 'lib/influxdb/rails/configuration.rb', line 245 def load_rails_defaults @logger ||= ::Rails.logger @environment ||= ::Rails.env @application_root ||= ::Rails.root @application_name ||= ::Rails.application.class.parent_name @framework = "Rails" @framework_version = ::Rails.version end |