dd-trace 6.10.0 → 6.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/LICENSE-3rdparty.csv +5 -0
  2. package/README.md +0 -17
  3. package/index.d.ts +128 -6
  4. package/initialize.mjs +28 -17
  5. package/openfeature.js +2 -2
  6. package/package.json +27 -23
  7. package/packages/datadog-esbuild/index.js +0 -34
  8. package/packages/datadog-instrumentations/src/anthropic.js +210 -15
  9. package/packages/datadog-instrumentations/src/aws-sdk.js +9 -1
  10. package/packages/datadog-instrumentations/src/browser-bunyan.js +11 -0
  11. package/packages/datadog-instrumentations/src/bunyan.js +3 -16
  12. package/packages/datadog-instrumentations/src/cucumber.js +30 -15
  13. package/packages/datadog-instrumentations/src/cypress-config.js +182 -16
  14. package/packages/datadog-instrumentations/src/cypress-legacy-finalizers.js +30 -0
  15. package/packages/datadog-instrumentations/src/cypress.js +2 -0
  16. package/packages/datadog-instrumentations/src/fastify.js +2 -0
  17. package/packages/datadog-instrumentations/src/helpers/bunyan.js +22 -0
  18. package/packages/datadog-instrumentations/src/helpers/hooks.js +2 -1
  19. package/packages/datadog-instrumentations/src/helpers/pool-acquire.js +9 -4
  20. package/packages/datadog-instrumentations/src/helpers/register.js +10 -8
  21. package/packages/datadog-instrumentations/src/jest.js +25 -17
  22. package/packages/datadog-instrumentations/src/mariadb.js +278 -21
  23. package/packages/datadog-instrumentations/src/mocha/main.js +539 -55
  24. package/packages/datadog-instrumentations/src/mocha/utils.js +135 -19
  25. package/packages/datadog-instrumentations/src/playwright-reporter.js +247 -0
  26. package/packages/datadog-instrumentations/src/playwright.js +182 -35
  27. package/packages/datadog-instrumentations/src/router.js +2 -0
  28. package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +6 -8
  29. package/packages/datadog-instrumentations/src/vitest-main.js +11 -3
  30. package/packages/datadog-plugin-aws-sdk/src/base.js +1 -0
  31. package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +163 -44
  32. package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +2 -8
  33. package/packages/datadog-plugin-azure-functions/src/index.js +1 -1
  34. package/packages/datadog-plugin-browser-bunyan/src/index.js +9 -0
  35. package/packages/datadog-plugin-bunyan/src/index.js +5 -8
  36. package/packages/datadog-plugin-cucumber/src/index.js +11 -0
  37. package/packages/datadog-plugin-cypress/src/after-run.js +5 -1
  38. package/packages/datadog-plugin-cypress/src/after-spec.js +5 -1
  39. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +81 -29
  40. package/packages/datadog-plugin-cypress/src/finalization.js +76 -0
  41. package/packages/datadog-plugin-cypress/src/index.js +12 -6
  42. package/packages/datadog-plugin-cypress/src/plugin.js +16 -3
  43. package/packages/datadog-plugin-dd-trace-api/src/index.js +4 -0
  44. package/packages/datadog-plugin-electron/src/index.js +2 -0
  45. package/packages/datadog-plugin-fs/src/index.js +1 -1
  46. package/packages/datadog-plugin-jest/src/index.js +6 -0
  47. package/packages/datadog-plugin-mocha/src/index.js +56 -1
  48. package/packages/datadog-plugin-nats/src/index.js +1 -1
  49. package/packages/datadog-plugin-openai/src/tracing.js +41 -30
  50. package/packages/datadog-plugin-openai-agents/src/integration.js +1 -0
  51. package/packages/datadog-plugin-playwright/src/index.js +46 -13
  52. package/packages/datadog-plugin-vitest/src/index.js +6 -0
  53. package/packages/datadog-webpack/index.js +0 -11
  54. package/packages/dd-trace/index.js +0 -1
  55. package/packages/dd-trace/src/agent/info.js +6 -5
  56. package/packages/dd-trace/src/aiguard/client.js +100 -1
  57. package/packages/dd-trace/src/aiguard/errors.js +41 -0
  58. package/packages/dd-trace/src/aiguard/evaluation.js +357 -0
  59. package/packages/dd-trace/src/aiguard/integrations/anthropic.js +70 -0
  60. package/packages/dd-trace/src/aiguard/integrations/index.js +4 -0
  61. package/packages/dd-trace/src/aiguard/messages/anthropic.js +423 -0
  62. package/packages/dd-trace/src/aiguard/messages/openai.js +1 -24
  63. package/packages/dd-trace/src/aiguard/messages/utils.js +28 -0
  64. package/packages/dd-trace/src/aiguard/messages/vercel-ai.js +1 -11
  65. package/packages/dd-trace/src/aiguard/sdk.js +22 -278
  66. package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +9 -12
  67. package/packages/dd-trace/src/appsec/reporter.js +2 -0
  68. package/packages/dd-trace/src/appsec/telemetry/index.js +13 -0
  69. package/packages/dd-trace/src/appsec/telemetry/rasp.js +16 -0
  70. package/packages/dd-trace/src/appsec/telemetry/waf.js +24 -0
  71. package/packages/dd-trace/src/carrier.js +107 -48
  72. package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +1 -0
  73. package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +5 -5
  74. package/packages/dd-trace/src/ci-visibility/exporters/agent-proxy/index.js +29 -3
  75. package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +27 -9
  76. package/packages/dd-trace/src/ci-visibility/exporters/agentless/di-logs-writer.js +21 -5
  77. package/packages/dd-trace/src/ci-visibility/exporters/agentless/request-tracker.js +164 -0
  78. package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +26 -8
  79. package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +365 -32
  80. package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +6 -4
  81. package/packages/dd-trace/src/ci-visibility/exporters/request.js +201 -0
  82. package/packages/dd-trace/src/ci-visibility/exporters/test-worker/index.js +5 -3
  83. package/packages/dd-trace/src/ci-visibility/exporters/test-worker/writer.js +9 -5
  84. package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +7 -4
  85. package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +4 -2
  86. package/packages/dd-trace/src/ci-visibility/requests/rate-limit.js +39 -0
  87. package/packages/dd-trace/src/ci-visibility/requests/request.js +3 -6
  88. package/packages/dd-trace/src/ci-visibility/requests/upload-coverage-report.js +4 -2
  89. package/packages/dd-trace/src/ci-visibility/requests/upload-test-screenshot.js +10 -4
  90. package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +5 -5
  91. package/packages/dd-trace/src/config/generated-config-types.d.ts +4 -0
  92. package/packages/dd-trace/src/config/index.js +13 -2
  93. package/packages/dd-trace/src/config/major-overrides.js +7 -0
  94. package/packages/dd-trace/src/config/supported-configurations.json +14 -0
  95. package/packages/dd-trace/src/datastreams/index.js +2 -0
  96. package/packages/dd-trace/src/datastreams/manager.js +9 -2
  97. package/packages/dd-trace/src/datastreams/processor.js +15 -13
  98. package/packages/dd-trace/src/datastreams/size.js +5 -0
  99. package/packages/dd-trace/src/debugger/constants.js +1 -0
  100. package/packages/dd-trace/src/debugger/devtools_client/condition.js +1 -1
  101. package/packages/dd-trace/src/debugger/devtools_client/index.js +5 -11
  102. package/packages/dd-trace/src/debugger/index.js +4 -2
  103. package/packages/dd-trace/src/debugger/inspect-segment.js +154 -0
  104. package/packages/dd-trace/src/evp_proxy/constants.js +8 -0
  105. package/packages/dd-trace/src/evp_proxy/direct.js +64 -0
  106. package/packages/dd-trace/src/evp_proxy/discovery.js +133 -0
  107. package/packages/dd-trace/src/evp_proxy/path.js +22 -0
  108. package/packages/dd-trace/src/exporters/agent/writer.js +49 -9
  109. package/packages/dd-trace/src/exporters/common/buffering-exporter.js +6 -4
  110. package/packages/dd-trace/src/exporters/common/request.js +5 -2
  111. package/packages/dd-trace/src/exporters/common/writer.js +11 -6
  112. package/packages/dd-trace/src/llmobs/experiments/client.js +167 -5
  113. package/packages/dd-trace/src/llmobs/experiments/dataset.js +484 -92
  114. package/packages/dd-trace/src/llmobs/experiments/experiment.js +302 -29
  115. package/packages/dd-trace/src/llmobs/experiments/index.js +75 -64
  116. package/packages/dd-trace/src/llmobs/experiments/noop.js +135 -7
  117. package/packages/dd-trace/src/llmobs/experiments/result.js +1 -0
  118. package/packages/dd-trace/src/llmobs/experiments/util.js +101 -9
  119. package/packages/dd-trace/src/llmobs/plugins/ai/util.js +12 -3
  120. package/packages/dd-trace/src/llmobs/plugins/base.js +4 -2
  121. package/packages/dd-trace/src/noop/proxy.js +3 -4
  122. package/packages/dd-trace/src/openfeature/constants/constants.js +0 -18
  123. package/packages/dd-trace/src/openfeature/flagging_provider.js +18 -2
  124. package/packages/dd-trace/src/openfeature/index.js +7 -4
  125. package/packages/dd-trace/src/openfeature/remote_config.js +1 -1
  126. package/packages/dd-trace/src/openfeature/writers/base.js +153 -11
  127. package/packages/dd-trace/src/openfeature/writers/exposures.js +62 -14
  128. package/packages/dd-trace/src/openfeature/writers/util.js +97 -15
  129. package/packages/dd-trace/src/opentelemetry/context_manager.js +7 -7
  130. package/packages/dd-trace/src/opentelemetry/logs/batch_log_processor.js +2 -1
  131. package/packages/dd-trace/src/opentelemetry/logs/logger.js +67 -11
  132. package/packages/dd-trace/src/opentelemetry/logs/otlp_transformer.js +14 -3
  133. package/packages/dd-trace/src/opentelemetry/metrics/index.js +25 -12
  134. package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_exporter.js +2 -5
  135. package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_transformer.js +96 -43
  136. package/packages/dd-trace/src/opentracing/propagation/text_map.js +22 -13
  137. package/packages/dd-trace/src/opentracing/tracer.js +5 -2
  138. package/packages/dd-trace/src/otel-thread-ctx.js +387 -0
  139. package/packages/dd-trace/src/plugin_manager.js +3 -3
  140. package/packages/dd-trace/src/plugins/ci_plugin.js +6 -1
  141. package/packages/dd-trace/src/plugins/index.js +1 -0
  142. package/packages/dd-trace/src/plugins/util/jest.js +4 -3
  143. package/packages/dd-trace/src/plugins/util/test.js +9 -9
  144. package/packages/dd-trace/src/plugins/util/web.js +3 -0
  145. package/packages/dd-trace/src/profiling/profiler.js +1 -1
  146. package/packages/dd-trace/src/profiling/profilers/space.js +1 -3
  147. package/packages/dd-trace/src/profiling/profilers/wall.js +37 -90
  148. package/packages/dd-trace/src/profiling/webspan-utils.js +45 -0
  149. package/packages/dd-trace/src/proxy.js +38 -29
  150. package/packages/dd-trace/src/ritm.js +9 -2
  151. package/packages/dd-trace/src/serverless.js +37 -0
  152. package/packages/dd-trace/src/span_format.js +1 -0
  153. package/packages/dd-trace/src/span_stats.js +30 -3
  154. package/packages/dd-trace/src/storage-channels.js +86 -0
  155. package/packages/dd-trace/src/telemetry/metrics.js +62 -8
  156. package/packages/dd-trace/src/telemetry/send-data.js +1 -0
  157. package/packages/dd-trace/src/tracer.js +9 -2
  158. package/packages/dd-trace/src/tracer_metadata.js +14 -1
  159. package/packages/dd-trace/src/web-tags-cache.js +132 -0
  160. package/vendor/dist/@datadog/openfeature-node-server/LICENSE +201 -0
  161. package/vendor/dist/@datadog/openfeature-node-server/index.js +1 -0
  162. package/vendor/dist/@datadog/sketches-js/index.js +1 -1
  163. package/vendor/dist/https-proxy-agent/LICENSE +22 -0
  164. package/vendor/dist/https-proxy-agent/index.js +4 -0
  165. package/vendor/dist/protobufjs/index.js +1 -1
  166. package/vendor/dist/protobufjs/minimal/index.js +1 -1
  167. package/vendor/dist/proxy-from-env/LICENSE +20 -0
  168. package/vendor/dist/proxy-from-env/index.js +1 -0
  169. package/packages/datadog-instrumentations/src/helpers/optional-peer-bundler.js +0 -65
  170. package/packages/datadog-webpack/src/optional-peer-loader.js +0 -17
  171. package/packages/dd-trace/src/feature-registry.js +0 -29
  172. package/packages/dd-trace/src/openfeature/register.js +0 -35
  173. package/packages/dd-trace/src/openfeature/require-provider.js +0 -18
@@ -44,18 +44,21 @@
44
44
  "@oxc-project/types","https://github.com/oxc-project/oxc","['MIT']","['Boshen and oxc contributors']"
45
45
  "@tybys/wasm-util","https://github.com/toyobayashi/wasm-util","['MIT']","['toyobayashi']"
46
46
  "@types/estree","https://github.com/DefinitelyTyped/DefinitelyTyped","['MIT']","['DefinitelyTyped']"
47
+ "agent-base","https://github.com/TooTallNate/proxy-agents","['MIT']","['Nathan Rajlich']"
47
48
  "argparse","https://github.com/nodeca/argparse","['Python-2.0']","['nodeca']"
48
49
  "astring","https://github.com/davidbonnet/astring","['MIT']","['David Bonnet']"
49
50
  "cjs-module-lexer","https://github.com/nodejs/cjs-module-lexer","['MIT']","['Guy Bedford']"
50
51
  "crypto-randomuuid","npm:crypto-randomuuid","['MIT']","['Stephen Belanger']"
51
52
  "dc-polyfill","https://github.com/DataDog/dc-polyfill","['MIT']","['Thomas Hunter II']"
52
53
  "dd-trace","https://github.com/DataDog/dd-trace-js","['(Apache-2.0 OR BSD-3-Clause)']","['Datadog Inc. <info@datadoghq.com>']"
54
+ "debug","https://github.com/debug-js/debug","['MIT']","['Josh Junon']"
53
55
  "detect-newline","https://github.com/sindresorhus/detect-newline","['MIT']","['Sindre Sorhus']"
54
56
  "es-module-lexer","https://github.com/guybedford/es-module-lexer","['MIT']","['Guy Bedford']"
55
57
  "escape-string-regexp","https://github.com/sindresorhus/escape-string-regexp","['MIT']","['Sindre Sorhus']"
56
58
  "esquery","https://github.com/estools/esquery","['BSD-3-Clause']","['Joel Feenstra']"
57
59
  "estraverse","https://github.com/estools/estraverse","['BSD-2-Clause']","['estools']"
58
60
  "fast-fifo","https://github.com/mafintosh/fast-fifo","['MIT']","['Mathias Buus']"
61
+ "https-proxy-agent","https://github.com/TooTallNate/proxy-agents","['MIT']","['Nathan Rajlich']"
59
62
  "import-in-the-middle","https://github.com/nodejs/import-in-the-middle","['Apache-2.0']","['Bryan English']"
60
63
  "istanbul-lib-coverage","https://github.com/istanbuljs/istanbuljs","['BSD-3-Clause']","['Krishnan Anantheswaran']"
61
64
  "jest-docblock","https://github.com/jestjs/jest","['MIT']","['jestjs']"
@@ -68,6 +71,7 @@
68
71
  "lru-cache","https://github.com/isaacs/node-lru-cache","['ISC']","['Isaac Z. Schlueter']"
69
72
  "meriyah","https://github.com/meriyah/meriyah","['ISC']","['Kenny F.']"
70
73
  "module-details-from-path","https://github.com/watson/module-details-from-path","['MIT']","['Thomas Watson']"
74
+ "ms","https://github.com/vercel/ms","['MIT']","['vercel']"
71
75
  "mutexify","https://github.com/mafintosh/mutexify","['MIT']","['Mathias Buus']"
72
76
  "node-addon-api","https://github.com/nodejs/node-addon-api","['MIT']","['nodejs']"
73
77
  "node-gyp-build","https://github.com/prebuild/node-gyp-build","['MIT']","['Mathias Buus']"
@@ -75,6 +79,7 @@
75
79
  "oxc-parser","https://github.com/oxc-project/oxc","['MIT']","['Boshen and oxc contributors']"
76
80
  "pprof-format","https://github.com/DataDog/pprof-format","['MIT']","['Datadog Inc.']"
77
81
  "protobufjs","https://github.com/protobufjs/protobuf.js","['BSD-3-Clause']","['Daniel Wirtz']"
82
+ "proxy-from-env","https://github.com/Rob--W/proxy-from-env","['MIT']","['Rob Wu']"
78
83
  "queue-tick","https://github.com/mafintosh/queue-tick","['MIT']","['Mathias Buus']"
79
84
  "retry","https://github.com/tim-kos/node-retry","['MIT']","['Tim Koschützki']"
80
85
  "rfdc","https://github.com/davidmarkclements/rfdc","['MIT']","['David Mark Clements']"
package/README.md CHANGED
@@ -93,23 +93,6 @@ Regardless of where you open the issue, someone at Datadog will try to help.
93
93
 
94
94
  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.
95
95
 
96
- When using the experimental OpenFeature provider, file-traced deployments can force the optional provider and
97
- its dependencies into the output with a side-effect import before accessing `tracer.openfeature`:
98
-
99
- CommonJS:
100
-
101
- ```js
102
- require('dd-trace/openfeature')
103
- ```
104
-
105
- ES modules:
106
-
107
- ```js
108
- import 'dd-trace/openfeature.js'
109
- ```
110
-
111
- This is a fallback for build tools that do not recognize the provider's optional-require wrapper.
112
-
113
96
 
114
97
  ## Security Vulnerabilities
115
98
 
package/index.d.ts CHANGED
@@ -243,6 +243,7 @@ interface Plugins {
243
243
  "azure-functions": tracer.plugins.azure_functions;
244
244
  "azure-service-bus": tracer.plugins.azure_service_bus;
245
245
  "azure-durable-functions": tracer.plugins.azure_durable_functions
246
+ "browser-bunyan": tracer.plugins.browser_bunyan;
246
247
  "bullmq": tracer.plugins.bullmq;
247
248
  "bunyan": tracer.plugins.bunyan;
248
249
  "cassandra-driver": tracer.plugins.cassandra_driver;
@@ -1940,6 +1941,18 @@ declare namespace tracer {
1940
1941
  /** @hidden */
1941
1942
  interface Instrumentation extends Integration, Analyzable {}
1942
1943
 
1944
+ /** @hidden */
1945
+ interface LLMObsIntegration extends Integration {
1946
+ /**
1947
+ * Whether to capture LLM Observability spans for this integration. When set to `false`,
1948
+ * the integration keeps emitting APM spans and propagating trace context, but no LLM
1949
+ * Observability spans are produced. Useful when another integration already captures the
1950
+ * same operation and the payloads would otherwise be stored twice.
1951
+ * @default true
1952
+ */
1953
+ llmobs?: boolean;
1954
+ }
1955
+
1943
1956
  /** @hidden */
1944
1957
  interface DatabaseInstrumentation extends Instrumentation {
1945
1958
  /**
@@ -2333,11 +2346,13 @@ declare namespace tracer {
2333
2346
  interface azure_durable_functions extends Integration {}
2334
2347
 
2335
2348
  /**
2336
- * This plugin patches the [bunyan](https://github.com/trentm/node-bunyan)
2349
+ * This plugin patches the [browser-bunyan](https://github.com/philmander/browser-bunyan)
2337
2350
  * to automatically inject trace identifiers in log records when the
2338
2351
  * [logInjection](interfaces/traceroptions.html#logInjection) option is enabled
2339
2352
  * on the tracer.
2340
2353
  */
2354
+ interface browser_bunyan extends Integration {}
2355
+
2341
2356
  /**
2342
2357
  * This plugin automatically instruments the
2343
2358
  * [bullmq](https://github.com/npmjs/package/bullmq) message queue library.
@@ -2358,6 +2373,12 @@ declare namespace tracer {
2358
2373
  producerFilter?: (job: { name?: string; data?: unknown; opts?: unknown; queueName?: string }) => boolean;
2359
2374
  }
2360
2375
 
2376
+ /**
2377
+ * This plugin patches the [bunyan](https://github.com/trentm/node-bunyan)
2378
+ * to automatically inject trace identifiers in log records when the
2379
+ * [logInjection](interfaces/traceroptions.html#logInjection) option is enabled
2380
+ * on the tracer.
2381
+ */
2361
2382
  interface bunyan extends Integration {}
2362
2383
 
2363
2384
  /**
@@ -2804,7 +2825,7 @@ declare namespace tracer {
2804
2825
  * This plugin automatically instruments the
2805
2826
  * [langchain](https://js.langchain.com/) module
2806
2827
  */
2807
- interface langchain extends Instrumentation {}
2828
+ interface langchain extends Instrumentation, LLMObsIntegration {}
2808
2829
 
2809
2830
  /**
2810
2831
  * This plugin automatically instruments the
@@ -2846,7 +2867,7 @@ declare namespace tracer {
2846
2867
  * This plugin automatically instruments the
2847
2868
  * [modelcontextprotocol-sdk](https://github.com/npmjs/package/@modelcontextprotocol/sdk) library.
2848
2869
  */
2849
- interface modelcontextprotocol_sdk extends Instrumentation {}
2870
+ interface modelcontextprotocol_sdk extends Instrumentation, LLMObsIntegration {}
2850
2871
 
2851
2872
  /**
2852
2873
  * This plugin automatically instruments the
@@ -3783,7 +3804,8 @@ declare namespace tracer {
3783
3804
  id?: string,
3784
3805
  inputData: JSONType,
3785
3806
  expectedOutput?: JSONType,
3786
- metadata?: Record<string, JSONType>
3807
+ metadata?: Record<string, JSONType>,
3808
+ tags?: string[]
3787
3809
  }>
3788
3810
  }
3789
3811
 
@@ -3816,6 +3838,8 @@ declare namespace tracer {
3816
3838
  expectedRecordCount?: number
3817
3839
  /** Maximum total time to wait, in ms. Default 30000. */
3818
3840
  maxWaitMs?: number
3841
+ /** Filter records by these tags. */
3842
+ tags?: string[]
3819
3843
  }
3820
3844
 
3821
3845
  interface ExperimentResultRow {
@@ -3852,6 +3876,79 @@ declare namespace tracer {
3852
3876
  url: string
3853
3877
  }
3854
3878
 
3879
+ type ExternalExperimentTimestamp = number | string | Date
3880
+
3881
+ interface StartExperimentDatasetOptions {
3882
+ /** Existing dataset id. When omitted, a placeholder dataset is created. */
3883
+ id?: string
3884
+ /** Dataset version to associate with the experiment. */
3885
+ version?: number
3886
+ /** Placeholder dataset name. Defaults to `<experiment name> dataset`. */
3887
+ name?: string
3888
+ /** Placeholder dataset description. */
3889
+ description?: string
3890
+ }
3891
+
3892
+ interface StartExperimentOptions {
3893
+ name: string
3894
+ description?: string
3895
+ /** Override the configured project name for this external experiment. */
3896
+ projectName?: string
3897
+ dataset?: StartExperimentDatasetOptions
3898
+ config?: Record<string, JSONType>
3899
+ metadata?: Record<string, JSONType>
3900
+ tags?: Record<string, string>
3901
+ }
3902
+
3903
+ interface ExternalExperimentSpanInput {
3904
+ name?: string
3905
+ input?: JSONType
3906
+ output?: JSONType
3907
+ expectedOutput?: JSONType
3908
+ metadata?: Record<string, JSONType>
3909
+ tags?: Record<string, string>
3910
+ startedAt?: ExternalExperimentTimestamp
3911
+ completedAt?: ExternalExperimentTimestamp
3912
+ durationMs?: number
3913
+ error?: string | Error | { type?: string, name?: string, message?: string, stack?: string }
3914
+ datasetRecordId?: string
3915
+ runId?: string
3916
+ runIteration?: number
3917
+ }
3918
+
3919
+ interface ExternalExperimentSpan {
3920
+ experimentId: string
3921
+ spanId: string
3922
+ traceId: string
3923
+ url: string | null
3924
+ }
3925
+
3926
+ interface ExternalExperimentMetric {
3927
+ label: string
3928
+ value?: JSONType
3929
+ error?: string | Error
3930
+ timestamp?: ExternalExperimentTimestamp
3931
+ tags?: Record<string, string>
3932
+ source?: string
3933
+ }
3934
+
3935
+ interface ExternalExperimentCloseOptions {
3936
+ status?: string
3937
+ error?: string | Error
3938
+ }
3939
+
3940
+ interface ExternalExperiment {
3941
+ experimentId (): string
3942
+ name (): string
3943
+ url (): string | null
3944
+ submitSpan (input?: ExternalExperimentSpanInput): Promise<ExternalExperimentSpan>
3945
+ submitEvaluationMetrics (
3946
+ span: { experimentId?: string, spanId: string, traceId: string },
3947
+ metrics: ExternalExperimentMetric[]
3948
+ ): Promise<void>
3949
+ close (options?: ExternalExperimentCloseOptions): Promise<void>
3950
+ }
3951
+
3855
3952
  interface DatasetPushResult {
3856
3953
  /** Number of records from this push that were confirmed with a record id. */
3857
3954
  pushedCount: number
@@ -3860,10 +3957,30 @@ declare namespace tracer {
3860
3957
  }
3861
3958
 
3862
3959
  interface Dataset {
3863
- addRecord (input: JSONType, expectedOutput?: JSONType, metadata?: Record<string, JSONType>): Dataset
3960
+ addRecord (
3961
+ input: JSONType,
3962
+ expectedOutput?: JSONType,
3963
+ metadata?: Record<string, JSONType>,
3964
+ tags?: string[]
3965
+ ): Dataset
3966
+ /** Update fields on an existing dataset record. */
3967
+ update (index: number, fields: {
3968
+ input?: JSONType
3969
+ expectedOutput?: JSONType
3970
+ metadata?: Record<string, JSONType>
3971
+ }): Dataset
3972
+ /** Delete an existing dataset record. */
3973
+ delete (index: number): Dataset
3974
+ /** Add tags to a dataset record. */
3975
+ addTags (index: number, tags: string[]): Dataset
3976
+ /** Remove tags from a dataset record. */
3977
+ removeTags (index: number, tags: string[]): Dataset
3978
+ /** Replace all tags on a dataset record. */
3979
+ replaceTags (index: number, tags: string[]): Dataset
3864
3980
  /** Creates the dataset remotely if needed and pushes any unpushed records. */
3865
3981
  push (): Promise<DatasetPushResult>
3866
3982
  name (): string
3983
+ description (): string
3867
3984
  id (): string | null
3868
3985
  projectId (): string | null
3869
3986
  version (): number | null
@@ -3872,8 +3989,11 @@ declare namespace tracer {
3872
3989
  id: string | null,
3873
3990
  input: JSONType,
3874
3991
  expectedOutput: JSONType,
3875
- metadata: Record<string, JSONType>
3992
+ metadata: Record<string, JSONType>,
3993
+ tags: string[]
3876
3994
  }>
3995
+ /** Return the tags used to filter this dataset. */
3996
+ filterTags (): string[]
3877
3997
  /** Dashboard URL for the dataset, or null until pushed. */
3878
3998
  url (): string | null
3879
3999
  }
@@ -3893,6 +4013,8 @@ declare namespace tracer {
3893
4013
  pullDataset (name: string, options?: PullDatasetOptions): Promise<Dataset>
3894
4014
  /** Build an experiment to run over a dataset. */
3895
4015
  experiment (options: ExperimentOptions): Experiment
4016
+ /** Start an externally-driven experiment. */
4017
+ startExperiment (options: StartExperimentOptions): Promise<ExternalExperiment>
3896
4018
  }
3897
4019
 
3898
4020
  interface LLMObservabilitySpan {
package/initialize.mjs CHANGED
@@ -16,19 +16,28 @@ import * as Module from 'module'
16
16
  import { types } from 'util'
17
17
  import { isMainThread } from 'worker_threads'
18
18
 
19
- // This file must support Node.js 12.0.0 syntax
19
+ // This file must support Node.js 14.13.1 syntax
20
20
 
21
- import {
22
- iitmExclusionRegExp,
23
- initialize as hookInitialize,
24
- load as hookLoad,
25
- resolve as hookResolve,
26
- } from './loader-hook.mjs?initialize'
21
+ const NODE_VERSION = process.versions.node
22
+
23
+ const brokenLoaders = NODE_VERSION.startsWith('18.0')
24
+ const isNode20LoaderWorker = !isMainThread && NODE_VERSION.startsWith('20.0')
25
+ const useDefaultLoader = brokenLoaders || isNode20LoaderWorker
26
+ // Avoid CommonJS in the loader worker on Node 20.0: https://github.com/nodejs/node/issues/47566
27
+ const loaderHook = useDefaultLoader ? undefined : await import('./loader-hook.mjs?initialize')
27
28
 
28
29
  let hasInsertedInit = false
29
30
  const initJsUrl = new URL('init.js', import.meta.url).href
30
31
  // `--loader` only reliably influences ESM entrypoints; for CJS apps use `--import`/`--require`.
31
32
 
33
+ // `globalPreload` is deprecated in favor of the `initialize` hook, but `initialize` only exists
34
+ // from Node 20.6 on, so it is the only way to run code in the application realm on Node 20.0.
35
+ export const globalPreload = isNode20LoaderWorker
36
+ ? () => `if (getBuiltin('module').createRequire(${JSON.stringify(import.meta.url)})('./init.js')) {
37
+ process.emitWarning('dd-trace cannot instrument ES modules on Node.js 20.0.0. Upgrade to Node.js 20.1.0 or newer.')
38
+ }`
39
+ : undefined
40
+
32
41
  /**
33
42
  * @param {{ source?: string|Buffer|Uint8Array, format?: string }} result
34
43
  * @param {unknown} _url_
@@ -63,26 +72,28 @@ function insertInit (result, _url_, context) {
63
72
  return result
64
73
  }
65
74
 
66
- const [NODE_MAJOR, NODE_MINOR] = process.versions.node.split('.').map(Number)
67
-
68
- const brokenLoaders = NODE_MAJOR === 18 && NODE_MINOR === 0
69
-
70
75
  // Node calls `initialize` only through `module.register`, never for `--loader`; without it
71
76
  // import-in-the-middle keeps its default matcher and proxies every application module. Loaders
72
77
  // before Node 18.19 share the application thread, where `loader-hook.mjs` builds no matcher.
73
- let needsHookInitialize = !isMainThread && !brokenLoaders
78
+ let needsHookInitialize = !isMainThread && !useDefaultLoader
74
79
 
75
- export async function load (url, context, nextLoad) {
80
+ /**
81
+ * @param {string} url
82
+ * @param {import('node:module').LoadHookContext & { isMain?: boolean }} context
83
+ * @param {Parameters<import('node:module').LoadHook>[2]} nextLoad
84
+ */
85
+ async function loadWithInit (url, context, nextLoad) {
76
86
  if (needsHookInitialize) {
77
87
  needsHookInitialize = false
78
- hookInitialize()
88
+ loaderHook.initialize()
79
89
  }
80
90
 
81
- const loadHook = (brokenLoaders || iitmExclusionRegExp.test(url)) ? nextLoad : hookLoad
82
- return insertInit(await loadHook(url, context, nextLoad), url, context)
91
+ const load = (useDefaultLoader || loaderHook.iitmExclusionRegExp.test(url)) ? nextLoad : loaderHook.load
92
+ return insertInit(await load(url, context, nextLoad), url, context)
83
93
  }
84
94
 
85
- export const resolve = brokenLoaders ? undefined : hookResolve
95
+ export const load = isNode20LoaderWorker ? undefined : loadWithInit
96
+ export const resolve = useDefaultLoader ? undefined : loaderHook.resolve
86
97
 
87
98
  if (isMainThread) {
88
99
  const require = Module.createRequire(import.meta.url)
package/openfeature.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use strict'
2
2
 
3
- // Static fallback for file tracers that do not recognize the optional-peer wrapper.
4
- require('@datadog/openfeature-node-server')
3
+ // Static fallback for file tracers that do not recognize the vendored provider's lazy require.
4
+ require('./vendor/dist/@datadog/openfeature-node-server')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dd-trace",
3
- "version": "6.10.0",
3
+ "version": "6.12.0",
4
4
  "description": "Datadog APM tracing client for JavaScript",
5
5
  "main": "index.js",
6
6
  "typings": "index.d.ts",
@@ -49,7 +49,7 @@
49
49
  "test:esbuild:ci": "node scripts/c8-ci.js test:esbuild",
50
50
  "test:webpack": "mocha \"packages/datadog-webpack/test/**/*.spec.js\"",
51
51
  "test:webpack:ci": "node scripts/c8-ci.js test:webpack",
52
- "test:instrumentations": "mocha \"packages/datadog-instrumentations/test/@(${PLUGINS}).spec.js\"",
52
+ "test:instrumentations": "mocha --fail-zero \"packages/datadog-instrumentations/test/@(${PLUGINS}).spec.js\"",
53
53
  "test:instrumentations:ci": "yarn services && node scripts/c8-ci.js test:instrumentations",
54
54
  "test:instrumentations:misc": "mocha \"packages/datadog-instrumentations/test/*/**/*.spec.{js,mjs}\"",
55
55
  "test:instrumentations:misc:ci": "node scripts/c8-ci.js test:instrumentations:misc",
@@ -57,20 +57,23 @@
57
57
  "test:core:ci": "node scripts/c8-ci.js test:core",
58
58
  "test:code-origin": "mocha \"packages/datadog-code-origin/test/**/*.spec.js\"",
59
59
  "test:code-origin:ci": "node scripts/c8-ci.js test:code-origin",
60
+ "test:evp_proxy": "mocha \"packages/dd-trace/test/evp_proxy/**/*.spec.js\"",
60
61
  "test:lambda": "mocha \"packages/dd-trace/test/lambda/**/*.spec.js\"",
61
62
  "test:lambda:ci": "node scripts/c8-ci.js test:lambda",
62
63
  "test:llmobs:sdk": "mocha --exclude \"packages/dd-trace/test/llmobs/plugins/**/*.spec.js\" \"packages/dd-trace/test/llmobs/**/*.spec.js\"",
63
64
  "test:llmobs:sdk:ci": "node scripts/c8-ci.js test:llmobs:sdk",
64
65
  "test:llmobs:plugins": "mocha \"packages/dd-trace/test/llmobs/plugins/@(${PLUGINS})/*.spec.js\"",
65
66
  "test:llmobs:plugins:ci": "yarn services && node scripts/c8-ci.js test:llmobs:plugins",
66
- "test:openfeature": "mocha \"packages/dd-trace/test/openfeature/**/*.spec.js\"",
67
+ "test:openfeature": "mocha \"packages/dd-trace/test/evp_proxy/**/*.spec.js\" \"packages/dd-trace/test/openfeature/**/*.spec.js\"",
67
68
  "test:openfeature:ci": "node scripts/c8-ci.js test:openfeature",
68
- "test:plugins": "node --expose-gc ./node_modules/mocha/bin/mocha.js \"packages/datadog-plugin-@(${PLUGINS})/test/**/${SPEC:-*}*.spec.js\"",
69
+ "test:plugins": "node --expose-gc ./node_modules/mocha/bin/mocha.js --fail-zero \"packages/datadog-plugin-@(${PLUGINS})/test/**/${SPEC:-*}*.spec.js\"",
69
70
  "test:plugins:ci": "yarn services && node scripts/c8-ci.js test:plugins",
70
71
  "test:plugins:ci:flaky": "yarn services && node scripts/c8-ci.js test:plugins --bail --retries 2",
71
72
  "test:plugins:upstream": "node ./packages/dd-trace/test/plugins/suite.js",
72
73
  "test:profiler": "node scripts/mocha-parallel-files.js --expose-gc --timeout 30000 -- \"packages/dd-trace/test/profiling/**/*.spec.js\"",
73
74
  "test:profiler:ci": "node scripts/c8-ci.js test:profiler",
75
+ "test:otel-thread-ctx": "mocha --timeout 60000 packages/dd-trace/test/otel-thread-ctx.spec.js",
76
+ "test:docker:otel-thread-ctx": "./scripts/docker/run-otel-thread-ctx-spec.sh",
74
77
  "test:integration": "mocha --timeout 60000 \"integration-tests/*.spec.js\"",
75
78
  "test:integration:coverage": "node ./integration-tests/coverage/run-suite.js --timeout 60000 \"integration-tests/*.spec.js\"",
76
79
  "test:integration:aiguard": "mocha --timeout 60000 \"integration-tests/aiguard/*.spec.js\"",
@@ -112,7 +115,7 @@
112
115
  "test:integration:plugins:coverage": "yarn services && node ./integration-tests/coverage/run-suite.js \"packages/datadog-plugin-@(${PLUGINS})/test/integration-test/**/${SPEC:-*}*.spec.js\"",
113
116
  "test:unit:plugins": "mocha \"packages/datadog-instrumentations/test/@(${PLUGINS}).spec.js\" \"packages/datadog-plugin-@(${PLUGINS})/test/**/*.spec.js\" --exclude \"packages/datadog-plugin-@(${PLUGINS})/test/integration-test/**/*.spec.js\"",
114
117
  "test:release": "mocha \"scripts/release/**/*.spec.js\"",
115
- "test:scripts": "mocha \"scripts/helpers/**/*.spec.js\" \"scripts/*.spec.mjs\"",
118
+ "test:scripts": "mocha \"benchmark/sirun/*.spec.js\" \"scripts/helpers/**/*.spec.js\" \"scripts/*.spec.mjs\"",
116
119
  "test:shimmer": "mocha \"packages/datadog-shimmer/test/**/*.spec.js\"",
117
120
  "test:shimmer:ci": "node scripts/c8-ci.js test:shimmer",
118
121
  "verify:workflow-job-names": "node scripts/verify-workflow-job-names.js",
@@ -180,13 +183,12 @@
180
183
  "opentracing": ">=0.14.7"
181
184
  },
182
185
  "optionalDependencies": {
183
- "@datadog/libdatadog": "0.9.4",
186
+ "@datadog/libdatadog": "0.12.1",
184
187
  "@datadog/native-appsec": "11.0.1",
185
188
  "@datadog/native-iast-taint-tracking": "4.2.0",
186
189
  "@datadog/native-metrics": "3.1.2",
187
- "@datadog/openfeature-node-server": "2.0.2",
188
- "@datadog/pprof": "5.17.0",
189
- "@datadog/wasm-js-rewriter": "5.0.1",
190
+ "@datadog/pprof": "5.18.1",
191
+ "@datadog/wasm-js-rewriter": "5.0.3",
190
192
  "@opentelemetry/api": ">=1.0.0 <1.10.0",
191
193
  "@opentelemetry/api-logs": "<1.0.0",
192
194
  "oxc-parser": "^0.132.0"
@@ -195,56 +197,58 @@
195
197
  "@actions/core": "^3.0.1",
196
198
  "@actions/github": "^9.1.1",
197
199
  "@babel/helpers": "^8.0.0",
198
- "@eslint/eslintrc": "^3.3.5",
200
+ "@eslint/eslintrc": "^3.3.6",
199
201
  "@eslint/js": "^10.0.1",
202
+ "@eslint/plugin-kit": "^0.7.2",
203
+ "@datadog/openfeature-node-server": "2.1.0",
200
204
  "@msgpack/msgpack": "^3.1.3",
201
- "@openfeature/core": "^1.11.0",
202
- "@openfeature/server-sdk": "~1.22.0",
205
+ "@openfeature/core": "^1.12.0",
206
+ "@openfeature/server-sdk": "~1.23.0",
203
207
  "@stylistic/eslint-plugin": "^5.10.0",
204
208
  "@types/mocha": "^10.0.10",
205
209
  "@types/node": "^18.19.106",
206
210
  "@types/sinon": "^22.0.0",
207
211
  "@vercel/nft": "^1.10.2",
208
212
  "@yarnpkg/lockfile": "^1.1.0",
209
- "axios": "^1.18.1",
213
+ "axios": "^1.19.0",
210
214
  "benchmark": "^2.1.4",
211
215
  "body-parser": "^2.3.0",
212
216
  "bun": "1.3.14",
213
217
  "c8": "^12.0.0",
214
218
  "codeowners-audit": "^2.9.0",
215
- "eslint": "^10.5.0",
216
- "eslint-plugin-cypress": "^6.4.2",
219
+ "eslint": "^10.8.1",
220
+ "eslint-plugin-cypress": "^7.0.0",
217
221
  "eslint-plugin-import-x": "^4.16.2",
218
- "eslint-plugin-jsdoc": "^63.0.12",
222
+ "eslint-plugin-jsdoc": "^64.2.0",
219
223
  "eslint-plugin-mocha": "^11.3.0",
220
- "eslint-plugin-n": "^18.2.1",
224
+ "eslint-plugin-n": "^18.3.0",
221
225
  "eslint-plugin-promise": "^7.3.0",
222
226
  "eslint-plugin-sonarjs": "^4.2.0",
223
227
  "eslint-plugin-unicorn": "^73.0.0",
224
228
  "express": "^5.1.0",
225
229
  "glob": "^10.4.5",
226
- "globals": "^17.7.0",
230
+ "globals": "^17.11.0",
227
231
  "graphql": "*",
228
232
  "husky": "^9.1.7",
229
233
  "istanbul-lib-report": "^3.0.0",
230
234
  "istanbul-reports": "^3.0.2",
231
235
  "jsonc-parser": "^3.3.1",
232
236
  "jszip": "^3.10.1",
233
- "minimatch": "^10.2.5",
234
- "mocha": "^11.7.6",
237
+ "minimatch": "^10.2.6",
238
+ "mocha": "^11.8.0",
235
239
  "mocha-junit-reporter": "^2.2.1",
236
240
  "mocha-multi-reporters": "^1.5.1",
237
241
  "multer": "^2.2.0",
238
- "nock": "^14.0.16",
242
+ "nock": "^14.0.17",
239
243
  "node-preload": "^0.2.1",
240
244
  "nyc": "^18.0.0",
241
245
  "octokit": "^5.0.3",
242
- "p-limit": "^7.2.0",
246
+ "p-limit": "^7.3.1",
243
247
  "proxyquire": "^2.1.3",
244
248
  "retry": "^0.13.1",
245
249
  "semifies": "^1.0.0",
246
250
  "semver": "^7.8.5",
247
- "sinon": "^22.0.0",
251
+ "sinon": "^22.1.0",
248
252
  "source-map-support": "^0.5.21",
249
253
  "test-exclude": "^8.0.0",
250
254
  "tiktoken": "^1.0.21",
@@ -8,11 +8,6 @@ const { pathToFileURL, fileURLToPath } = require('node:url')
8
8
  const instrumentations = require('../datadog-instrumentations/src/helpers/instrumentations')
9
9
  const extractPackageAndModulePath = require('../datadog-instrumentations/src/helpers/extract-package-and-module-path')
10
10
  const hooks = require('../datadog-instrumentations/src/helpers/hooks')
11
- const {
12
- OPTIONAL_PEER_FILTER,
13
- matchesOptionalPeerFile,
14
- rewriteOptionalPeerLoads,
15
- } = require('../datadog-instrumentations/src/helpers/optional-peer-bundler')
16
11
  const { processModule, isESMFile } = require('./src/utils')
17
12
  const log = require('./src/log')
18
13
 
@@ -133,19 +128,6 @@ module.exports.setup = function (build) {
133
128
  ${build.initialOptions.banner.js}`
134
129
  }
135
130
 
136
- // Keep the build from failing on the optional `@openfeature/core` peer of
137
- // `@openfeature/server-sdk` when it is not installed (#8635). esbuild follows the chain
138
- // whenever `@openfeature/server-sdk` is reachable -- the app importing it directly, or the
139
- // bundled provider when the optional peer is present -- so mark `@openfeature/core` external
140
- // when it is absent rather than erroring at bundle time.
141
- try {
142
- // eslint-disable-next-line n/no-unpublished-require
143
- require.resolve('@openfeature/core')
144
- } catch {
145
- build.initialOptions.external ??= []
146
- build.initialOptions.external.push('@openfeature/core')
147
- }
148
-
149
131
  const esmBuild = isESMBuild(build)
150
132
  if (
151
133
  esmBuild &&
@@ -182,22 +164,6 @@ ${build.initialOptions.banner.js}`
182
164
  log.warn('No git metadata available - skipping injection')
183
165
  }
184
166
 
185
- // Rewrite optional-peer loads so installed peers get bundled and survive the bundle being
186
- // relocated without them on disk (#8980). Registered before the generic onLoad so it wins for
187
- // these files. Absent peers stay opaque, so a build that does not opt into the feature does not
188
- // follow their dependency chain (#8635).
189
- build.onLoad({ filter: OPTIONAL_PEER_FILTER }, args => {
190
- const normalizedPath = args.path.replaceAll('\\', '/')
191
- if (!matchesOptionalPeerFile(normalizedPath)) return
192
-
193
- log.debug('INLINE: optional-peer loader applied to %s', normalizedPath)
194
- return {
195
- contents: rewriteOptionalPeerLoads(fs.readFileSync(args.path, 'utf8'), path.dirname(args.path)),
196
- loader: 'js',
197
- resolveDir: path.dirname(args.path),
198
- }
199
- })
200
-
201
167
  // first time is intercepted, proxy should be created, next time the original should be loaded
202
168
  const interceptedESMModules = new Set()
203
169