Class: Apidepth::Configuration
- Inherits:
-
Object
- Object
- Apidepth::Configuration
- Defined in:
- lib/apidepth/configuration.rb
Constant Summary collapse
- HARD_IGNORED_HOSTS =
Always ignored regardless of user config. Covers unambiguous loopback addresses — we deliberately avoid wildcard patterns like *.internal here because silently swallowing traffic the developer wants to see is worse than showing mystery vendors. The setup subcommand prompts for custom patterns interactively.
%w[localhost 127.0.0.1 0.0.0.0 ::1].freeze
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#collector_url ⇒ Object
Returns the value of attribute collector_url.
-
#enabled ⇒ Object
Returns the value of attribute enabled.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#extra_vendors ⇒ Object
Returns the value of attribute extra_vendors.
-
#flush_interval ⇒ Object
Returns the value of attribute flush_interval.
-
#ignored_hosts ⇒ Object
Returns the value of attribute ignored_hosts.
-
#on_flush_error ⇒ Object
Returns the value of attribute on_flush_error.
-
#registry_cache_path ⇒ Object
Returns the value of attribute registry_cache_path.
-
#registry_refresh_interval ⇒ Object
Returns the value of attribute registry_refresh_interval.
-
#sample_rate ⇒ Object
Returns the value of attribute sample_rate.
Instance Method Summary collapse
-
#ignored_host?(host) ⇒ Boolean
Returns true if
hostshould be skipped. -
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/apidepth/configuration.rb', line 27 def initialize @enabled = true @flush_interval = 20 @registry_refresh_interval = 6 * 60 * 60 @registry_cache_path = "/tmp/apidepth_registry.json" @collector_url = nil @_user_hosts = [] @on_flush_error = nil @environment = nil # Railtie sets this to Rails.env at boot @sample_rate = 1.0 # capture everything by default @extra_vendors = {} # customer-defined host mappings _rebuild_ignored_hosts end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
15 16 17 |
# File 'lib/apidepth/configuration.rb', line 15 def api_key @api_key end |
#collector_url ⇒ Object
Returns the value of attribute collector_url.
25 26 27 |
# File 'lib/apidepth/configuration.rb', line 25 def collector_url @collector_url end |
#enabled ⇒ Object
Returns the value of attribute enabled.
15 16 17 |
# File 'lib/apidepth/configuration.rb', line 15 def enabled @enabled end |
#environment ⇒ Object
Returns the value of attribute environment.
15 16 17 |
# File 'lib/apidepth/configuration.rb', line 15 def environment @environment end |
#extra_vendors ⇒ Object
Returns the value of attribute extra_vendors.
15 16 17 |
# File 'lib/apidepth/configuration.rb', line 15 def extra_vendors @extra_vendors end |
#flush_interval ⇒ Object
Returns the value of attribute flush_interval.
15 16 17 |
# File 'lib/apidepth/configuration.rb', line 15 def flush_interval @flush_interval end |
#ignored_hosts ⇒ Object
Returns the value of attribute ignored_hosts.
25 26 27 |
# File 'lib/apidepth/configuration.rb', line 25 def ignored_hosts @ignored_hosts end |
#on_flush_error ⇒ Object
Returns the value of attribute on_flush_error.
15 16 17 |
# File 'lib/apidepth/configuration.rb', line 15 def on_flush_error @on_flush_error end |
#registry_cache_path ⇒ Object
Returns the value of attribute registry_cache_path.
15 16 17 |
# File 'lib/apidepth/configuration.rb', line 15 def registry_cache_path @registry_cache_path end |
#registry_refresh_interval ⇒ Object
Returns the value of attribute registry_refresh_interval.
15 16 17 |
# File 'lib/apidepth/configuration.rb', line 15 def registry_refresh_interval @registry_refresh_interval end |
#sample_rate ⇒ Object
Returns the value of attribute sample_rate.
15 16 17 |
# File 'lib/apidepth/configuration.rb', line 15 def sample_rate @sample_rate end |
Instance Method Details
#ignored_host?(host) ⇒ Boolean
Returns true if host should be skipped. Supports glob wildcards (* matches any sequence, ? matches one character) so customers can ignore entire internal domains: “*.internal”, “*.svc.cluster.local”.
54 55 56 57 |
# File 'lib/apidepth/configuration.rb', line 54 def ignored_host?(host) @_exact_ignored.include?(host) || @_glob_ignored.any? { |pat| File.fnmatch(pat, host) } end |