diff --git a/lib/ddtrace/configuration/proxy.rb b/lib/ddtrace/configuration/proxy.rb index 8b904cbe10b..2be1a06d0f1 100644 --- a/lib/ddtrace/configuration/proxy.rb +++ b/lib/ddtrace/configuration/proxy.rb @@ -7,7 +7,11 @@ def initialize(integration) end def [](param) - @integration.get_option(param) + value = @integration.get_option(param) + + return value.call if value.respond_to?(:call) + + value end def []=(param, value) diff --git a/test/configuration_test.rb b/test/configuration_test.rb index a544c34cbb4..28546d7faa0 100644 --- a/test/configuration_test.rb +++ b/test/configuration_test.rb @@ -50,6 +50,17 @@ def test_invalid_integration end end + def test_lazy_option + integration = Module.new do + include Contrib::Base + option :option1, default: -> { 1 + 1 } + end + + @registry.add(:example, integration) + + assert_equal(2, @configuration[:example][:option1]) + end + def test_hash_coercion integration = Module.new do include Contrib::Base