Skip to content

refactor(config): modernize Config class structure and extract stateless methods#7408

Merged
BridgeAR merged 10 commits intomasterfrom
watson/clean-up-config
Feb 2, 2026
Merged

refactor(config): modernize Config class structure and extract stateless methods#7408
BridgeAR merged 10 commits intomasterfrom
watson/clean-up-config

Conversation

@watson
Copy link
Copy Markdown
Collaborator

@watson watson commented Feb 2, 2026

What does this PR do?

Refactor the Config class in packages/dd-trace/src/config/index.js to improve code organization:

  • Extracted stateless methods: Moved 10+ private methods that don't rely on instance state (this) outside the Config class as standalone functions
  • Modernized private fields: Replaced underscore-prefixed pseudo-private methods (_method) with proper ES2022 private class fields (#method)
  • Improved organization: Consolidated all helper functions below the class definition for better code navigation, and grouped public/private methods within the class
  • Updated data structures: Converted plain objects to Map instances where they were used as key-value stores (OTEL_DD_ENV_MAPPING, TELEMETRY_COUNTERS)
  • Standardized constants: Renamed module-level constants to use SCREAMING_SNAKE_CASE convention (RUNTIME_ID, NAMING_VERSIONS, etc.)
  • Core module imports: Added node: prefix to Node.js core module imports (fs, os, url, path) per modern conventions

All changes are purely structural with no behavioral modifications.

Motivation

The Config class has grown organically over time and accumulated methods that don't actually need instance access. This refactoring:

  • Makes the codebase more maintainable by clarifying which code operates on instance state vs. pure logic
  • Aligns with project coding standards (proper private fields, consistent naming, modern imports)
  • Makes the code easier to navigate with better organization

Additional Notes

  • The refactoring was done incrementally across multiple commits for easier review

Copy link
Copy Markdown
Collaborator Author

watson commented Feb 2, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@watson watson self-assigned this Feb 2, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 2, 2026

Overall package size

Self size: 4.49 MB
Deduped: 5.32 MB
No deduping: 5.32 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 2.0.3 | 76.87 kB | 808.03 kB | | dc-polyfill | 0.1.10 | 26.73 kB | 26.73 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 2, 2026

Codecov Report

❌ Patch coverage is 97.25000% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.56%. Comparing base (75b67c2) to head (3f99c0c).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
packages/dd-trace/src/config/index.js 97.25% 11 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7408      +/-   ##
==========================================
- Coverage   85.83%   80.56%   -5.28%     
==========================================
  Files         518      731     +213     
  Lines       22376    31236    +8860     
==========================================
+ Hits        19207    25165    +5958     
- Misses       3169     6071    +2902     
Flag Coverage Δ
aiguard-macos 39.11% <63.50%> (-59.99%) ⬇️
aiguard-ubuntu 39.15% <63.50%> (-59.95%) ⬇️
aiguard-windows 39.00% <63.50%> (-60.10%) ⬇️
apm-capabilities-tracing-macos 48.92% <97.25%> (-8.73%) ⬇️
apm-capabilities-tracing-ubuntu 48.92% <97.25%> (-8.74%) ⬇️
apm-capabilities-tracing-windows 48.64% <97.25%> (-8.65%) ⬇️
apm-integrations-child-process 38.61% <63.50%> (-60.59%) ⬇️
apm-integrations-couchbase-18 37.33% <63.50%> (-62.67%) ⬇️
apm-integrations-couchbase-eol 37.96% <63.50%> (-62.04%) ⬇️
apm-integrations-oracledb 38.01% <63.50%> (?)
appsec-express 55.46% <63.75%> (-7.09%) ⬇️
appsec-fastify 52.06% <63.75%> (-6.49%) ⬇️
appsec-graphql 52.39% <64.25%> (-1.02%) ⬇️
appsec-kafka 44.68% <63.50%> (+0.70%) ⬆️
appsec-ldapjs 44.35% <63.50%> (-1.69%) ⬇️
appsec-lodash 44.03% <63.50%> (-3.26%) ⬇️
appsec-macos 58.53% <64.75%> (-35.24%) ⬇️
appsec-mongodb-core 49.26% <63.50%> (-2.57%) ⬇️
appsec-mongoose 49.96% <63.50%> (-0.78%) ⬇️
appsec-mysql 51.33% <63.75%> (-2.83%) ⬇️
appsec-node-serialize 43.54% <63.50%> (-0.38%) ⬇️
appsec-passport 48.15% <63.75%> (+0.08%) ⬆️
appsec-postgres 51.10% <63.75%> (-3.42%) ⬇️
appsec-sourcing 42.88% <63.50%> (+9.08%) ⬆️
appsec-template 43.71% <63.50%> (-0.21%) ⬇️
appsec-ubuntu 58.55% <64.75%> (-35.21%) ⬇️
appsec-windows 58.41% <64.75%> (-35.36%) ⬇️
instrumentations-instrumentation-bluebird 32.28% <63.50%> (?)
instrumentations-instrumentation-body-parser 40.75% <63.50%> (?)
instrumentations-instrumentation-child_process 37.91% <63.50%> (?)
instrumentations-instrumentation-cookie-parser 34.52% <63.50%> (?)
instrumentations-instrumentation-express 34.86% <63.50%> (?)
instrumentations-instrumentation-express-mongo-sanitize 34.66% <63.50%> (?)
instrumentations-instrumentation-express-session 40.43% <63.50%> (?)
instrumentations-instrumentation-fs 31.88% <63.50%> (?)
instrumentations-instrumentation-generic-pool 29.77% <ø> (?)
instrumentations-instrumentation-http 39.64% <63.50%> (?)
instrumentations-instrumentation-knex 32.03% <63.50%> (?)
instrumentations-instrumentation-mongoose 33.60% <63.50%> (?)
instrumentations-instrumentation-multer 40.49% <63.50%> (?)
instrumentations-instrumentation-mysql2 38.30% <63.50%> (?)
instrumentations-instrumentation-passport 40.79% <63.50%> (?)
instrumentations-instrumentation-passport-http 40.76% <63.50%> (?)
instrumentations-instrumentation-passport-local 40.76% <63.50%> (?)
instrumentations-instrumentation-pg 37.81% <63.50%> (?)
instrumentations-instrumentation-promise 32.20% <63.50%> (?)
instrumentations-instrumentation-promise-js 32.21% <63.50%> (?)
instrumentations-instrumentation-q 32.26% <63.50%> (?)
instrumentations-instrumentation-url 32.17% <63.50%> (?)
instrumentations-instrumentation-when 32.23% <63.50%> (?)
llmobs-ai 41.41% <63.75%> (-10.68%) ⬇️
llmobs-anthropic 40.62% <63.75%> (-2.11%) ⬇️
llmobs-bedrock 39.51% <63.75%> (-0.56%) ⬇️
llmobs-google-genai 40.11% <63.75%> (-5.79%) ⬇️
llmobs-langchain 39.65% <63.75%> (-10.51%) ⬇️
llmobs-openai 44.46% <63.75%> (-11.16%) ⬇️
llmobs-vertex-ai 40.40% <63.75%> (-4.08%) ⬇️
platform-core 28.09% <ø> (-59.15%) ⬇️
platform-esbuild 31.49% <ø> (?)
platform-instrumentations-misc 39.62% <ø> (-49.55%) ⬇️
platform-shimmer 34.83% <ø> (-63.98%) ⬇️
platform-unit-guardrails 30.37% <ø> (-59.10%) ⬇️
plugins-azure-event-hubs 22.64% <ø> (?)
plugins-azure-service-bus 22.08% <ø> (?)
plugins-bullmq 43.60% <63.50%> (?)
plugins-cassandra 38.05% <63.50%> (?)
plugins-cookie 23.69% <ø> (?)
plugins-cookie-parser 23.50% <ø> (?)
plugins-crypto 22.88% <ø> (?)
plugins-dd-trace-api 38.42% <63.50%> (?)
plugins-express-mongo-sanitize 23.67% <ø> (?)
plugins-express-session 23.46% <ø> (?)
plugins-fastify 42.56% <63.50%> (?)
plugins-fetch 38.61% <63.50%> (?)
plugins-fs 38.68% <63.50%> (?)
plugins-generic-pool 22.68% <ø> (?)
plugins-google-cloud-pubsub 45.77% <63.50%> (?)
plugins-grpc 41.33% <63.50%> (?)
plugins-handlebars 23.71% <ø> (?)
plugins-hapi 40.45% <63.50%> (?)
plugins-hono 40.65% <63.50%> (?)
plugins-ioredis 38.48% <63.50%> (?)
plugins-knex 23.51% <ø> (?)
plugins-ldapjs 21.28% <ø> (?)
plugins-limitd-client 32.58% <63.50%> (?)
plugins-lodash 22.74% <ø> (?)
plugins-mariadb 39.55% <63.50%> (?)
plugins-memcached 38.21% <63.50%> (?)
plugins-microgateway-core 39.46% <63.50%> (?)
plugins-moleculer 40.86% <63.50%> (?)
plugins-mongodb 39.57% <63.50%> (?)
plugins-mongodb-core 39.14% <63.50%> (?)
plugins-mongoose 40.43% <63.50%> (?)
plugins-multer 23.46% <ø> (?)
plugins-mysql 39.27% <63.50%> (?)
plugins-mysql2 39.32% <63.50%> (?)
plugins-node-serialize 23.73% <ø> (?)
plugins-opensearch 37.88% <63.50%> (?)
plugins-postgres 35.70% <63.50%> (?)
plugins-process 22.88% <ø> (?)
plugins-pug 23.69% <ø> (?)
plugins-redis 38.81% <63.50%> (?)
plugins-router 43.28% <63.50%> (?)
plugins-sequelize 22.27% <ø> (?)
plugins-test-and-upstream-amqp10 38.40% <63.50%> (?)
plugins-test-and-upstream-amqplib 43.93% <63.50%> (?)
plugins-test-and-upstream-apollo 39.34% <63.50%> (?)
plugins-test-and-upstream-avsc 38.84% <63.50%> (?)
plugins-test-and-upstream-bunyan 33.87% <63.50%> (?)
plugins-test-and-upstream-connect 41.07% <63.50%> (?)
plugins-test-and-upstream-graphql 40.25% <63.50%> (?)
plugins-test-and-upstream-koa 40.71% <63.50%> (?)
plugins-test-and-upstream-protobufjs 39.07% <63.50%> (?)
plugins-test-and-upstream-rhea 44.19% <63.50%> (?)
plugins-undici 39.41% <63.50%> (?)
plugins-url 22.88% <ø> (?)
plugins-valkey 38.13% <63.50%> (?)
plugins-vm 22.88% <ø> (?)
plugins-winston 34.37% <63.50%> (?)
plugins-ws 40.78% <63.50%> (?)
profiling-macos 40.07% <63.50%> (-30.67%) ⬇️
profiling-ubuntu 40.12% <63.50%> (-30.62%) ⬇️
profiling-windows 41.49% <63.50%> (-32.74%) ⬇️
serverless-azure-functions-client 22.88% <ø> (?)
serverless-azure-functions-eventhubs 22.88% <ø> (?)
serverless-azure-functions-servicebus 22.88% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@datadog-official

This comment has been minimized.

@watson watson force-pushed the watson/clean-up-config branch from 24092ac to c02431b Compare February 2, 2026 07:08
@pr-commenter
Copy link
Copy Markdown

pr-commenter bot commented Feb 2, 2026

Benchmarks

Benchmark execution time: 2026-02-02 07:21:59

Comparing candidate commit 3f99c0c in PR branch watson/clean-up-config with baseline commit 75b67c2 in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 231 metrics, 29 unstable metrics.

@watson watson marked this pull request as ready for review February 2, 2026 07:41
@watson watson requested a review from a team as a code owner February 2, 2026 07:41
@watson watson requested review from BridgeAR and removed request for a team February 2, 2026 07:41
Copy link
Copy Markdown
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not have a strong opinion on these improvements, while they should all be fine.

@BridgeAR BridgeAR merged commit 0ac5788 into master Feb 2, 2026
787 checks passed
@BridgeAR BridgeAR deleted the watson/clean-up-config branch February 2, 2026 08:41
dd-octo-sts bot pushed a commit that referenced this pull request Feb 3, 2026
…ess methods (#7408)

* Move stateless methods outside of Config class

* Group private/public methods in Config class

* Use proper private methods instead of underscore-prefix

* Remove whitespace

* Move functions below Config class + export above

* Capitalize constants + use Maps for map-like objects

* Use node: prefix for core modules

* Group imports correctly

* Move configInstance variable to the top
@dd-octo-sts dd-octo-sts bot mentioned this pull request Feb 3, 2026
BridgeAR pushed a commit that referenced this pull request Feb 5, 2026
…ess methods (#7408)

* Move stateless methods outside of Config class

* Group private/public methods in Config class

* Use proper private methods instead of underscore-prefix

* Remove whitespace

* Move functions below Config class + export above

* Capitalize constants + use Maps for map-like objects

* Use node: prefix for core modules

* Group imports correctly

* Move configInstance variable to the top
bm1549 pushed a commit that referenced this pull request Feb 10, 2026
…ess methods (#7408)

* Move stateless methods outside of Config class

* Group private/public methods in Config class

* Use proper private methods instead of underscore-prefix

* Remove whitespace

* Move functions below Config class + export above

* Capitalize constants + use Maps for map-like objects

* Use node: prefix for core modules

* Group imports correctly

* Move configInstance variable to the top
BridgeAR pushed a commit that referenced this pull request Feb 22, 2026
…ess methods (#7408)

* Move stateless methods outside of Config class

* Group private/public methods in Config class

* Use proper private methods instead of underscore-prefix

* Remove whitespace

* Move functions below Config class + export above

* Capitalize constants + use Maps for map-like objects

* Use node: prefix for core modules

* Group imports correctly

* Move configInstance variable to the top
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants