-
Notifications
You must be signed in to change notification settings - Fork 375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update core configuration to use env and type options #2988
Update core configuration to use env and type options #2988
Conversation
68b041f
to
2ee5597
Compare
526ebfd
to
a118dbd
Compare
a118dbd
to
ce03d19
Compare
@@ -35,10 +41,26 @@ class Settings < Contrib::Configuration::Settings | |||
end | |||
|
|||
option :error_status_codes do |o| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't add the type
to the error_status_code
option, because in the tests the values used are Array and Range. I didn't wanted to change the backend logic for :array
on this PR. So I will leave the decision to adding the type
to the original author of this integration
@@ -35,10 +41,26 @@ class Settings < Contrib::Configuration::Settings | |||
end | |||
|
|||
option :error_status_codes do |o| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -35,10 +41,26 @@ class Settings < Contrib::Configuration::Settings | |||
end | |||
|
|||
option :error_status_codes do |o| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's in mega good shape! I left a few small notes, and I think after looking into them/discussing them, this is good to go.
One additional note: when running the specs manually I'm seeing a bunch of
/lib/datadog/core/configuration/options.rb:27: warning: instance variable @settings_name not initialized
I think this happens for top-level groups (e.g. c.agent
) that don't get to have a custom class. I think the fix is as simple as settings_name = defined?(@settings_name) && @settings_name
, as we do in a few other places in the codebase.
option :error_handler, experimental_default_proc: Tracing::SpanOperation::Events::DEFAULT_ON_ERROR | ||
option :error_handler do |o| | ||
o.type :proc | ||
o.experimental_default_proc(&Tracing::SpanOperation::Events::DEFAULT_ON_ERROR) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not for this PR -- but are we're ready to make a decision on the experimental_default_proc
?
E.g. do we want to keep it as-is for now (probably rename it), or do you still have plans to change/remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, no plans to remove it. We should rename it to default_proc
😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack! Created https://github.com/DataDog/ruby-guild/issues/29 to record it (Datadog-only link)
o.lazy | ||
o.type :float | ||
o.env Ext::ENV_ANALYTICS_SAMPLE_RATE | ||
o.default 1.0 | ||
end | ||
|
||
option :quantize, default: {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sarahchen6 Maybe worth adding a type here as a follow-up PR to Gustavo's?
o.on_set do |value| | ||
# Update ActionPack analytics too | ||
Datadog.configuration.tracing[:action_pack][:analytics_enabled] = value | ||
Datadog.configuration.tracing[:action_pack][:analytics_enabled] = value unless value.nil? | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's subtle, but since both this setting, as well as the action_pack setting allow nil
, I think perhaps that unless value.nil?
is perhaps not the best idea (because in a way, nil
previously meant "disable everything" and now only means "disable only rails".
In practice in most cases it'll be equivalent, but my thinking is, why change it, if we can keep the exact same previous behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 00b1168
On a private Zoom call, we also discussed that rails
and action_pack
supporting nil
for analytics_enabled
is weird and that we should use a boolean value instead.
That change should be done on a separate PR
ce03d19
to
1e31049
Compare
Datadog.logger.warn { "#{Tracing::Configuration::Ext::ClientIp::ENV_DISABLED} environment variable is deprecated, found set to #{disabled}, use #{Tracing::Configuration::Ext::ClientIp::ENV_ENABLED}=#{!disabled}" } | ||
Datadog::Core.log_deprecation do | ||
"#{Tracing::Configuration::Ext::ClientIp::ENV_DISABLED} environment variable is deprecated, use #{Tracing::Configuration::Ext::ClientIp::ENV_ENABLED} instead." | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
option :writer_options, default: ->(_i) { {} } | ||
# @return [Hash] | ||
option :writer_options do |o| | ||
o.type :hash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was changed to not nillable, but after inspecting our codebase, this change has no impact as the default {}
is accepted everywhere nil
would.
option :trace_flush do |o| | ||
o.default { nil } | ||
end | ||
option :trace_flush |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When nothing is configured like this, is the type nillable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When there's no type, the validation is disabled completely (https://github.com/DataDog/dd-trace-rb/blob/master/lib/datadog/core/configuration/option.rb#L237) so it's a bit different from nillable (because nillable is a modifier after you select a specific type)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing really blocking this, awesome job!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 LGTM!
For future PRs, I'd suggest not force-pushing after the first review is posted, as it makes it hard to see what has changed between revisions.
I'm the "trust, but verify" kinda person so I always like to give a look to the overall diff to try to spot new accidental issues, and this makes it hard to know if the older commits have changed :)
What does this PR do?
This code has been extracted from #2970 to facilitate the review process.
This PR focus on updating our current settings options to use
env
andtype
new functionality #2983The only addition outside of updating the settings is making sure the default value gets duplicated before setting it a118dbd
There has been a discussion rather than duplicating. We should make sure that it is frozen to avoid unwanted changes to the value. #2970 (comment)
That change would be done on a separate PR
Motivation
Additional Notes
How to test the change?