lib/new_relic/agent/configuration/manager.rb in newrelic_rpm-8.4.0 vs lib/new_relic/agent/configuration/manager.rb in newrelic_rpm-8.5.0

- old
+ new

@@ -111,14 +111,12 @@ config_stack.each do |config| next unless config accessor = key.to_sym if config.has_key?(accessor) - evaluated = evaluate_procs(config[accessor]) - begin - return apply_transformations(accessor, evaluated) + return evaluate_and_apply_transformations(accessor, config[accessor]) rescue next end end end @@ -132,10 +130,14 @@ else value end end + def evaluate_and_apply_transformations(key, value) + apply_transformations(key, evaluate_procs(value)) + end + def apply_transformations(key, value) if transform = transform_from_default(key) begin transform.call(value) rescue => e @@ -157,15 +159,24 @@ end def invoke_callbacks(direction, source) return unless source source.keys.each do |key| - if @cache[key] != source[key] + begin + # we need to evaluate and apply transformations for the value to deal with procs as values + # this is usually done by the fetch method when accessing config, however the callbacks bypass that + evaluated_cache = evaluate_and_apply_transformations(key, @cache[key]) + evaluated_source = evaluate_and_apply_transformations(key, source[key]) + rescue + next + end + + if evaluated_cache != evaluated_source @callbacks[key].each do |proc| if direction == :add - proc.call(source[key]) + proc.call(evaluated_source) else - proc.call(@cache[key]) + proc.call(evaluated_cache) end end end end end