dd-trace 5.121.0 → 5.123.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;
@@ -2052,6 +2053,18 @@ declare namespace tracer {
2052
2053
  /** @hidden */
2053
2054
  interface Instrumentation extends Integration, Analyzable {}
2054
2055
 
2056
+ /** @hidden */
2057
+ interface LLMObsIntegration extends Integration {
2058
+ /**
2059
+ * Whether to capture LLM Observability spans for this integration. When set to `false`,
2060
+ * the integration keeps emitting APM spans and propagating trace context, but no LLM
2061
+ * Observability spans are produced. Useful when another integration already captures the
2062
+ * same operation and the payloads would otherwise be stored twice.
2063
+ * @default true
2064
+ */
2065
+ llmobs?: boolean;
2066
+ }
2067
+
2055
2068
  /** @hidden */
2056
2069
  interface DatabaseInstrumentation extends Instrumentation {
2057
2070
  /**
@@ -2461,11 +2474,13 @@ declare namespace tracer {
2461
2474
  interface azure_durable_functions extends Integration {}
2462
2475
 
2463
2476
  /**
2464
- * This plugin patches the [bunyan](https://github.com/trentm/node-bunyan)
2477
+ * This plugin patches the [browser-bunyan](https://github.com/philmander/browser-bunyan)
2465
2478
  * to automatically inject trace identifiers in log records when the
2466
2479
  * [logInjection](interfaces/traceroptions.html#logInjection) option is enabled
2467
2480
  * on the tracer.
2468
2481
  */
2482
+ interface browser_bunyan extends Integration {}
2483
+
2469
2484
  /**
2470
2485
  * This plugin automatically instruments the
2471
2486
  * [bullmq](https://github.com/npmjs/package/bullmq) message queue library.
@@ -2486,6 +2501,12 @@ declare namespace tracer {
2486
2501
  producerFilter?: (job: { name?: string; data?: unknown; opts?: unknown; queueName?: string }) => boolean;
2487
2502
  }
2488
2503
 
2504
+ /**
2505
+ * This plugin patches the [bunyan](https://github.com/trentm/node-bunyan)
2506
+ * to automatically inject trace identifiers in log records when the
2507
+ * [logInjection](interfaces/traceroptions.html#logInjection) option is enabled
2508
+ * on the tracer.
2509
+ */
2489
2510
  interface bunyan extends Integration {}
2490
2511
 
2491
2512
  /**
@@ -2974,7 +2995,7 @@ declare namespace tracer {
2974
2995
  * This plugin automatically instruments the
2975
2996
  * [langchain](https://js.langchain.com/) module
2976
2997
  */
2977
- interface langchain extends Instrumentation {}
2998
+ interface langchain extends Instrumentation, LLMObsIntegration {}
2978
2999
 
2979
3000
  /**
2980
3001
  * This plugin automatically instruments the
@@ -3016,7 +3037,7 @@ declare namespace tracer {
3016
3037
  * This plugin automatically instruments the
3017
3038
  * [modelcontextprotocol-sdk](https://github.com/npmjs/package/@modelcontextprotocol/sdk) library.
3018
3039
  */
3019
- interface modelcontextprotocol_sdk extends Instrumentation {}
3040
+ interface modelcontextprotocol_sdk extends Instrumentation, LLMObsIntegration {}
3020
3041
 
3021
3042
  /**
3022
3043
  * This plugin automatically instruments the
@@ -3980,7 +4001,8 @@ declare namespace tracer {
3980
4001
  id?: string,
3981
4002
  inputData: JSONType,
3982
4003
  expectedOutput?: JSONType,
3983
- metadata?: Record<string, JSONType>
4004
+ metadata?: Record<string, JSONType>,
4005
+ tags?: string[]
3984
4006
  }>
3985
4007
  }
3986
4008
 
@@ -4013,6 +4035,8 @@ declare namespace tracer {
4013
4035
  expectedRecordCount?: number
4014
4036
  /** Maximum total time to wait, in ms. Default 30000. */
4015
4037
  maxWaitMs?: number
4038
+ /** Filter records by these tags. */
4039
+ tags?: string[]
4016
4040
  }
4017
4041
 
4018
4042
  interface ExperimentResultRow {
@@ -4049,6 +4073,79 @@ declare namespace tracer {
4049
4073
  url: string
4050
4074
  }
4051
4075
 
4076
+ type ExternalExperimentTimestamp = number | string | Date
4077
+
4078
+ interface StartExperimentDatasetOptions {
4079
+ /** Existing dataset id. When omitted, a placeholder dataset is created. */
4080
+ id?: string
4081
+ /** Dataset version to associate with the experiment. */
4082
+ version?: number
4083
+ /** Placeholder dataset name. Defaults to `<experiment name> dataset`. */
4084
+ name?: string
4085
+ /** Placeholder dataset description. */
4086
+ description?: string
4087
+ }
4088
+
4089
+ interface StartExperimentOptions {
4090
+ name: string
4091
+ description?: string
4092
+ /** Override the configured project name for this external experiment. */
4093
+ projectName?: string
4094
+ dataset?: StartExperimentDatasetOptions
4095
+ config?: Record<string, JSONType>
4096
+ metadata?: Record<string, JSONType>
4097
+ tags?: Record<string, string>
4098
+ }
4099
+
4100
+ interface ExternalExperimentSpanInput {
4101
+ name?: string
4102
+ input?: JSONType
4103
+ output?: JSONType
4104
+ expectedOutput?: JSONType
4105
+ metadata?: Record<string, JSONType>
4106
+ tags?: Record<string, string>
4107
+ startedAt?: ExternalExperimentTimestamp
4108
+ completedAt?: ExternalExperimentTimestamp
4109
+ durationMs?: number
4110
+ error?: string | Error | { type?: string, name?: string, message?: string, stack?: string }
4111
+ datasetRecordId?: string
4112
+ runId?: string
4113
+ runIteration?: number
4114
+ }
4115
+
4116
+ interface ExternalExperimentSpan {
4117
+ experimentId: string
4118
+ spanId: string
4119
+ traceId: string
4120
+ url: string | null
4121
+ }
4122
+
4123
+ interface ExternalExperimentMetric {
4124
+ label: string
4125
+ value?: JSONType
4126
+ error?: string | Error
4127
+ timestamp?: ExternalExperimentTimestamp
4128
+ tags?: Record<string, string>
4129
+ source?: string
4130
+ }
4131
+
4132
+ interface ExternalExperimentCloseOptions {
4133
+ status?: string
4134
+ error?: string | Error
4135
+ }
4136
+
4137
+ interface ExternalExperiment {
4138
+ experimentId (): string
4139
+ name (): string
4140
+ url (): string | null
4141
+ submitSpan (input?: ExternalExperimentSpanInput): Promise<ExternalExperimentSpan>
4142
+ submitEvaluationMetrics (
4143
+ span: { experimentId?: string, spanId: string, traceId: string },
4144
+ metrics: ExternalExperimentMetric[]
4145
+ ): Promise<void>
4146
+ close (options?: ExternalExperimentCloseOptions): Promise<void>
4147
+ }
4148
+
4052
4149
  interface DatasetPushResult {
4053
4150
  /** Number of records from this push that were confirmed with a record id. */
4054
4151
  pushedCount: number
@@ -4057,10 +4154,30 @@ declare namespace tracer {
4057
4154
  }
4058
4155
 
4059
4156
  interface Dataset {
4060
- addRecord (input: JSONType, expectedOutput?: JSONType, metadata?: Record<string, JSONType>): Dataset
4157
+ addRecord (
4158
+ input: JSONType,
4159
+ expectedOutput?: JSONType,
4160
+ metadata?: Record<string, JSONType>,
4161
+ tags?: string[]
4162
+ ): Dataset
4163
+ /** Update fields on an existing dataset record. */
4164
+ update (index: number, fields: {
4165
+ input?: JSONType
4166
+ expectedOutput?: JSONType
4167
+ metadata?: Record<string, JSONType>
4168
+ }): Dataset
4169
+ /** Delete an existing dataset record. */
4170
+ delete (index: number): Dataset
4171
+ /** Add tags to a dataset record. */
4172
+ addTags (index: number, tags: string[]): Dataset
4173
+ /** Remove tags from a dataset record. */
4174
+ removeTags (index: number, tags: string[]): Dataset
4175
+ /** Replace all tags on a dataset record. */
4176
+ replaceTags (index: number, tags: string[]): Dataset
4061
4177
  /** Creates the dataset remotely if needed and pushes any unpushed records. */
4062
4178
  push (): Promise<DatasetPushResult>
4063
4179
  name (): string
4180
+ description (): string
4064
4181
  id (): string | null
4065
4182
  projectId (): string | null
4066
4183
  version (): number | null
@@ -4069,8 +4186,11 @@ declare namespace tracer {
4069
4186
  id: string | null,
4070
4187
  input: JSONType,
4071
4188
  expectedOutput: JSONType,
4072
- metadata: Record<string, JSONType>
4189
+ metadata: Record<string, JSONType>,
4190
+ tags: string[]
4073
4191
  }>
4192
+ /** Return the tags used to filter this dataset. */
4193
+ filterTags (): string[]
4074
4194
  /** Dashboard URL for the dataset, or null until pushed. */
4075
4195
  url (): string | null
4076
4196
  }
@@ -4090,6 +4210,8 @@ declare namespace tracer {
4090
4210
  pullDataset (name: string, options?: PullDatasetOptions): Promise<Dataset>
4091
4211
  /** Build an experiment to run over a dataset. */
4092
4212
  experiment (options: ExperimentOptions): Experiment
4213
+ /** Start an externally-driven experiment. */
4214
+ startExperiment (options: StartExperimentOptions): Promise<ExternalExperiment>
4093
4215
  }
4094
4216
 
4095
4217
  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": "5.121.0",
3
+ "version": "5.123.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