Class: Chronos::Configuration
- Inherits:
-
Object
- Object
- Chronos::Configuration
- Defined in:
- lib/chronos/configuration.rb
Overview
Mutable configuration used only while the Chronos agent is being set up.
Defined Under Namespace
Classes: Snapshot
Constant Summary collapse
- DEFAULT_BLOCKLIST_KEYS =
%w( password password_confirmation passwd secret api_key apikey authorization token access_token refresh_token private_key client_secret cookie set-cookie session credit_card card_number cvv cpf cnpj ).freeze
- ATTRIBUTES =
[ :project_id, :project_key, :host, :environment, :app_version, :service_name, :root_directory, :logger, :timeout, :open_timeout, :queue_size, :workers, :enabled, :error_notifications, :ignored_environments, :proxy, :ssl_verify, :user_agent, :max_payload_size, :gzip, :blocklist_keys, :allowlist_keys, :filters, :hash_keys, :anonymize_ip ].freeze
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #snapshot ⇒ Object
- #valid? ⇒ Boolean
- #validation_errors ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/chronos/configuration.rb', line 39 def initialize @project_id = nil @project_key = nil @host = nil @environment = "production" @app_version = nil @service_name = nil @root_directory = Dir.pwd @logger = nil @timeout = 5.0 @open_timeout = 2.0 @queue_size = 100 @workers = 1 @enabled = true @error_notifications = true @ignored_environments = [] @proxy = nil @ssl_verify = true @user_agent = "chronos-ruby/#{Chronos::VERSION}" @max_payload_size = 1_048_576 @gzip = false @blocklist_keys = DEFAULT_BLOCKLIST_KEYS.dup @allowlist_keys = [] @filters = [] @hash_keys = [] @anonymize_ip = true end |
Instance Method Details
#snapshot ⇒ Object
67 68 69 70 71 72 |
# File 'lib/chronos/configuration.rb', line 67 def snapshot errors = validation_errors raise ConfigurationError, errors.join(", ") unless errors.empty? Snapshot.new(to_hash) end |
#valid? ⇒ Boolean
74 75 76 |
# File 'lib/chronos/configuration.rb', line 74 def valid? validation_errors.empty? end |
#validation_errors ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/chronos/configuration.rb', line 78 def validation_errors errors = [] if enabled errors << "project_id is required" if blank?(project_id) errors << "project_key is required" if blank?(project_key) errors.concat(host_errors) end errors << "timeout must be greater than zero" unless positive_number?(timeout) errors << "open_timeout must be greater than zero" unless positive_number?(open_timeout) errors << "queue_size must be a positive integer" unless positive_integer?(queue_size) errors << "workers must be a positive integer" unless positive_integer?(workers) errors << "max_payload_size must be a positive integer" unless positive_integer?(max_payload_size) errors.concat(privacy_errors) errors end |