Skip to content

changes to option proc loads broke default usage #3182

Closed

Description

Current behaviour

I've had a build failure with the master version of the datadog plugin configuration of this gem I maintain. The error message doesn't show it, but the tests fail here, when loading the default error handler. I could reproduce the backtrace locally, and here it is:

= 1)), "last_error" = 'undefined method `set_error'' for #<Datadog::Tracing::Contrib::Tobox::Configuration::Settings:0x0000000108580418 @options={:enabled=>#<Datadog::Core::Configuration::Option:0x0000000
107c09970 @definition=#<Datadog::Core::Configuration::OptionDefinition:0x0000000107c46410 @default=#<Proc:0x000000010858daf0 /user/dev/tobox/lib/tobox/plugins/datadog/configuration.rb:14>, @
experimental_default_proc=nil, @env=nil, @deprecated_env=nil, @env_parser=nil, @delegate_to=nil, @depends_on=[], @name=:enabled, @on_set=nil, @resetter=nil, @setter=#<Proc:0x0000000107cdc7f8 /user/dev/tobox/.bundle/ruby/3.2.0/gems/ddtrace-1.14.0/lib/datadog/core/configuration/option_definition.rb:10 (lambda)>, @type=nil, @type_options={}>, @context=#<Datadog::Tracing::Contrib::Tobox::Configu
ration::Settings:0x0000000108580418 ...>, @value=true, @is_set=true, @value_per_precedence={#<struct Datadog::Core::Configuration::Option::Precedence::Value numeric=0, name=:default>=>true}, @precedence_s
et=#<struct Datadog::Core::Configuration::Option::Precedence::Value numeric=0, name=:default>>, :service_name=>#<Datadog::Core::Configuration::Option:0x00000001089ccc60 @definition=#<Datadog::Core::Config
uration::OptionDefinition:0x0000000107c45d30 @default=nil, @experimental_default_proc=nil, @env=nil, @deprecated_env=nil, @env_parser=nil, @delegate_to=nil, @depends_on=[], @name=:service_name, @on_set=ni
l, @resetter=nil, @setter=#<Proc:0x0000000107cdc7f8 /user/dev/tobox/.bundle/ruby/3.2.0/gems/ddtrace-1.14.0/lib/datadog/core/configuration/option_definition.rb:10 (lambda)>, @type=nil, @type_
options={}>, @context=#<Datadog::Tracing::Contrib::Tobox::Configuration::Settings:0x0000000108580418 ...>, @value=nil, @is_set=true, @value_per_precedence={#<struct Datadog::Core::Configuration::Option::P
recedence::Value numeric=0, name=:default>=>nil}, @precedence_set=#<struct Datadog::Core::Configuration::Option::Precedence::Value numeric=0, name=:default>>, :error_handler=>#<Datadog::Core::Configuratio
n::Option:0x00000001087a8ee8 @definition=#<Datadog::Core::Configuration::OptionDefinition:0x0000000107c45bf0 @default=#<Proc:0x00000001082297b0 /user/dev/tobox/.bundle/ruby/3.2.0/gems/ddtrac
e-1.14.0/lib/datadog/tracing/span_operation.rb:338>, @experimental_default_proc=nil, @env=nil, @deprecated_env=nil, @env_parser=nil, @delegate_to=nil, @depends_on=[], @name=:error_handler, @on_set=nil, @r
esetter=nil, @setter=#<Proc:0x0000000107cdc7f8 /Users/tiagocardoso/dev/tobox/.bundle/ruby/3.2.0/gems/ddtrace-1.14.0/lib/datadog/core/configuration/option_definition.rb:10 (lambda)>, @type=nil, @type_optio
ns={}>, @context=#<Datadog::Tracing::Contrib::Tobox::Configuration::Settings:0x0000000108580418 ...>, @value=nil, @is_set=false, @value_per_precedence={}, @precedence_set=#<struct Datadog::Core::Configura
tion::Option::Precedence::Value numeric=0, name=:default>>}>
/user/dev/tobox/.bundle/ruby/3.2.0/gems/ddtrace-1.14.0/lib/datadog/tracing/span_operation.rb:338:in `block in <class:Events>''
/user/dev/tobox/.bundle/ruby/3.2.0/gems/ddtrace-1.14.0/lib/datadog/core/configuration/option.rb:278:in `instance_eval''
/user/dev/tobox/.bundle/ruby/3.2.0/gems/ddtrace-1.14.0/lib/datadog/core/configuration/option.rb:278:in `context_eval''
/user/dev/tobox/.bundle/ruby/3.2.0/gems/ddtrace-1.14.0/lib/datadog/core/configuration/option.rb:142:in `default_value''
/user/dev/tobox/.bundle/ruby/3.2.0/gems/ddtrace-1.14.0/lib/datadog/core/configuration/option.rb:299:in `set_value_from_env_or_default''
/user/dev/tobox/.bundle/ruby/3.2.0/gems/ddtrace-1.14.0/lib/datadog/core/configuration/option.rb:119:in `get''
/user/dev/tobox/.bundle/ruby/3.2.0/gems/ddtrace-1.14.0/lib/datadog/core/configuration/options.rb:79:in `get_option''
/user/dev/tobox/.bundle/ruby/3.2.0/gems/ddtrace-1.14.0/lib/datadog/core/configuration/options.rb:46:in `block in default_helpers''
/user/dev/tobox/.bundle/ruby/3.2.0/gems/ddtrace-1.14.0/lib/datadog/tracing/contrib/configuration/settings.rb:29:in `[]''
/user/dev/tobox/lib/tobox/plugins/datadog.rb:20:in `on_start''
/user/dev/tobox/lib/tobox/fetcher.rb:166:in `block in handle_before_event''
/user/dev/tobox/lib/tobox/fetcher.rb:165:in `each''

Expected behaviour

I was expecting this to keep working.

I assume this was caused by this change, which is providing a path to migrate away from setting defaults like that. While that may be warranted (and should be done in a major change), it shouldn't happen at the cost of the old API breaking.

FWIW I was following changes in other adapters in order to come up with this patch, which is a bit more complicated than I would have expected to maintain as an external plugin for a 1.x series of a given library (hope what I say makes sense from your perspective).

Steps to reproduce

Load the tobox repo locally, use any supported ruby (you can use 3.2), set up a usable database (postgres is advised), set it up in DATABASE_URL (i.e. export DATABASE_URL=postgresql://user:pass@host/db), and run the datadog test suite (bundle exec ruby -Itest integration_tests/datadog_test.rb).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

bugInvolves a bugcommunityWas opened by a community member

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions