Skip to content

Commit 8b21280

Browse files
rochdevclaude
andcommitted
feat(openfeature): vendor the flagging provider instead of an optional peer
`@datadog/openfeature-node-server` was an optional peer dependency resolved through a bundler-opaque require, requiring dedicated esbuild/webpack plugin code to keep the require invisible when the peer wasn't installed (#8635) and to inline it so bundles survived relocation when it was (#8980). Vendoring the provider into `vendor/dist/` removes the need for a peer at all, so all of that machinery (`feature-registry.js`, `register.js`, `require-provider.js`, the optional-peer esbuild/webpack loaders, and their integration tests) is deleted in favor of a single lazy `tracer.openfeature` property. The vendored provider's only remaining external dependency is `@openfeature/server-sdk`, used solely for `OpenFeatureEventEmitter` and `ProviderEvents`. Bundling our own copy would give those a different identity than the customer's, so it's externalized to a small bridge module (`server-sdk-bridge.js`) that a new `openfeature-server-sdk` instrumentation fills in from the customer's own `require()`. `FlaggingProvider#initialize` also unrefs the vendored provider's initialization timer, which otherwise keeps an idle process (a short script, a serverless handler) alive for up to `initializationTimeoutMs` while waiting for configuration to arrive. TODO left to remove this once `@datadog/openfeature-node-server` unrefs it upstream. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 87df4d6 commit 8b21280

42 files changed

Lines changed: 442 additions & 1112 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

LICENSE-3rdparty.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
"@jsep-plugin/assignment","https://github.com/EricSmekens/jsep","['MIT']","['Shelly']"
1717
"@jsep-plugin/regex","https://github.com/EricSmekens/jsep","['MIT']","['Shelly']"
1818
"@napi-rs/wasm-runtime","https://github.com/napi-rs/napi-rs","['MIT']","['LongYinan']"
19+
"@openfeature/core","https://github.com/open-feature/js-sdk","['Apache-2.0']","['OpenFeature Maintainers']"
20+
"@openfeature/server-sdk","https://github.com/open-feature/js-sdk","['Apache-2.0']","['OpenFeature Maintainers']"
1921
"@opentelemetry/api","https://github.com/open-telemetry/opentelemetry-js","['Apache-2.0']","['OpenTelemetry Authors']"
2022
"@opentelemetry/api-logs","https://github.com/open-telemetry/opentelemetry-js","['Apache-2.0']","['OpenTelemetry Authors']"
2123
"@opentelemetry/core","https://github.com/open-telemetry/opentelemetry-js","['Apache-2.0']","['OpenTelemetry Authors']"

README.md

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -93,24 +93,6 @@ Regardless of where you open the issue, someone at Datadog will try to help.
9393

9494
If you would like to trace your bundled application then please read this page on [bundling and dd-trace](https://docs.datadoghq.com/tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/#bundling). It includes information on how to use our ESBuild plugin and includes caveats for other bundlers.
9595

96-
When using the experimental OpenFeature provider in a bundled application, require it through the
97-
`dd-trace/openfeature` subpath. This subpath uses a plain `require`/`import` for its dependencies, so
98-
bundlers can resolve and include them at build time. It must be loaded after `tracer.init()`:
99-
100-
CommonJS:
101-
102-
```js
103-
const tracer = require('dd-trace').init()
104-
const openfeatureProvider = require('dd-trace/openfeature')
105-
```
106-
107-
ES modules: initialize the tracer with the `--import` flag (see the [ESM support](#ecmascript-modules-esm-support)
108-
section above) so it's ready before your application code runs, then import the provider normally:
109-
110-
```js
111-
import openfeatureProvider from 'dd-trace/openfeature.js'
112-
```
113-
11496

11597
## Security Vulnerabilities
11698

index.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ interface Tracer extends opentracing.Tracer {
163163
* @env DD_FEATURE_FLAGS_ENABLED
164164
* @env DD_FEATURE_FLAGS_CONFIGURATION_SOURCE
165165
* @beta This feature is in preview and not ready for production use
166-
* @deprecated Use `require('dd-trace/openfeature')` instead, which also works in bundled applications.
167166
*/
168167
openfeature: tracer.OpenFeatureProvider;
169168

index.d.v5.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ interface Tracer extends opentracing.Tracer {
163163
* @env DD_FEATURE_FLAGS_ENABLED
164164
* @env DD_FEATURE_FLAGS_CONFIGURATION_SOURCE
165165
* @beta This feature is in preview and not ready for production use
166-
* @deprecated Use `require('dd-trace/openfeature')` instead, which also works in bundled applications.
167166
*/
168167
openfeature: tracer.OpenFeatureProvider;
169168

integration-tests/esbuild/build-and-test-openfeature.js

Lines changed: 0 additions & 94 deletions
This file was deleted.

integration-tests/esbuild/index.spec.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,6 @@ esbuildVersions.forEach((version) => {
9595
})
9696
})
9797

98-
it('bundles the optional OpenFeature peer so it survives bundle relocation', () => {
99-
execSync('node ./build-and-test-openfeature.js', {
100-
timeout,
101-
})
102-
})
103-
10498
it('injects Git metadata into bundled applications', () => {
10599
execSync('node ./build-and-test-git-tags.js', {
106100
timeout,

integration-tests/esbuild/openfeature-app.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

integration-tests/webpack/build-and-test-openfeature.js

Lines changed: 0 additions & 151 deletions
This file was deleted.

integration-tests/webpack/index.spec.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ webpackVersions.forEach((version) => {
5858
execSync('node ./build-and-test-skip-external.js', { timeout })
5959
})
6060

61-
it('does not follow `@datadog/openfeature-node-server` into its optional peer chain', () => {
62-
execSync('node ./build-and-test-openfeature.js', { timeout })
63-
})
64-
6561
it('injects Git metadata into bundled applications', () => {
6662
execSync('node ./build-and-test-git-tags.js', { timeout })
6763
})

integration-tests/webpack/openfeature-app.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)