Add class ConfigEnvSources to merge stable config and environment variables#6982
Add class ConfigEnvSources to merge stable config and environment variables#6982
Conversation
Overall package sizeSelf size: 4.44 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 2.0.0 | 68.46 kB | 797.03 kB | | dc-polyfill | 0.1.10 | 26.73 kB | 26.73 kB |🤖 This report was automatically generated by heaviest-objects-in-the-universe |
This comment has been minimized.
This comment has been minimized.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #6982 +/- ##
==========================================
+ Coverage 86.12% 86.16% +0.03%
==========================================
Files 513 513
Lines 22123 22147 +24
==========================================
+ Hits 19054 19082 +28
+ Misses 3069 3065 -4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
BenchmarksBenchmark execution time: 2026-01-22 10:44:16 Comparing candidate commit 8cc76b9 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 231 metrics, 29 unstable metrics. |
eacb99d to
a532c6a
Compare
282f094 to
948ddde
Compare
| if (errors.agentError) { | ||
| app.error = errors.agentError | ||
| errors.agentError = undefined |
There was a problem hiding this comment.
I am unsure why this was never activated before. I am going to try to verify that before landing.
There was a problem hiding this comment.
@bengl and me discussed it and the RFCs gone missing. We are going to activate it and see.
c745a69 to
b1308bc
Compare
b1308bc to
af99299
Compare
| if (errors.agentError) { | ||
| app.error = errors.agentError | ||
| errors.agentError = undefined |
There was a problem hiding this comment.
This is a quite significant change and it's hard for me to properly review it. As far as I can see, we only have one dedicated test for telemetry: integration-tests/telemetry.spec.js - but it doesn't test very much. It would be good with all these changes if we could extend it a bit in this PR.
There was a problem hiding this comment.
I went through the changes with @bengl. Mostly it is types. There are a few changes around the host and the error cases and the repeated setTimeout to setInterval. I will work more with telemetry soon and add additional tests there, while this should be safe.
bengl
left a comment
There was a problem hiding this comment.
LGTM except changes we discussed verbally.
bengl
left a comment
There was a problem hiding this comment.
LGTM except changes we discussed verbally.
bengl
left a comment
There was a problem hiding this comment.
LGTM except changes we discussed verbally.
fix circular dependency Migrate civis call to use getEnvironmnetVariableSources instead run linter cleanup comments on config-env-sources complete ci/init.js migration migrate otel-sdk-trace.js assert getResolvedEnv behaves just like getEnvironmentVariable when only envs exist migrate register.js migrate DD_TRACE_AWS_SDK_BATCH_PROPAGATION_ENABLED migrate DD_TRACE_AZURE_EVENTHUBS_BATCH_LINKS_ENABLED and DD_TRACE_AZURE_SERVICEBUS_BATCH_LINKS_ENABLED migrate cypress and cucumber DD_CIVISIBILITY_AUTO_INSTRUMENTATION_PROVIDER migrate dd-trace-api, mocha and jest migrate mongodb, playwright and vitest plugins migrate index.js -- specifically for disablement env vars -- and update tests to call resetEnvConfigSources migrate plugin_manager migrate DD_API_KEY in proxy.js Finish bulk migration fix debugger test: reset configenvsources Fix failing tests in ci fix failing lambda tets and aws-sdk tests whoops - include all changes to lambda tests migrate DD_TRACE_ENCODING_DEBUG and DD_TRACE_EXPERIMENTAL_STATE_TRACKING Try out not cachine env vars update config-env-sources tests accordingly Remove calls to resetConfigEnvSources in legacy tests nits restore exporter.spec.js have Config re-use the stable config entries from ConfigEnvSources Add doc for ConfigEnvSources drop config-env-sources; just use config-helper delete config env sources try again to delete config-env-sources Apply getValueFromEnvSources to rest of DD calls; fix serverless.js fix ritm fix more referecnes to config env sources fix another import fix calls to getEnvironmentVariables that need getValueFromEnvSources pass 'config' all the way down into profiler; remove duplicate config resolution logic use getValueFromEnvSources in profiler for DD_ configs leave TODO
Potentially split this into multiple PRs
670b08c to
e00b30a
Compare
…nt variables (#6982) This makes sure most environment variables will be reading from stable config. In addition, much code is cleaned up, types are added, and small improvements were added. --------- Co-authored-by: Ruben Bridgewater <ruben.bridgewater@datadoghq.com>
…nt variables (#6982) This makes sure most environment variables will be reading from stable config. In addition, much code is cleaned up, types are added, and small improvements were added. --------- Co-authored-by: Ruben Bridgewater <ruben.bridgewater@datadoghq.com>
Reviewer tips
The majority of code changes are just replacing
getEnvironmentVariablewithgetValueFromEnvSources. Feel free to gloss over those changes once you get the idea from a few, and instead focus on:Background
Currently, stable config files and environment variables are only processed when the Config class is instantiated, which happens in tracer.init(). This limits us from earlier access: code that runs before tracer.init() can't access stable config values.
This PR allows us to access stable config values before tracer.init(), when we peek at DD_TRACE env vars.
It also deduplicates configuration sourcing in profiler.
What does this PR do?
Introduces
getValueFromEnvSourcesAPI in config-helper.js that resolves configuration from local stable config, environment variables, and fleet stable config in ascending priority order, before theConfigsingleton is initialized. This method can be used instead ofgetEnvironmentVariablewhen we want to see whether particular DD_TRACE configs have been set.Key additions:
config-helper:
profiler
Motivation
All environment variables must be set-able via stable config files: RFC
Note
Not all calls to getEnvironmentVariable were replaced by getResolvedEnv. In some cases, we are really looking for an environment variable that is a heuristic for a particular type of environment. Stable config is not relevant in these cases.
Plugin Checklist
Additional Notes