dd-trace 6.21.0 → 6.23.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 (231) hide show
  1. package/ci/diagnose.js +9 -14
  2. package/ci/init.js +1 -2
  3. package/ci/test-optimization-validation/ci-discovery.js +9 -4
  4. package/ci/test-optimization-validation/executable.js +1 -5
  5. package/ci/test-optimization-validation/framework-adapters/cypress.js +1 -4
  6. package/ci/test-optimization-validation/framework-adapters/vitest.js +1 -1
  7. package/ci/test-optimization-validation/generated-files.js +6 -4
  8. package/ci/test-optimization-validation/generated-test-contract.js +7 -3
  9. package/ci/test-optimization-validation/manifest-scaffold.js +7 -2
  10. package/ci/test-optimization-validation/manifest-schema.js +6 -7
  11. package/ci/test-optimization-validation/report-writer.js +6 -2
  12. package/ci/test-optimization-validation/runner-command.js +2 -4
  13. package/ci/test-optimization-validation/runner-contract.js +1 -2
  14. package/ci/test-optimization-validation/scenarios/auto-test-retries.js +1 -15
  15. package/ci/vitest-no-worker-init-runner-setup.mjs +27 -0
  16. package/ci/vitest-no-worker-init-setup.mjs +10 -7
  17. package/index.d.ts +41 -19
  18. package/initialize.mjs +1 -3
  19. package/openfeature/rules-based.d.ts +11 -0
  20. package/openfeature/rules-based.js +7 -0
  21. package/package.json +25 -22
  22. package/packages/datadog-core/src/storage.js +16 -0
  23. package/packages/datadog-esbuild/index.js +18 -12
  24. package/packages/datadog-instrumentations/index.js +2 -1
  25. package/packages/datadog-instrumentations/src/aerospike.js +3 -3
  26. package/packages/datadog-instrumentations/src/ai.js +3 -3
  27. package/packages/datadog-instrumentations/src/aws-durable-execution-sdk-js.js +0 -6
  28. package/packages/datadog-instrumentations/src/aws-sdk.js +21 -13
  29. package/packages/datadog-instrumentations/src/cassandra-driver.js +25 -20
  30. package/packages/datadog-instrumentations/src/claude-agent-sdk.js +9 -23
  31. package/packages/datadog-instrumentations/src/cucumber.js +65 -41
  32. package/packages/datadog-instrumentations/src/elasticsearch.js +1 -5
  33. package/packages/datadog-instrumentations/src/electron.js +6 -6
  34. package/packages/datadog-instrumentations/src/fastify.js +13 -4
  35. package/packages/datadog-instrumentations/src/fs.js +2 -2
  36. package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +9 -5
  37. package/packages/datadog-instrumentations/src/grpc/client.js +2 -0
  38. package/packages/datadog-instrumentations/src/helpers/bundler-register.js +28 -9
  39. package/packages/datadog-instrumentations/src/helpers/check-require-cache.js +1 -2
  40. package/packages/datadog-instrumentations/src/helpers/hooks.js +1 -0
  41. package/packages/datadog-instrumentations/src/helpers/instrument.js +1 -1
  42. package/packages/datadog-instrumentations/src/helpers/register.js +45 -1
  43. package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +2 -0
  44. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +89 -6
  45. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql-jit.js +5 -6
  46. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/jest.js +12 -0
  47. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/postgres.js +48 -31
  48. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/vitest.js +8 -0
  49. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/webdriverio.js +7 -7
  50. package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +5 -0
  51. package/packages/datadog-instrumentations/src/helpers/rewriter/transforms/postgres.js +42 -4
  52. package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +7 -10
  53. package/packages/datadog-instrumentations/src/ioredis.js +7 -5
  54. package/packages/datadog-instrumentations/src/iovalkey.js +7 -5
  55. package/packages/datadog-instrumentations/src/jest.js +72 -67
  56. package/packages/datadog-instrumentations/src/knex.js +9 -5
  57. package/packages/datadog-instrumentations/src/mariadb-bundle.js +3 -3
  58. package/packages/datadog-instrumentations/src/mocha/common.js +20 -8
  59. package/packages/datadog-instrumentations/src/mocha/main.js +140 -43
  60. package/packages/datadog-instrumentations/src/mocha/utils.js +38 -4
  61. package/packages/datadog-instrumentations/src/mocha/worker.js +1 -2
  62. package/packages/datadog-instrumentations/src/mongodb-core.js +3 -3
  63. package/packages/datadog-instrumentations/src/mongoose.js +3 -3
  64. package/packages/datadog-instrumentations/src/nova-sonic/audio.js +173 -0
  65. package/packages/datadog-instrumentations/src/nova-sonic/index.js +209 -0
  66. package/packages/datadog-instrumentations/src/nova-sonic/session.js +492 -0
  67. package/packages/datadog-instrumentations/src/openai-realtime/index.js +18 -6
  68. package/packages/datadog-instrumentations/src/openai-realtime/session.js +1 -1
  69. package/packages/datadog-instrumentations/src/openai.js +7 -0
  70. package/packages/datadog-instrumentations/src/pino.js +5 -6
  71. package/packages/datadog-instrumentations/src/playwright.js +2 -0
  72. package/packages/datadog-instrumentations/src/redis.js +27 -13
  73. package/packages/datadog-instrumentations/src/router.js +30 -0
  74. package/packages/datadog-instrumentations/src/rum-browser-scripts.js +2 -6
  75. package/packages/datadog-instrumentations/src/stripe.js +23 -12
  76. package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +8 -5
  77. package/packages/datadog-instrumentations/src/vitest-main.js +16 -18
  78. package/packages/datadog-instrumentations/src/vitest-util.js +7 -4
  79. package/packages/datadog-instrumentations/src/vitest-worker.js +1 -2
  80. package/packages/datadog-instrumentations/src/vitest.js +9 -1
  81. package/packages/datadog-instrumentations/src/webdriverio.js +5 -8
  82. package/packages/datadog-instrumentations/src/ws.js +1 -4
  83. package/packages/datadog-plugin-amqplib/src/client.js +1 -2
  84. package/packages/datadog-plugin-avsc/src/schema_iterator.js +1 -5
  85. package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/handler.js +1 -2
  86. package/packages/datadog-plugin-aws-sdk/src/base.js +5 -8
  87. package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/index.js +18 -0
  88. package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/sonic.js +45 -0
  89. package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +9 -3
  90. package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +2 -5
  91. package/packages/datadog-plugin-azure-durable-functions/src/index.js +5 -4
  92. package/packages/datadog-plugin-azure-functions/src/index.js +5 -3
  93. package/packages/datadog-plugin-claude-agent-sdk/src/index.js +0 -2
  94. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +4 -5
  95. package/packages/datadog-plugin-cypress/src/index.js +6 -6
  96. package/packages/datadog-plugin-cypress/src/source-map-utils.js +1 -2
  97. package/packages/datadog-plugin-cypress/src/support.js +3 -4
  98. package/packages/datadog-plugin-express/src/code_origin.js +1 -2
  99. package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +2 -2
  100. package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +1 -2
  101. package/packages/datadog-plugin-graphql/src/execute.js +5 -5
  102. package/packages/datadog-plugin-grpc/src/util.js +1 -2
  103. package/packages/datadog-plugin-kafkajs/src/producer.js +1 -2
  104. package/packages/datadog-plugin-mocha/src/index.js +7 -10
  105. package/packages/datadog-plugin-mocha/src/webdriverio-video.js +8 -4
  106. package/packages/datadog-plugin-mongodb-core/src/query.js +8 -5
  107. package/packages/datadog-plugin-next/src/index.js +1 -2
  108. package/packages/datadog-plugin-openai/src/tracing.js +5 -2
  109. package/packages/datadog-plugin-openai-agents/src/integration.js +6 -2
  110. package/packages/datadog-plugin-openai-agents/src/processor.js +2 -4
  111. package/packages/datadog-plugin-postgres/src/index.js +24 -0
  112. package/packages/datadog-plugin-protobufjs/src/schema_iterator.js +1 -5
  113. package/packages/datadog-plugin-rhea/src/consumer.js +1 -4
  114. package/packages/datadog-plugin-vitest/src/index.js +5 -2
  115. package/packages/datadog-shimmer/src/shimmer.js +5 -4
  116. package/packages/datadog-webpack/index.js +55 -43
  117. package/packages/datadog-webpack/src/loader.js +56 -8
  118. package/packages/dd-trace/src/aiguard/evaluation.js +143 -1
  119. package/packages/dd-trace/src/aiguard/integrations/vercel-ai.js +2 -4
  120. package/packages/dd-trace/src/aiguard/messages/utils.js +1 -2
  121. package/packages/dd-trace/src/aiguard/redaction.js +8 -2
  122. package/packages/dd-trace/src/appsec/api_security/normalized-route.js +3 -2
  123. package/packages/dd-trace/src/appsec/api_security/sampler.js +2 -6
  124. package/packages/dd-trace/src/appsec/downstream_requests.js +1 -9
  125. package/packages/dd-trace/src/appsec/handlers/http-request.js +3 -9
  126. package/packages/dd-trace/src/appsec/handlers/http-response.js +7 -2
  127. package/packages/dd-trace/src/appsec/iast/analyzers/path-traversal-analyzer.js +4 -3
  128. package/packages/dd-trace/src/appsec/iast/analyzers/set-cookies-header-interceptor.js +1 -4
  129. package/packages/dd-trace/src/appsec/iast/path-line.js +2 -1
  130. package/packages/dd-trace/src/appsec/iast/taint-tracking/operations-taint-object.js +7 -1
  131. package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +1 -3
  132. package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter-esm.mjs +1 -3
  133. package/packages/dd-trace/src/appsec/iast/telemetry/iast-metric.js +1 -6
  134. package/packages/dd-trace/src/appsec/lambda.js +1 -3
  135. package/packages/dd-trace/src/appsec/rasp/fs-plugin.js +37 -27
  136. package/packages/dd-trace/src/appsec/rasp/lfi.js +9 -5
  137. package/packages/dd-trace/src/appsec/reporter.js +21 -1
  138. package/packages/dd-trace/src/appsec/stack_trace.js +4 -4
  139. package/packages/dd-trace/src/ci-visibility/dynamic-atr-retries.js +3 -6
  140. package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +3 -2
  141. package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/msgpack-to-json.js +1 -1
  142. package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +13 -7
  143. package/packages/dd-trace/src/ci-visibility/exporters/settings-cache-key.js +1 -2
  144. package/packages/dd-trace/src/ci-visibility/exporters/test-worker/index.js +2 -8
  145. package/packages/dd-trace/src/ci-visibility/resolve-runfile-path.js +54 -0
  146. package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache-schema.js +5 -8
  147. package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache.js +2 -53
  148. package/packages/dd-trace/src/config/config-types.d.ts +2 -2
  149. package/packages/dd-trace/src/config/defaults.js +5 -5
  150. package/packages/dd-trace/src/config/generated-config-types.d.ts +10 -0
  151. package/packages/dd-trace/src/config/helper.js +34 -3
  152. package/packages/dd-trace/src/config/index.js +55 -9
  153. package/packages/dd-trace/src/config/normalize-service.js +1 -1
  154. package/packages/dd-trace/src/config/parsers.js +2 -2
  155. package/packages/dd-trace/src/config/supported-configurations.json +44 -0
  156. package/packages/dd-trace/src/datastreams/processor.js +3 -2
  157. package/packages/dd-trace/src/datastreams/schemas/schema_builder.js +1 -4
  158. package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +6 -5
  159. package/packages/dd-trace/src/debugger/devtools_client/condition.js +5 -5
  160. package/packages/dd-trace/src/debugger/devtools_client/send.js +1 -0
  161. package/packages/dd-trace/src/debugger/devtools_client/snapshot/collector.js +4 -6
  162. package/packages/dd-trace/src/debugger/devtools_client/status.js +1 -0
  163. package/packages/dd-trace/src/debugger/guardrail-metrics.js +2 -2
  164. package/packages/dd-trace/src/debugger/unsupported-runtime.js +16 -0
  165. package/packages/dd-trace/src/dogstatsd.js +1 -1
  166. package/packages/dd-trace/src/encode/tags-processors.js +2 -2
  167. package/packages/dd-trace/src/exporters/common/request.js +1 -5
  168. package/packages/dd-trace/src/id.js +14 -1
  169. package/packages/dd-trace/src/lambda/handler.js +179 -19
  170. package/packages/dd-trace/src/lambda/index.js +15 -1
  171. package/packages/dd-trace/src/lambda/runtime/patch.js +34 -7
  172. package/packages/dd-trace/src/llmobs/agent-manifest.js +19 -2
  173. package/packages/dd-trace/src/llmobs/audio-utils.js +3 -2
  174. package/packages/dd-trace/src/llmobs/constants/tags.js +15 -0
  175. package/packages/dd-trace/src/llmobs/experiments/experiment.js +1 -1
  176. package/packages/dd-trace/src/llmobs/plugins/anthropic/index.js +15 -0
  177. package/packages/dd-trace/src/llmobs/plugins/genai/util.js +1 -2
  178. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chat_model.js +1 -3
  179. package/packages/dd-trace/src/llmobs/plugins/langgraph/index.js +1 -1
  180. package/packages/dd-trace/src/llmobs/plugins/nova-sonic.js +92 -0
  181. package/packages/dd-trace/src/llmobs/plugins/openai/constants.js +5 -0
  182. package/packages/dd-trace/src/llmobs/plugins/openai/index.js +64 -2
  183. package/packages/dd-trace/src/llmobs/plugins/openai/utils.js +38 -0
  184. package/packages/dd-trace/src/llmobs/prompts/manager.js +5 -7
  185. package/packages/dd-trace/src/llmobs/prompts/prompt.js +1 -1
  186. package/packages/dd-trace/src/llmobs/sdk.js +15 -4
  187. package/packages/dd-trace/src/llmobs/span_processor.js +13 -2
  188. package/packages/dd-trace/src/llmobs/tagger.js +20 -10
  189. package/packages/dd-trace/src/llmobs/util.js +11 -6
  190. package/packages/dd-trace/src/llmobs/writers/base.js +4 -5
  191. package/packages/dd-trace/src/log/log.js +1 -5
  192. package/packages/dd-trace/src/openfeature/evaluation-telemetry-opt-out-hook.js +51 -0
  193. package/packages/dd-trace/src/openfeature/flagging_provider.js +48 -21
  194. package/packages/dd-trace/src/openfeature/index.js +6 -0
  195. package/packages/dd-trace/src/openfeature/writers/util.js +4 -4
  196. package/packages/dd-trace/src/opentelemetry/logs/otlp_transformer.js +1 -1
  197. package/packages/dd-trace/src/opentelemetry/metrics/otlp_transformer.js +1 -1
  198. package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +1 -2
  199. package/packages/dd-trace/src/opentelemetry/otlp/common.proto +1 -1
  200. package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +24 -24
  201. package/packages/dd-trace/src/opentracing/propagation/text_map.js +53 -13
  202. package/packages/dd-trace/src/otel-sampling.js +4 -5
  203. package/packages/dd-trace/src/otel-thread-ctx.js +79 -13
  204. package/packages/dd-trace/src/plugin_manager.js +1 -2
  205. package/packages/dd-trace/src/plugins/database.js +7 -16
  206. package/packages/dd-trace/src/plugins/tracing.js +0 -1
  207. package/packages/dd-trace/src/plugins/util/git.js +99 -59
  208. package/packages/dd-trace/src/plugins/util/inferred_proxy.js +1 -5
  209. package/packages/dd-trace/src/plugins/util/stacktrace.js +2 -1
  210. package/packages/dd-trace/src/plugins/util/test.js +50 -4
  211. package/packages/dd-trace/src/plugins/util/web.js +90 -20
  212. package/packages/dd-trace/src/priority_sampler.js +1 -2
  213. package/packages/dd-trace/src/profiling/profiler.js +4 -6
  214. package/packages/dd-trace/src/proxy.js +1 -2
  215. package/packages/dd-trace/src/ritm.js +4 -2
  216. package/packages/dd-trace/src/serverless.js +5 -0
  217. package/packages/dd-trace/src/span_processor.js +13 -17
  218. package/packages/dd-trace/src/span_stats.js +4 -1
  219. package/packages/dd-trace/src/telemetry/endpoints.js +1 -3
  220. package/packages/dd-trace/src/telemetry/logs/log-collector.js +1 -1
  221. package/packages/dd-trace/src/util.js +37 -4
  222. package/packages/dd-trace/src/web-tags-cache.js +6 -2
  223. package/vendor/dist/@apm-js-collab/code-transformer/index.js +8 -8
  224. package/vendor/dist/@datadog/openfeature-node-server/index.js +1 -1
  225. package/vendor/dist/@datadog/openfeature-node-server/rules-based/LICENSE +201 -0
  226. package/vendor/dist/@datadog/openfeature-node-server/rules-based/index.d.ts +925 -0
  227. package/vendor/dist/@datadog/openfeature-node-server/rules-based/index.js +1 -0
  228. package/vendor/dist/@datadog/sketches-js/index.js +1 -1
  229. package/vendor/dist/protobufjs/index.js +1 -1
  230. package/vendor/dist/protobufjs/minimal/index.js +1 -1
  231. package/vendor/dist/shell-quote/index.js +1 -1
package/ci/diagnose.js CHANGED
@@ -1743,9 +1743,7 @@ function readTextFiles (root, physicalRoot, files, maxTotalBytes) {
1743
1743
 
1744
1744
  for (const relativePath of files) {
1745
1745
  const file = getSafeScannedFile(root, physicalRoot, relativePath)
1746
- if (!file) continue
1747
-
1748
- if (file.stat.size > MAX_TEXT_FILE_SIZE) continue
1746
+ if (!file || file.stat.size > MAX_TEXT_FILE_SIZE) continue
1749
1747
  if (totalBytes + file.stat.size > maxTotalBytes) {
1750
1748
  textFiles.truncated = true
1751
1749
  break
@@ -1862,15 +1860,13 @@ function isTestSetupOrCiFile (file) {
1862
1860
  const relativePath = file.relativePath
1863
1861
  const basename = path.basename(relativePath)
1864
1862
 
1865
- if (isWorkflowFile(relativePath)) return true
1866
- if (basename === 'package.json') return true
1867
- if (/^(?:jest|config-jest|vitest|vite|playwright|cypress|cucumber)\.config\./.test(basename)) return true
1868
- if (/^\.mocharc\./.test(basename)) return true
1869
- if (basename === 'cypress.json') return true
1870
- if (/setup|bootstrap/i.test(basename)) return true
1871
- if (relativePath.startsWith('cypress/support/')) return true
1872
-
1873
- return false
1863
+ return isWorkflowFile(relativePath) ||
1864
+ basename === 'package.json' ||
1865
+ /^(?:jest|config-jest|vitest|vite|playwright|cypress|cucumber)\.config\./.test(basename) ||
1866
+ /^\.mocharc\./.test(basename) ||
1867
+ basename === 'cypress.json' ||
1868
+ /setup|bootstrap/i.test(basename) ||
1869
+ relativePath.startsWith('cypress/support/')
1874
1870
  }
1875
1871
 
1876
1872
  /**
@@ -2014,8 +2010,7 @@ function coerceVersion (rawVersion) {
2014
2010
  */
2015
2011
  function isAmbiguousRange (rawVersion) {
2016
2012
  const version = String(rawVersion || '').trim()
2017
- if (!version) return true
2018
- if (version.includes('||')) return true
2013
+ if (!version || version.includes('||')) return true
2019
2014
  return /<=?\s*\d/.test(version)
2020
2015
  }
2021
2016
 
package/ci/init.js CHANGED
@@ -32,8 +32,7 @@ function detectTestWorkerType () {
32
32
  if (getEnvironmentVariable('CUCUMBER_WORKER_ID')) return 'cucumber'
33
33
  if (getEnvironmentVariable('MOCHA_WORKER_ID')) return 'mocha'
34
34
  if (getValueFromEnvSources('DD_PLAYWRIGHT_WORKER')) return 'playwright'
35
- if (getEnvironmentVariable('TINYPOOL_WORKER_ID')) return 'vitest'
36
- if (getValueFromEnvSources('DD_VITEST_WORKER')) return 'vitest'
35
+ if (getEnvironmentVariable('TINYPOOL_WORKER_ID') || getValueFromEnvSources('DD_VITEST_WORKER')) return 'vitest'
37
36
  return null
38
37
  }
39
38
 
@@ -40,8 +40,7 @@ function buildCiDiscovery ({ manifest, diagnosis }) {
40
40
  const candidateFound = getManifestWorkflowLocations(manifest)
41
41
  const manifestFound = uniqueStrings([...declaredFound, ...candidateFound])
42
42
  const searched = normalizeStringArray(declared.searched)
43
- let method = 'validator-static-diagnosis'
44
- if (candidateFound.length > 0) method = 'framework-ci-command'
43
+ let method = candidateFound.length > 0 ? 'framework-ci-command' : 'validator-static-diagnosis'
45
44
  if (declaredFound.length > 0) method = 'manifest'
46
45
  if (typeof declared.method === 'string' && declared.method) method = declared.method
47
46
  const found = manifestFound.length > 0 ? manifestFound : staticFound
@@ -83,8 +82,14 @@ function getManifestWorkflowLocations (manifest) {
83
82
 
84
83
  function getFrameworkCiDiscoveryContradiction (framework, manifest) {
85
84
  const ciDiscovery = manifest?.ciDiscovery
86
- if (!ciDiscovery || !Array.isArray(ciDiscovery.staticFound) || ciDiscovery.staticFound.length === 0) return null
87
- if (!frameworkClaimsNoCi(framework)) return null
85
+ if (
86
+ !ciDiscovery ||
87
+ !Array.isArray(ciDiscovery.staticFound) ||
88
+ ciDiscovery.staticFound.length === 0 ||
89
+ !frameworkClaimsNoCi(framework)
90
+ ) {
91
+ return null
92
+ }
88
93
 
89
94
  return {
90
95
  reason: 'CI workflow files were found by validator static diagnosis, but this manifest entry says no CI ' +
@@ -158,11 +158,7 @@ function splitNodeOptions (source) {
158
158
  }
159
159
  }
160
160
  const next = source[index + 1]
161
- if (character === '\\' && next && (next === quote || /[\s'"\\]/.test(next))) {
162
- value += source[++index]
163
- } else {
164
- value += character
165
- }
161
+ value += character === '\\' && next && (next === quote || /[\s'"\\]/.test(next)) ? source[++index] : character
166
162
  started = true
167
163
  }
168
164
  if (quote) throw new Error('NODE_OPTIONS contains an unterminated quoted value.')
@@ -37,10 +37,7 @@ function getTestExtension (filename) {
37
37
  * @param {string} input.testName generated test name
38
38
  */
39
39
  function getGeneratedTestContent ({ scenarioId, testName }) {
40
- let content = ''
41
- if (scenarioId === 'atr-fail-once') {
42
- content = 'let attempt = 0\n\n'
43
- }
40
+ let content = scenarioId === 'atr-fail-once' ? 'let attempt = 0\n\n' : ''
44
41
  content += "describe('dd-test-optimization-validation', () => {\n" +
45
42
  ` it(${JSON.stringify(testName)}, () => {\n` +
46
43
  (scenarioId === 'atr-fail-once'
@@ -361,7 +361,7 @@ function getDelimitedRanges (source, open, close) {
361
361
  function getLiteralStringProperties (source, property) {
362
362
  return getPropertyPositions(source, property).flatMap(({ index, valueStart }) => {
363
363
  const literal = /^(["'])([^"'\\]+)\1/.exec(source.slice(valueStart))
364
- return literal ? [{ index, value: literal[2] }] : []
364
+ return literal ? { index, value: literal[2] } : []
365
365
  })
366
366
  }
367
367
 
@@ -305,12 +305,14 @@ function isCleanupAuthorizationValid (filename, authorization) {
305
305
  try {
306
306
  const currentPhysicalRoot = fs.realpathSync(authorization.lexicalRoot)
307
307
  const rootStat = fs.statSync(currentPhysicalRoot, { bigint: true })
308
- if (currentPhysicalRoot !== authorization.physicalRoot ||
309
- rootStat.dev !== authorization.rootDevice || rootStat.ino !== authorization.rootInode) {
308
+ if (
309
+ currentPhysicalRoot !== authorization.physicalRoot ||
310
+ rootStat.dev !== authorization.rootDevice ||
311
+ rootStat.ino !== authorization.rootInode ||
312
+ authorization.physicalParent === undefined
313
+ ) {
310
314
  return false
311
315
  }
312
-
313
- if (authorization.physicalParent === undefined) return false
314
316
  const physicalParent = fs.realpathSync(path.dirname(filename))
315
317
  const parentStat = fs.statSync(physicalParent, { bigint: true })
316
318
  if (physicalParent !== authorization.physicalParent ||
@@ -124,9 +124,13 @@ function getGeneratedTestContent ({ framework, moduleSystem, scenarioId, stateFi
124
124
  */
125
125
  function getGeneratedTestContractError (framework) {
126
126
  const strategy = framework.generatedTestStrategy
127
- if (!strategy || !['planned', 'verified'].includes(strategy.status)) return
128
-
129
- if (!['cucumber', 'cypress', 'jest', 'mocha', 'playwright', 'vitest'].includes(framework.framework)) return
127
+ if (
128
+ !strategy ||
129
+ !['planned', 'verified'].includes(strategy.status) ||
130
+ !['cucumber', 'cypress', 'jest', 'mocha', 'playwright', 'vitest'].includes(framework.framework)
131
+ ) {
132
+ return
133
+ }
130
134
  if (!['commonjs', 'esm'].includes(strategy.moduleSystem)) {
131
135
  return 'must retain generatedTestStrategy.moduleSystem as "commonjs" or "esm".'
132
136
  }
@@ -750,8 +750,13 @@ function hasCucumberBrowserSupport (files, retainedInputs, projectRoot) {
750
750
  function isTestFile (filename, source, framework, projectRoot, allowDirectoryConvention) {
751
751
  const basename = path.basename(filename)
752
752
  const normalized = filename.replaceAll('\\', '/')
753
- if (normalized.includes('/dd-test-optimization-validation-')) return false
754
- if (TYPE_ONLY_TEST_PATTERN.test(basename) || TYPE_ONLY_DIRECTORY_PATTERN.test(normalized)) return false
753
+ if (
754
+ normalized.includes('/dd-test-optimization-validation-') ||
755
+ TYPE_ONLY_TEST_PATTERN.test(basename) ||
756
+ TYPE_ONLY_DIRECTORY_PATTERN.test(normalized)
757
+ ) {
758
+ return false
759
+ }
755
760
  if (framework === 'cucumber') return cucumber.isTestFile(filename)
756
761
  if (framework === 'cypress') return cypress.isTestFile(basename, path.dirname(filename), projectRoot)
757
762
  if (framework === 'playwright') return playwright.isTestFile(basename, path.dirname(filename), projectRoot)
@@ -441,16 +441,15 @@ function validateCiWiring (repositoryRoot, ciWiring, prefix, errors) {
441
441
  if (typeof ciWiring.reviewComplete !== 'boolean') errors.push(`${prefix}.reviewComplete must be a boolean.`)
442
442
  validateStringArray(ciWiring.unresolved, `${prefix}.unresolved`, errors)
443
443
 
444
- if (!isObject(ciWiring.initialization) ||
445
- !INITIALIZATION_STATUSES.has(ciWiring.initialization.status)) {
446
- errors.push(`${prefix}.initialization.status must be configured, not_configured, or unknown.`)
447
- } else {
444
+ if (isObject(ciWiring.initialization) && INITIALIZATION_STATUSES.has(ciWiring.initialization.status)) {
448
445
  validateStringArray(ciWiring.initialization.evidence, `${prefix}.initialization.evidence`, errors)
449
- }
450
- if (!isObject(ciWiring.transport) || !TRANSPORT_MODES.has(ciWiring.transport.mode)) {
451
- errors.push(`${prefix}.transport.mode must be agent, agentless, none, or unknown.`)
452
446
  } else {
447
+ errors.push(`${prefix}.initialization.status must be configured, not_configured, or unknown.`)
448
+ }
449
+ if (isObject(ciWiring.transport) && TRANSPORT_MODES.has(ciWiring.transport.mode)) {
453
450
  validateStringArray(ciWiring.transport.evidence, `${prefix}.transport.evidence`, errors)
451
+ } else {
452
+ errors.push(`${prefix}.transport.mode must be agent, agentless, none, or unknown.`)
454
453
  }
455
454
  }
456
455
 
@@ -332,8 +332,12 @@ function getActions (results) {
332
332
  function getActionPriority (result, localPasses) {
333
333
  if (result.evidence?.possibleLibraryBug) return 0
334
334
  if (result.scenario === 'ci-wiring' && localPasses.has(result.frameworkId)) return 0
335
- if (result.evidence?.blockerCategory === 'EXECUTION_ENVIRONMENT_BLOCKED') return 1
336
- if (result.evidence?.blockerCategory === 'VALIDATOR_LIMITATION') return 1
335
+ if (
336
+ result.evidence?.blockerCategory === 'EXECUTION_ENVIRONMENT_BLOCKED' ||
337
+ result.evidence?.blockerCategory === 'VALIDATOR_LIMITATION'
338
+ ) {
339
+ return 1
340
+ }
337
341
  if (result.scenario === 'ci-wiring') return 2
338
342
  return 3
339
343
  }
@@ -46,8 +46,7 @@ function getGeneratedCommand (framework, scenario) {
46
46
  * @returns {Array<[string, object]>} labeled direct-runner commands
47
47
  */
48
48
  function getFrameworkCommands (framework, requestedScenario = null) {
49
- if (framework.status !== 'runnable') return []
50
- if (requestedScenario === 'ci-wiring') return []
49
+ if (framework.status !== 'runnable' || requestedScenario === 'ci-wiring') return []
51
50
 
52
51
  const commands = [['basic-reporting', getBasicCommand(framework)]]
53
52
  const fallbackTests = framework.validation.fallbackTests
@@ -99,8 +98,7 @@ function getManifestInputFiles (manifest, { includeLocal = true } = {}) {
99
98
  for (const framework of manifest.frameworks) {
100
99
  addExistingFile(files, framework.ciWiring?.configFile)
101
100
  addExistingFile(files, framework.project?.packageJson)
102
- if (!includeLocal) continue
103
- if (framework.status !== 'runnable') continue
101
+ if (!includeLocal || framework.status !== 'runnable') continue
104
102
  addExistingFile(files, framework.validation?.runner)
105
103
  addExistingFile(files, framework.validation?.testFile)
106
104
  const fallbackTests = framework.validation?.fallbackTests
@@ -450,8 +450,7 @@ function getRunnerInputError (args, environment, projectRoot, repositoryRoot, co
450
450
  * @returns {{error?: string, runnerIndex: number, tokens: string[]}|undefined} parsed invocation
451
451
  */
452
452
  function getFrameworkInvocation (command, framework) {
453
- if (CONTROL_PATTERN.test(String(command || ''))) return
454
- if (command === `direct ${framework} binary`) return
453
+ if (CONTROL_PATTERN.test(String(command || '')) || command === `direct ${framework} binary`) return
455
454
  const tokens = tokenizeCommand(command)
456
455
  const executable = getRunnerExecutableName(framework)
457
456
  const runnerIndex = tokens.findIndex(token => {
@@ -100,21 +100,7 @@ async function runAutoTestRetries ({ framework, out, options }) {
100
100
  })
101
101
  }
102
102
 
103
- if (run.result.exitCode !== 0) {
104
- return failWithDebugRerun({
105
- command: scenario.runCommand,
106
- fixtureConfig,
107
- diagnosis: getAutoTestRetriesFailureDiagnosis(framework, evidence),
108
- evidence,
109
- framework,
110
- options,
111
- out,
112
- outDir,
113
- scenarioName,
114
- })
115
- }
116
-
117
- if (tests.length < 2 || autoTestRetryEvents.length === 0) {
103
+ if (run.result.exitCode !== 0 || tests.length < 2 || autoTestRetryEvents.length === 0) {
118
104
  return failWithDebugRerun({
119
105
  command: scenario.runCommand,
120
106
  fixtureConfig,
@@ -2,7 +2,34 @@ try {
2
2
  // Vitest does not expose setFn from its public setup API; keep this optional for strict installers.
3
3
  const vitestRunner = await import('@vitest/runner')
4
4
  globalThis[Symbol.for('dd-trace.vitest.set-fn')] = vitestRunner.setFn
5
+ trackNativeRetryOptions(vitestRunner.getCurrentSuite())
5
6
  } catch {}
6
7
  globalThis[Symbol.for('dd-trace.vitest.browser-context-importer')] = () => import('@vitest/browser/context')
7
8
 
8
9
  await import('./vitest-no-worker-init-setup.mjs')
10
+
11
+ /**
12
+ * Legacy Vitest inherits numeric retries and loses their origin during collection.
13
+ * These collectors and their chainable callbacks are created at runtime.
14
+ * @param {object} collector
15
+ */
16
+ function trackNativeRetryOptions (collector) {
17
+ const original = collector.test.fn
18
+ collector.test.fn = function (name, optionsOrFn, fnOrOptions) {
19
+ const options = optionsOrFn !== null && typeof optionsOrFn === 'object' ? optionsOrFn : fnOrOptions
20
+ const length = collector.tasks.length
21
+ const result = original.apply(this, arguments)
22
+ if ((options?.retry !== undefined || collector.options?.retry !== undefined) && collector.tasks.length > length) {
23
+ const task = collector.tasks.at(-1)
24
+ task.meta = { ...task.meta, __ddTestOptNativeRetry: true }
25
+ }
26
+ return result
27
+ }
28
+ const push = collector.tasks.push
29
+ collector.tasks.push = function (...tasks) {
30
+ for (const task of tasks) {
31
+ if (task.type === 'collector') trackNativeRetryOptions(task)
32
+ }
33
+ return push.apply(this, tasks)
34
+ }
35
+ }
@@ -3,7 +3,7 @@ import { afterEach, beforeAll, beforeEach, inject } from 'vitest'
3
3
  // Instrumentation-less setup for DD_EXPERIMENTAL_TEST_OPT_VITEST_NO_WORKER_INIT.
4
4
  // It applies Test Optimization execution changes without initializing dd-trace and also supports Browser Mode.
5
5
  const VITEST_NO_WORKER_INIT_ACTIVE_ENV = 'DD_TEST_OPT_VITEST_NO_WORKER_INIT_ACTIVE'
6
- const SERIALIZED_CONTEXT_PREFIX = '\u0000dd-vitest-context:'
6
+ const SERIALIZED_CONTEXT_PREFIX = '\0dd-vitest-context:'
7
7
  const providedContext = getProvidedContext()
8
8
  const isNoWorkerInitActive = providedContext.isActive ?? getIsNoWorkerInitActive()
9
9
  const attemptToFixTests = providedContext.attemptToFixTests || {}
@@ -220,9 +220,8 @@ function getNextAttemptIndex (task) {
220
220
  */
221
221
  function prepareRumCorrelation (task, attemptIndex) {
222
222
  // A per-origin cookie cannot identify overlapping attempts without racing.
223
- if (!isRumCorrelationEnabled || isConcurrentTask(task)) return
224
-
225
223
  if (
224
+ !isRumCorrelationEnabled || isConcurrentTask(task) ||
226
225
  typeof window === 'undefined' ||
227
226
  typeof document === 'undefined' ||
228
227
  typeof rumTestExecutionIdCookieName !== 'string'
@@ -289,8 +288,7 @@ function getRum () {
289
288
  * @param {object|undefined} rum
290
289
  */
291
290
  function getIsRumActive (rum) {
292
- if (!rum) return false
293
- if (typeof rum.getInternalContext !== 'function') return false
291
+ if (!rum || typeof rum.getInternalContext !== 'function') return false
294
292
 
295
293
  try {
296
294
  return !!rum.getInternalContext()
@@ -770,8 +768,13 @@ function getEarlyFlakeDetectionSuiteCandidate (suite) {
770
768
 
771
769
  const testSuite = getTestSuite(task)
772
770
  const testName = getTestName(task)
773
- if (attemptToFixTests[testSuite]?.[testName] || disabledTests[testSuite]?.[testName]) continue
774
- if (!isEarlyFlakeDetectionTest(testSuite, testName)) continue
771
+ if (
772
+ attemptToFixTests[testSuite]?.[testName] ||
773
+ disabledTests[testSuite]?.[testName] ||
774
+ !isEarlyFlakeDetectionTest(testSuite, testName)
775
+ ) {
776
+ continue
777
+ }
775
778
 
776
779
  candidate ||= {
777
780
  hasNewTest: false,
package/index.d.ts CHANGED
@@ -218,7 +218,7 @@ interface Tracer extends opentracing.Tracer {
218
218
  * @env DD_FEATURE_FLAGS_ENABLED
219
219
  * @env DD_FEATURE_FLAGS_CONFIGURATION_SOURCE
220
220
  * @env DD_FLAGGING_EVALUATION_COUNTS_ENABLED
221
- * @beta This feature is in preview and not ready for production use
221
+ * @env DD_FEATURE_FLAGS_EXPOSURES_DATADOG_LOGGING_ENABLED
222
222
  */
223
223
  openfeature: tracer.OpenFeatureProvider;
224
224
 
@@ -275,7 +275,7 @@ interface Tracer extends opentracing.Tracer {
275
275
  *
276
276
  * Removes all baggage items from the current context and returns the new context.
277
277
  *
278
- * @see https://opentelemetry.io/docs/specs/otel/baggage/api/#remove-all-values
278
+ * @see https://opentelemetry.io/docs/specs/otel/baggage/api/#clear-baggage-in-the-context
279
279
  */
280
280
  removeAllBaggageItems (): Record<string, string>;
281
281
  }
@@ -818,6 +818,22 @@ declare namespace tracer {
818
818
  */
819
819
  site?: string;
820
820
 
821
+ /**
822
+ * Feature Flags configuration.
823
+ */
824
+ featureFlags?: {
825
+ /**
826
+ * Allow boolean true in dd_evaluation_telemetry_opt_out to suppress evaluation events, metrics, and span tags.
827
+ * The attribute remains available to targeting rules and exposure reporting.
828
+ * Enabling this option does not change exposure events or flag evaluation results.
829
+ * Captured when the provider is constructed.
830
+ * Explicit configuration takes precedence over the environment variable, including false.
831
+ * @default false
832
+ * @env DD_FEATURE_FLAGS_EVALUATION_TELEMETRY_PER_SUBJECT_OPT_OUT_ENABLED
833
+ */
834
+ enableEvaluationTelemetryOptOutParameter?: boolean
835
+ }
836
+
821
837
  /**
822
838
  * Experimental features can be enabled individually using key / value pairs.
823
839
  * @default {}
@@ -890,8 +906,6 @@ declare namespace tracer {
890
906
 
891
907
  /**
892
908
  * Configuration for Feature Flagging & Experimentation.
893
- *
894
- * @beta This feature is in preview and not ready for production use
895
909
  */
896
910
  flaggingProvider?: {
897
911
  /**
@@ -1728,8 +1742,6 @@ declare namespace tracer {
1728
1742
  *
1729
1743
  * Wraps @datadog/openfeature-node-server with agentless and Agent Remote Config delivery.
1730
1744
  * Implements the OpenFeature Provider interface for flag evaluation.
1731
- *
1732
- * @beta This feature is in preview and not ready for production use
1733
1745
  */
1734
1746
  export interface OpenFeatureProvider {
1735
1747
  /**
@@ -2494,14 +2506,14 @@ declare namespace tracer {
2494
2506
  /**
2495
2507
  * This plugin patches the [browser-bunyan](https://github.com/philmander/browser-bunyan)
2496
2508
  * to automatically inject trace identifiers in log records when the
2497
- * [logInjection](interfaces/traceroptions.html#logInjection) option is enabled
2509
+ * {@link TracerOptions.logInjection | logInjection} option is enabled
2498
2510
  * on the tracer.
2499
2511
  */
2500
2512
  interface browser_bunyan extends Integration {}
2501
2513
 
2502
2514
  /**
2503
2515
  * This plugin automatically instruments the
2504
- * [bullmq](https://github.com/npmjs/package/bullmq) message queue library.
2516
+ * [bullmq](https://www.npmjs.com/package/bullmq) message queue library.
2505
2517
  */
2506
2518
  interface bullmq extends Instrumentation {
2507
2519
  /**
@@ -2522,7 +2534,7 @@ declare namespace tracer {
2522
2534
  /**
2523
2535
  * This plugin patches the [bunyan](https://github.com/trentm/node-bunyan)
2524
2536
  * to automatically inject trace identifiers in log records when the
2525
- * [logInjection](interfaces/traceroptions.html#logInjection) option is enabled
2537
+ * {@link TracerOptions.logInjection | logInjection} option is enabled
2526
2538
  * on the tracer.
2527
2539
  */
2528
2540
  interface bunyan extends Integration {}
@@ -2975,7 +2987,7 @@ declare namespace tracer {
2975
2987
 
2976
2988
  /**
2977
2989
  * This plugin automatically instruments the
2978
- * [langgraph](https://github.com/npmjs/package/langgraph) library.
2990
+ * [langgraph](https://www.npmjs.com/package/@langchain/langgraph) library.
2979
2991
  */
2980
2992
  interface langgraph extends Instrumentation, LLMObsIntegration {}
2981
2993
 
@@ -3011,7 +3023,7 @@ declare namespace tracer {
3011
3023
 
3012
3024
  /**
3013
3025
  * This plugin automatically instruments the
3014
- * [modelcontextprotocol-sdk](https://github.com/npmjs/package/@modelcontextprotocol/sdk) library.
3026
+ * [modelcontextprotocol-sdk](https://www.npmjs.com/package/@modelcontextprotocol/sdk) library.
3015
3027
  */
3016
3028
  interface modelcontextprotocol_sdk extends Instrumentation, LLMObsIntegration {}
3017
3029
 
@@ -3190,7 +3202,7 @@ declare namespace tracer {
3190
3202
  /**
3191
3203
  * This plugin patches the [pino](http://getpino.io)
3192
3204
  * to automatically inject trace identifiers in log records when the
3193
- * [logInjection](interfaces/traceroptions.html#logInjection) option is enabled
3205
+ * {@link TracerOptions.logInjection | logInjection} option is enabled
3194
3206
  * on the tracer.
3195
3207
  */
3196
3208
  interface pino extends Integration {}
@@ -3361,7 +3373,7 @@ declare namespace tracer {
3361
3373
  /**
3362
3374
  * This plugin patches the [winston](https://github.com/winstonjs/winston)
3363
3375
  * to automatically inject trace identifiers in log records when the
3364
- * [logInjection](interfaces/traceroptions.html#logInjection) option is enabled
3376
+ * {@link TracerOptions.logInjection | logInjection} option is enabled
3365
3377
  * on the tracer.
3366
3378
  */
3367
3379
  interface winston extends Integration {}
@@ -3652,7 +3664,7 @@ declare namespace tracer {
3652
3664
  * key/value pair separated by an equals sign `=`. Spaces and horizontal tabs
3653
3665
  * surrounding `list-members` are ignored. There can be a maximum of 32
3654
3666
  * `list-members` in a `list`.
3655
- * More Info: https://www.w3.org/TR/trace-context/#tracestate-field
3667
+ * More Info: https://www.w3.org/TR/trace-context/#tracestate-header
3656
3668
  *
3657
3669
  * Examples:
3658
3670
  * Single tracing system (generic format):
@@ -4867,11 +4879,14 @@ declare namespace tracer {
4867
4879
  }
4868
4880
 
4869
4881
  /**
4870
- * Declares the agent an `agent` span represents, reported as the agent's manifest. Only applies to
4871
- * `agent` spans. Unreportable values are dropped with a warning, and unset values (`undefined`, `null`,
4872
- * `''`, `[]`) leave what an earlier annotation declared in place.
4882
+ * Declares the agent an `agent` span represents. `version` is set as an `agent_version` tag on the agent
4883
+ * span and its child spans within the same process. The other fields are reported as the agent's manifest.
4884
+ * Only applies to `agent` spans. Unreportable values are dropped with a warning, and unset values
4885
+ * (`undefined`, `null`, `''`, `[]`) leave what an earlier annotation declared in place.
4873
4886
  */
4874
4887
  interface Agent {
4888
+ /** The version of the agent. Must not contain a comma. */
4889
+ version?: string,
4875
4890
  /** The agent's name. Defaults to the agent span's name. */
4876
4891
  name?: string,
4877
4892
  /** The system instructions the agent runs with. */
@@ -4966,8 +4981,8 @@ declare namespace tracer {
4966
4981
  prompt?: Prompt,
4967
4982
 
4968
4983
  /**
4969
- * Declares the agent running in this context, read when the context is entered. The manifest is
4970
- * reported on every `agent` span in the context, nested ones included. Use `annotate` on a nested agent
4984
+ * Declares the agent running in this context, read when the context is entered. The version and manifest
4985
+ * are reported on every `agent` span in the context, nested ones included. Use `annotate` on a nested agent
4971
4986
  * span to declare its own agent.
4972
4987
  */
4973
4988
  agent?: Agent,
@@ -5028,6 +5043,13 @@ declare namespace tracer {
5028
5043
  * If not provided for LLM or embedding spans, a default value of 'custom' will be set.
5029
5044
  */
5030
5045
  modelProvider?: string,
5046
+
5047
+ /**
5048
+ * The version of the agent, set as an `agent_version` tag on the agent span and its child spans within the
5049
+ * same process. Must not contain a comma. Only used on `agent` spans, and wins over a version declared by an
5050
+ * enclosing `annotationContext`.
5051
+ */
5052
+ version?: string,
5031
5053
  }
5032
5054
 
5033
5055
  interface LLMObsNamedSpanOptions extends LLMObsSpanOptions {
package/initialize.mjs CHANGED
@@ -101,8 +101,6 @@ if (isMainThread) {
101
101
  // Only register the loader hook when instrumentation initialized. On a bailout the
102
102
  // loader has nothing to instrument and can keep a short-lived process from exiting.
103
103
  if (Module.register && initialized) {
104
- // The loader builds its own include/exclude matcher in `initialize`, so no
105
- // options need to cross the registration boundary.
106
- Module.register('./loader-hook.mjs', import.meta.url)
104
+ require('./register.js')
107
105
  }
108
106
  }
@@ -0,0 +1,11 @@
1
+ export {
2
+ configurationToString,
3
+ ConfigurationFetchError,
4
+ fetchRulesConfiguration,
5
+ } from '../vendor/dist/@datadog/openfeature-node-server/rules-based';
6
+ export type {
7
+ ConfigurationFetchErrorCode,
8
+ FlagsConfiguration,
9
+ FlagsConfigurationWire,
10
+ RulesConfigurationFetchOptions,
11
+ } from '../vendor/dist/@datadog/openfeature-node-server/rules-based';
@@ -0,0 +1,7 @@
1
+ 'use strict'
2
+
3
+ const rules = require('../vendor/dist/@datadog/openfeature-node-server/rules-based')
4
+
5
+ exports.configurationToString = rules.configurationToString
6
+ exports.ConfigurationFetchError = rules.ConfigurationFetchError
7
+ exports.fetchRulesConfiguration = rules.fetchRulesConfiguration