Class: Flare::HttpMetricsConfig
- Inherits:
-
Object
- Object
- Flare::HttpMetricsConfig
- Defined in:
- lib/flare/http_metrics_config.rb
Defined Under Namespace
Classes: HostConfig
Constant Summary collapse
- DEFAULT =
new.tap do |config| config.host "flare.am" do |h| h.allow %r{/api/metrics} end config.host "www.flippercloud.io" do |h| h.map %r{/adapter/features/[^/]+/(boolean|actors|groups|percentage_of_actors|percentage_of_time|expression|clear)}, "/adapter/features/:name/:gate" h.map %r{/adapter/features/[^/]+}, "/adapter/features/:name" h.map %r{/adapter/actors/[^/]+}, "/adapter/actors/:id" h.allow %r{/adapter/features} h.allow %r{/adapter/import} h.allow %r{/adapter/telemetry/summary} h.allow %r{/adapter/telemetry} h.allow %r{/adapter/events} h.allow %r{/adapter/audits} end end.freeze
Instance Method Summary collapse
- #host(hostname, mode = nil, &block) ⇒ Object
-
#initialize ⇒ HttpMetricsConfig
constructor
A new instance of HttpMetricsConfig.
- #initialize_copy(source) ⇒ Object
-
#resolve(hostname, path) ⇒ Object
Resolve a host+path to the target path for metrics.
Constructor Details
#initialize ⇒ HttpMetricsConfig
Returns a new instance of HttpMetricsConfig.
54 55 56 |
# File 'lib/flare/http_metrics_config.rb', line 54 def initialize @hosts = {} end |
Instance Method Details
#host(hostname, mode = nil, &block) ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'lib/flare/http_metrics_config.rb', line 62 def host(hostname, mode = nil, &block) config = @hosts[hostname] ||= HostConfig.new if mode == :all config.all elsif block yield config end end |
#initialize_copy(source) ⇒ Object
58 59 60 |
# File 'lib/flare/http_metrics_config.rb', line 58 def initialize_copy(source) @hosts = source.instance_variable_get(:@hosts).transform_values(&:dup) end |
#resolve(hostname, path) ⇒ Object
Resolve a host+path to the target path for metrics. Returns “*” for unknown hosts or unmatched paths. Returns nil to signal “use normalize_path”. Returns a string for custom replacements.
76 77 78 79 80 81 |
# File 'lib/flare/http_metrics_config.rb', line 76 def resolve(hostname, path) host_config = @hosts[hostname] return "*" unless host_config host_config.resolve(path) end |