Repository navigation
Conversation
…dependent extend The data_streams accessor on Core::Configuration::Settings previously only existed if lib/datadog/data_streams.rb was required, which only happens via the full lib/datadog.rb entrypoint. Any process with a narrower require chain (e.g. some CI test suites) got a NoMethodError for settings.data_streams. Move the data_streams settings block directly into Settings' class body in settings.rb, matching the pattern used by profiling/crashtracking/etc., so it's always present regardless of require order. Remove the now-dead extend-based registration in data_streams/configuration.rb and data_streams/extensions.rb. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 3089b0d | Docs | View more details | Give us feedback! |
BenchmarksBenchmark execution time: 2026-08-20 13:50:06 Comparing candidate commit 3089b0d in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 48 metrics, 1 unstable metrics.
|
eregon
left a comment
There was a problem hiding this comment.
Nice, much simpler and more reliable
ivoanjo
left a comment
There was a problem hiding this comment.
👍 LGTM this is great!
This pattern of "extending settings instead of inlining" is something that other components of dd-trace-rb tried and I think overall the experiment didn't go very well.
It causes order-dependent failures, it's really confusing (where is this defined?), and in the end is not particularly "modular" -- monkey patching means the original classes are modified anyway.
So I'm a big fan to going back to basics. Maybe one day we'll come up with a new way of doing settings and we'll be able to separate these out again, but for now I think this is the way to go.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 003d1989d4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
lib/datadog/data_streams/ext.rb is marked @public_api, and used to be loaded transitively through data_streams/configuration.rb's require. Now that configuration.rb is gone, a narrow-require consumer referencing Datadog::DataStreams::Ext::ENV_ENABLED gets a NameError. Require it directly from the data_streams entrypoint. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Sorry, if a test misrequires a product (data streams in this case, per PR description), I don't find this a valid reason to move product functionality into core. What is the test fix? ~5 lines of requires added? |
|
I don't have a strong opinion about it but if we really want to keep core and data_stream separated, we could instead extend |
As I mentioned above, I think extension here is a mistake -- monkey patching is confusing and creates these sharp edges. (I think tracing and opentelemetry should move away from this pattern as well) Yes, we should have a better solution for configuring modules independently, and I would 100% support that as an alternative here, but IMHO that should not be "monkey patching into core". |
|
For further evidence of why I claim our "monkey patch" approach doesn't make sense, look at #6291 : We have Our current setup "pretends" like configuration is local, but it's not really -- it needs global changes, hence my claim that we should start pretending to be local until we actually make it local (and in such a situation, adding a new setting would mean core actually wouldn't need to change, including for env vars). |

What does this PR do?
Moves the
data_streamssettings block (enabled,interval) directly intoCore::Configuration::Settings's class body insettings.rb, the same wayprofiling/crashtracking/other product settings are registered.Removes
lib/datadog/data_streams/configuration.rbandlib/datadog/data_streams/extensions.rb, which registereddata_streamssettings viaCore::Configuration::Settings.extend(...), only triggered whenlib/datadog/data_streams.rbwas required.Motivation:
settings.data_streamspreviously only existed iflib/datadog/data_streams.rbwas required, which only happens via the fulllib/datadog.rbentrypoint.Any process with a narrower require chain (e.g. some CI test suites that require individual products directly) hit
NoMethodError: undefined method 'data_streams', silently caught and logged as a warning byComponents#build_data_streams.Registering the settings inline removes the load-order dependency entirely, matching the more robust pattern already used elsewhere in the codebase.
Change log entry
None. This is an internal fix for an edge case affecting narrow-require processes/tests;
settings.data_streamsalready worked correctly in the normal boot path and no defaults, option names, or public behavior changed.Additional Notes:
None.
How to test the change?
Added
describe "#data_streams"coverage inspec/datadog/core/configuration/settings_spec.rbforenabled/enabled=/interval/interval=, matching the existing#crashtrackingtests.Verified via a local repro (using the narrow require chain from
spec/datadog/di/integration/implicit_enablement_spec.rb) thatsettings.data_streamsraisedNoMethodErroronmasterand no longer does with this change.