dd-trace 5.123.0 → 5.125.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 (251) hide show
  1. package/LICENSE-3rdparty.csv +3 -1
  2. package/ci/init.js +8 -3
  3. package/ci/test-optimization-validation/ci-package-scripts.js +2 -2
  4. package/ci/test-optimization-validation/ci-remediation.js +6 -6
  5. package/ci/test-optimization-validation/command-blocker.js +7 -5
  6. package/ci/test-optimization-validation/framework-adapters/cucumber.js +1 -1
  7. package/ci/test-optimization-validation/framework-adapters/cypress.js +9 -11
  8. package/ci/test-optimization-validation/framework-adapters/vitest.js +3 -3
  9. package/ci/test-optimization-validation/package-check.js +1 -1
  10. package/ci/test-optimization-validation/report-writer.js +7 -5
  11. package/ci/test-optimization-validation/scenarios/ci-wiring.js +5 -4
  12. package/ci/vitest-no-worker-init-runner-setup.mjs +8 -0
  13. package/ci/vitest-no-worker-init-setup.mjs +13 -13
  14. package/ci/vitest-no-worker-init-v5-setup.mjs +4 -0
  15. package/index.d.ts +128 -26
  16. package/package.json +22 -19
  17. package/packages/datadog-esbuild/index.js +3 -1
  18. package/packages/datadog-instrumentations/src/bunyan.js +4 -2
  19. package/packages/datadog-instrumentations/src/cypress-config.js +19 -17
  20. package/packages/datadog-instrumentations/src/fs.js +24 -20
  21. package/packages/datadog-instrumentations/src/google-cloud-vertexai.js +2 -2
  22. package/packages/datadog-instrumentations/src/graphql.js +16 -16
  23. package/packages/datadog-instrumentations/src/helpers/bunyan.js +12 -3
  24. package/packages/datadog-instrumentations/src/helpers/graphql-jit-runtime.js +504 -0
  25. package/packages/datadog-instrumentations/src/helpers/hooks.js +2 -0
  26. package/packages/datadog-instrumentations/src/helpers/pool-acquire.js +266 -0
  27. package/packages/datadog-instrumentations/src/helpers/rewriter/compiler.js +1 -2
  28. package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +95 -30
  29. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/ai.js +0 -25
  30. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql-jit.js +83 -0
  31. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql.js +85 -1
  32. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/index.js +1 -0
  33. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/mercurius.js +30 -12
  34. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/playwright.js +13 -0
  35. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/webdriverio.js +279 -0
  36. package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +12 -1
  37. package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +562 -27
  38. package/packages/datadog-instrumentations/src/jest.js +165 -38
  39. package/packages/datadog-instrumentations/src/knex.js +76 -0
  40. package/packages/datadog-instrumentations/src/mariadb-bundle.js +1597 -0
  41. package/packages/datadog-instrumentations/src/mariadb.js +13 -0
  42. package/packages/datadog-instrumentations/src/mocha/common.js +59 -2
  43. package/packages/datadog-instrumentations/src/mocha/main.js +25 -15
  44. package/packages/datadog-instrumentations/src/mocha/utils.js +2 -1
  45. package/packages/datadog-instrumentations/src/mocha/webdriverio-protocol.js +98 -0
  46. package/packages/datadog-instrumentations/src/mocha/worker.js +12 -8
  47. package/packages/datadog-instrumentations/src/net.js +14 -17
  48. package/packages/datadog-instrumentations/src/next.js +212 -62
  49. package/packages/datadog-instrumentations/src/openai.js +42 -40
  50. package/packages/datadog-instrumentations/src/pg.js +15 -0
  51. package/packages/datadog-instrumentations/src/pino.js +15 -4
  52. package/packages/datadog-instrumentations/src/playwright.js +137 -27
  53. package/packages/datadog-instrumentations/src/rum-browser-scripts.js +40 -0
  54. package/packages/datadog-instrumentations/src/sequelize.js +94 -2
  55. package/packages/datadog-instrumentations/src/undici.js +53 -4
  56. package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +44 -7
  57. package/packages/datadog-instrumentations/src/vitest-main.js +92 -9
  58. package/packages/datadog-instrumentations/src/vitest-worker.js +82 -14
  59. package/packages/datadog-instrumentations/src/webdriverio.js +986 -1
  60. package/packages/datadog-instrumentations/src/winston.js +6 -3
  61. package/packages/datadog-plugin-amqp10/src/consumer.js +3 -1
  62. package/packages/datadog-plugin-amqp10/src/producer.js +3 -1
  63. package/packages/datadog-plugin-amqp10/src/util.js +2 -1
  64. package/packages/datadog-plugin-avsc/src/schema_iterator.js +6 -1
  65. package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/utils.js +16 -5
  66. package/packages/datadog-plugin-cassandra-driver/src/index.js +8 -3
  67. package/packages/datadog-plugin-cucumber/src/index.js +0 -2
  68. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +262 -48
  69. package/packages/datadog-plugin-cypress/src/support.js +1 -0
  70. package/packages/datadog-plugin-google-cloud-pubsub/src/client.js +4 -1
  71. package/packages/datadog-plugin-graphql/src/execute.js +998 -196
  72. package/packages/datadog-plugin-graphql/src/index.js +27 -7
  73. package/packages/datadog-plugin-graphql/src/jit.js +136 -0
  74. package/packages/datadog-plugin-graphql/src/request.js +18 -27
  75. package/packages/datadog-plugin-graphql/src/resolve-error.js +108 -0
  76. package/packages/datadog-plugin-graphql/src/tools/signature.js +1 -2
  77. package/packages/datadog-plugin-graphql/src/tools/transforms.js +45 -3
  78. package/packages/datadog-plugin-graphql/src/utils.js +208 -120
  79. package/packages/datadog-plugin-graphql/src/validate.js +10 -23
  80. package/packages/datadog-plugin-http/src/client.js +2 -15
  81. package/packages/datadog-plugin-http2/src/client.js +2 -15
  82. package/packages/datadog-plugin-jest/src/index.js +0 -6
  83. package/packages/datadog-plugin-langchain/src/tracing.js +7 -0
  84. package/packages/datadog-plugin-mocha/src/index.js +403 -75
  85. package/packages/datadog-plugin-mongodb-core/src/query.js +6 -0
  86. package/packages/datadog-plugin-mysql/src/index.js +41 -15
  87. package/packages/datadog-plugin-net/src/tcp.js +3 -1
  88. package/packages/datadog-plugin-next/src/index.js +63 -29
  89. package/packages/datadog-plugin-openai-agents/src/integration.js +15 -11
  90. package/packages/datadog-plugin-playwright/src/index.js +176 -28
  91. package/packages/datadog-plugin-undici/src/index.js +29 -56
  92. package/packages/datadog-plugin-vitest/src/index.js +6 -12
  93. package/packages/dd-trace/src/aiguard/evaluation.js +96 -21
  94. package/packages/dd-trace/src/aiguard/integrations/vercel-ai.js +2 -3
  95. package/packages/dd-trace/src/aiguard/messages/anthropic.js +29 -10
  96. package/packages/dd-trace/src/aiguard/messages/openai.js +8 -1
  97. package/packages/dd-trace/src/aiguard/messages/vercel-ai.js +20 -6
  98. package/packages/dd-trace/src/aiguard/noop.js +9 -1
  99. package/packages/dd-trace/src/aiguard/redaction.js +183 -0
  100. package/packages/dd-trace/src/aiguard/sdk.js +7 -2
  101. package/packages/dd-trace/src/aiguard/tags.js +2 -0
  102. package/packages/dd-trace/src/appsec/api_security/index.js +23 -6
  103. package/packages/dd-trace/src/appsec/api_security/sampler.js +99 -40
  104. package/packages/dd-trace/src/appsec/graphql.js +6 -2
  105. package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +3 -3
  106. package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +2 -1
  107. package/packages/dd-trace/src/appsec/iast/telemetry/span-tags.js +8 -2
  108. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/sql-sensitive-analyzer.js +11 -36
  109. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/url-sensitive-analyzer.js +1 -1
  110. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/utils.js +10 -9
  111. package/packages/dd-trace/src/appsec/lambda.js +44 -26
  112. package/packages/dd-trace/src/appsec/rule_manager.js +2 -0
  113. package/packages/dd-trace/src/ci-visibility/encode/json-encoder.js +32 -2
  114. package/packages/dd-trace/src/ci-visibility/exporters/agent-proxy/index.js +8 -8
  115. package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +6 -4
  116. package/packages/dd-trace/src/ci-visibility/exporters/agentless/di-logs-writer.js +20 -4
  117. package/packages/dd-trace/src/ci-visibility/exporters/agentless/request-tracker.js +7 -150
  118. package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +7 -6
  119. package/packages/dd-trace/src/ci-visibility/exporters/agents.js +54 -0
  120. package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/writer.js +1 -2
  121. package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +397 -234
  122. package/packages/dd-trace/src/ci-visibility/exporters/limits.js +9 -0
  123. package/packages/dd-trace/src/ci-visibility/exporters/request.js +323 -31
  124. package/packages/dd-trace/src/ci-visibility/exporters/settings-cache-key.js +42 -0
  125. package/packages/dd-trace/src/ci-visibility/final-flush.js +21 -0
  126. package/packages/dd-trace/src/ci-visibility/requests/fs-cache.js +57 -18
  127. package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +0 -3
  128. package/packages/dd-trace/src/ci-visibility/requests/upload-test-screenshot.js +164 -71
  129. package/packages/dd-trace/src/ci-visibility/requests/video-request.js +176 -0
  130. package/packages/dd-trace/src/ci-visibility/telemetry.js +10 -7
  131. package/packages/dd-trace/src/ci-visibility/test-video.js +61 -0
  132. package/packages/dd-trace/src/config/generated-config-types.d.ts +10 -0
  133. package/packages/dd-trace/src/config/index.js +75 -14
  134. package/packages/dd-trace/src/config/parsers.js +11 -1
  135. package/packages/dd-trace/src/config/stable.js +3 -3
  136. package/packages/dd-trace/src/config/supported-configurations.json +47 -2
  137. package/packages/dd-trace/src/crashtracking/crashtracker.js +82 -18
  138. package/packages/dd-trace/src/debugger/config.js +12 -1
  139. package/packages/dd-trace/src/debugger/constants.js +1 -0
  140. package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +2 -1
  141. package/packages/dd-trace/src/debugger/devtools_client/request-options.js +33 -0
  142. package/packages/dd-trace/src/debugger/devtools_client/send.js +7 -39
  143. package/packages/dd-trace/src/debugger/devtools_client/status.js +11 -6
  144. package/packages/dd-trace/src/debugger/devtools_client/tags.js +41 -0
  145. package/packages/dd-trace/src/debugger/index.js +23 -3
  146. package/packages/dd-trace/src/dogstatsd.js +532 -71
  147. package/packages/dd-trace/src/encode/0.4-cross-payload.js +170 -0
  148. package/packages/dd-trace/src/encode/0.4.js +5 -5
  149. package/packages/dd-trace/src/encode/agentless-ci-visibility.js +9 -8
  150. package/packages/dd-trace/src/evp_proxy/direct.js +27 -23
  151. package/packages/dd-trace/src/exporters/agent/index.js +24 -3
  152. package/packages/dd-trace/src/exporters/agent/writer.js +28 -11
  153. package/packages/dd-trace/src/exporters/agentless/index.js +7 -9
  154. package/packages/dd-trace/src/exporters/agentless/writer.js +100 -118
  155. package/packages/dd-trace/src/exporters/common/agents.js +28 -6
  156. package/packages/dd-trace/src/exporters/common/buffering-exporter.js +2 -2
  157. package/packages/dd-trace/src/exporters/common/final-flush-request-tracker.js +191 -0
  158. package/packages/dd-trace/src/exporters/common/request.js +31 -11
  159. package/packages/dd-trace/src/exporters/common/url.js +40 -1
  160. package/packages/dd-trace/src/exporters/common/writer.js +31 -7
  161. package/packages/dd-trace/src/exporters/span-stats/index.js +23 -4
  162. package/packages/dd-trace/src/external-logger/src/index.js +4 -3
  163. package/packages/dd-trace/src/flush.js +105 -0
  164. package/packages/dd-trace/src/id.js +14 -0
  165. package/packages/dd-trace/src/index.js +5 -2
  166. package/packages/dd-trace/src/llmobs/experiments/client.js +4 -0
  167. package/packages/dd-trace/src/llmobs/experiments/dataset.js +52 -2
  168. package/packages/dd-trace/src/llmobs/experiments/experiment.js +420 -105
  169. package/packages/dd-trace/src/llmobs/experiments/index.js +54 -42
  170. package/packages/dd-trace/src/llmobs/experiments/noop.js +39 -8
  171. package/packages/dd-trace/src/llmobs/experiments/result.js +1 -0
  172. package/packages/dd-trace/src/llmobs/experiments/util.js +21 -0
  173. package/packages/dd-trace/src/llmobs/index.js +111 -48
  174. package/packages/dd-trace/src/llmobs/noop.js +2 -1
  175. package/packages/dd-trace/src/llmobs/plugins/ai/ddTelemetry.js +22 -71
  176. package/packages/dd-trace/src/llmobs/plugins/ai/vercelTelemetry.js +23 -13
  177. package/packages/dd-trace/src/llmobs/plugins/anthropic/util.js +8 -4
  178. package/packages/dd-trace/src/llmobs/plugins/claude-agent-sdk/index.js +6 -3
  179. package/packages/dd-trace/src/llmobs/plugins/langchain/index.js +7 -0
  180. package/packages/dd-trace/src/llmobs/plugins/openai/utils.js +13 -6
  181. package/packages/dd-trace/src/llmobs/plugins/openai-agents/utils.js +5 -7
  182. package/packages/dd-trace/src/llmobs/util.js +0 -33
  183. package/packages/dd-trace/src/llmobs/writers/base.js +106 -53
  184. package/packages/dd-trace/src/log/index.js +7 -1
  185. package/packages/dd-trace/src/log-submission/log-submission-plugin.js +249 -0
  186. package/packages/dd-trace/src/noop/span.js +5 -0
  187. package/packages/dd-trace/src/openfeature/writers/base.js +14 -12
  188. package/packages/dd-trace/src/openfeature/writers/exposures.js +8 -1
  189. package/packages/dd-trace/src/openfeature/writers/util.js +1 -1
  190. package/packages/dd-trace/src/opentelemetry/logs/batch_log_processor.js +45 -3
  191. package/packages/dd-trace/src/opentelemetry/logs/index.js +9 -25
  192. package/packages/dd-trace/src/opentelemetry/logs/logger_provider.js +7 -4
  193. package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +14 -4
  194. package/packages/dd-trace/src/opentelemetry/metrics/index.js +18 -23
  195. package/packages/dd-trace/src/opentelemetry/metrics/meter_provider.js +8 -0
  196. package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +18 -6
  197. package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_exporter.js +14 -2
  198. package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +25 -5
  199. package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +61 -25
  200. package/packages/dd-trace/src/opentelemetry/otlp/otlp_transformer_base.js +19 -4
  201. package/packages/dd-trace/src/opentelemetry/resource-attributes.js +55 -0
  202. package/packages/dd-trace/src/opentelemetry/trace/index.js +6 -1
  203. package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +10 -0
  204. package/packages/dd-trace/src/opentelemetry/tracer.js +26 -2
  205. package/packages/dd-trace/src/opentracing/propagation/text_map.js +494 -351
  206. package/packages/dd-trace/src/opentracing/span.js +28 -0
  207. package/packages/dd-trace/src/otel-thread-ctx.js +23 -5
  208. package/packages/dd-trace/src/payload-tagging/index.js +2 -1
  209. package/packages/dd-trace/src/plugin_manager.js +2 -0
  210. package/packages/dd-trace/src/plugins/ci_plugin.js +1 -6
  211. package/packages/dd-trace/src/plugins/tracing.js +12 -10
  212. package/packages/dd-trace/src/plugins/util/ci.js +3 -1
  213. package/packages/dd-trace/src/plugins/util/inferred_proxy.js +16 -15
  214. package/packages/dd-trace/src/plugins/util/status-validator.js +98 -0
  215. package/packages/dd-trace/src/plugins/util/test.js +157 -41
  216. package/packages/dd-trace/src/plugins/util/url.js +2 -2
  217. package/packages/dd-trace/src/plugins/util/web.js +6 -74
  218. package/packages/dd-trace/src/profiling/config.js +1 -0
  219. package/packages/dd-trace/src/profiling/oom.js +11 -5
  220. package/packages/dd-trace/src/profiling/profiler.js +30 -13
  221. package/packages/dd-trace/src/profiling/profilers/events.js +3 -3
  222. package/packages/dd-trace/src/profiling/profilers/space.js +38 -11
  223. package/packages/dd-trace/src/profiling/profilers/wall.js +14 -14
  224. package/packages/dd-trace/src/profiling/webspan-utils.js +7 -4
  225. package/packages/dd-trace/src/proxy.js +108 -10
  226. package/packages/dd-trace/src/remote_config/index.js +319 -101
  227. package/packages/dd-trace/src/remote_config/scheduler.js +37 -12
  228. package/packages/dd-trace/src/runtime_metrics/client.js +37 -8
  229. package/packages/dd-trace/src/runtime_metrics/index.js +5 -0
  230. package/packages/dd-trace/src/runtime_metrics/otlp_runtime_metrics.js +10 -1
  231. package/packages/dd-trace/src/runtime_metrics/runtime_metrics.js +22 -7
  232. package/packages/dd-trace/src/sampling_rule.js +36 -9
  233. package/packages/dd-trace/src/serverless/telemetry-delivery-tracker.js +51 -0
  234. package/packages/dd-trace/src/serverless/vercel.js +155 -0
  235. package/packages/dd-trace/src/serverless.js +45 -21
  236. package/packages/dd-trace/src/service-naming/schemas/util.js +1 -1
  237. package/packages/dd-trace/src/span_stats.js +64 -31
  238. package/packages/dd-trace/src/startup-log.js +3 -2
  239. package/packages/dd-trace/src/telemetry/agentless-url.js +28 -0
  240. package/packages/dd-trace/src/telemetry/send-data.js +18 -16
  241. package/packages/dd-trace/src/telemetry/session-propagation.js +3 -2
  242. package/packages/dd-trace/src/tracer.js +26 -5
  243. package/packages/dd-trace/src/tracer_metadata.js +11 -3
  244. package/packages/dd-trace/src/web-tags-cache.js +67 -13
  245. package/vendor/dist/@datadog/openfeature-node-server/index.js +1 -1
  246. package/vendor/dist/@datadog/sketches-js/index.js +1 -1
  247. package/vendor/dist/protobufjs/index.js +1 -1
  248. package/vendor/dist/protobufjs/minimal/index.js +1 -1
  249. package/packages/datadog-instrumentations/src/playwright-browser-scripts.js +0 -27
  250. package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +0 -53
  251. package/packages/dd-trace/src/encode/agentless-json.js +0 -209
@@ -1,7 +1,9 @@
1
1
  "component","origin","license","copyright"
2
2
  "@apm-js-collab/code-transformer","https://github.com/nodejs/orchestrion-js","['Apache-2.0']","['nodejs']"
3
3
  "@datadog/flagging-core","https://github.com/DataDog/openfeature-js-client","['Apache-2.0']","['DataDog']"
4
- "@datadog/libdatadog","https://github.com/DataDog/libdatadog-nodejs","['Apache-2.0']","['Datadog Inc.']"
4
+ "@datadog/libdatadog","https://github.com/DataDog/libdatadog-nodejs","['Apache-2.0']","['DataDog']"
5
+ "@datadog/libdatadog-extras","https://github.com/DataDog/libdatadog-nodejs","['Apache-2.0']","['Datadog Inc.']"
6
+ "@datadog/libdatadog-wasm","https://github.com/DataDog/libdatadog-nodejs","['Apache-2.0']","['DataDog']"
5
7
  "@datadog/native-appsec","https://github.com/DataDog/dd-native-appsec-js","['Apache-2.0']","['Datadog Inc.']"
6
8
  "@datadog/native-iast-taint-tracking","https://github.com/DataDog/dd-native-iast-taint-tracking-js","['Apache-2.0']","['Datadog Inc.']"
7
9
  "@datadog/native-metrics","https://github.com/DataDog/dd-native-metrics-js","['Apache-2.0']","['Datadog Inc.']"
package/ci/init.js CHANGED
@@ -7,7 +7,7 @@ const { getEnvironmentVariable, getValueFromEnvSources } = require('../packages/
7
7
  const { isFalse, isTrue } = require('../packages/dd-trace/src/util')
8
8
 
9
9
  const PACKAGE_MANAGERS = ['npm', 'yarn', 'pnpm']
10
- const DEFAULT_FLUSH_INTERVAL = 5000
10
+ const DEFAULT_FLUSH_INTERVAL = 10_000
11
11
  const JEST_FLUSH_INTERVAL = 0
12
12
  const VITEST_NO_WORKER_INIT_ACTIVE_ENV = 'DD_TEST_OPT_VITEST_NO_WORKER_INIT_ACTIVE'
13
13
  const VALIDATION_MODE_ENV = '_DD_TEST_OPTIMIZATION_VALIDATION_MODE'
@@ -63,7 +63,9 @@ if (isValidationModeRequested && !isValidationMode) {
63
63
  let shouldInit = isValidationModeRequested
64
64
  ? isValidationMode && !isFalse(getEnvironmentVariable('DD_CIVISIBILITY_ENABLED'))
65
65
  : getValueFromEnvSources('DD_CIVISIBILITY_ENABLED', true) !== false
66
- const isAgentlessEnabled = getValueFromEnvSources('DD_CIVISIBILITY_AGENTLESS_ENABLED')
66
+ const isGlobalAgentlessEnabled = getValueFromEnvSources('DD_AGENTLESS_ENABLED')
67
+ const isAgentlessEnabled = isGlobalAgentlessEnabled ||
68
+ getValueFromEnvSources('DD_CIVISIBILITY_AGENTLESS_ENABLED')
67
69
 
68
70
  if (!isTestWorker && isPackageManager()) {
69
71
  log.debug('dd-trace is not initialized in a package manager.')
@@ -85,8 +87,11 @@ if (isTestWorker) {
85
87
  exporter: 'datadog',
86
88
  }
87
89
  } else {
90
+ const configurationName = isGlobalAgentlessEnabled
91
+ ? 'DD_AGENTLESS_ENABLED'
92
+ : 'DD_CIVISIBILITY_AGENTLESS_ENABLED'
88
93
  console.error(
89
- 'DD_CIVISIBILITY_AGENTLESS_ENABLED is set, but neither ' +
94
+ `${configurationName} is set, but neither ` +
90
95
  'DD_API_KEY nor DATADOG_API_KEY are set in your environment, so ' +
91
96
  'dd-trace will not be initialized.'
92
97
  )
@@ -146,7 +146,7 @@ function getPackageScriptInvocation (command) {
146
146
  const literalPrefix = parseLiteralEnvironmentPrefix(command)
147
147
  const source = command.slice(literalPrefix.length).trim()
148
148
  .replace(/^(?:c8|nyc)(?:\.cmd)?\s+/, '')
149
- const match = /^(bun|npm(?:\.cmd)?|pnpm(?:\.cmd)?|yarn(?:pkg)?(?:\.cmd)?)\s+(?:(run|run-script)\s+)?([\w:-]+)(?:\s+(.+))?$/
149
+ const match = /^(bun|npm(?:\.cmd)?|pnpm(?:\.cmd)?|yarn(?:pkg)?(?:\.cmd)?)\s+(?:(run|run-script)\s+)?([\w:-]+)(?:\s+(\S.*))?$/
150
150
  .exec(source)
151
151
  if (!match) return
152
152
 
@@ -155,7 +155,7 @@ function getPackageScriptInvocation (command) {
155
155
  if (manager === 'bun' && match[2] !== 'run') return
156
156
  if (!match[2] && RESERVED_PACKAGE_MANAGER_COMMANDS[manager]?.has(match[3])) return
157
157
  const args = match[4]?.trim()
158
- const separatedArguments = args ? /^--(?:\s+(.+))?$/.exec(args) : undefined
158
+ const separatedArguments = args ? /^--(?:\s+(\S.*))?$/.exec(args) : undefined
159
159
  if (['npm', 'pnpm'].includes(manager) && args && !separatedArguments) return
160
160
  const scriptArguments = ['npm', 'pnpm'].includes(manager) ? separatedArguments?.[1]?.trim() : args
161
161
  if (scriptArguments && !splitLiteralAndChain(scriptArguments)) return
@@ -54,12 +54,12 @@ function getConfiguredTransport (framework) {
54
54
  }
55
55
 
56
56
  function getCiLocation (ciWiring) {
57
- const parts = []
58
- if (ciWiring.configFile) parts.push(`configuration ${formatPath(ciWiring.configFile)}`)
59
- if (ciWiring.workflow) parts.push(`workflow ${JSON.stringify(String(ciWiring.workflow))}`)
60
- if (ciWiring.job) parts.push(`job ${JSON.stringify(String(ciWiring.job))}`)
61
- if (ciWiring.step) parts.push(`step ${JSON.stringify(String(ciWiring.step))}`)
62
- return parts.length > 0 ? parts.join(', ') : 'the selected CI test step'
57
+ let location = ''
58
+ if (ciWiring.configFile) location += `configuration ${formatPath(ciWiring.configFile)}`
59
+ if (ciWiring.workflow) location += `${location ? ', ' : ''}workflow ${JSON.stringify(String(ciWiring.workflow))}`
60
+ if (ciWiring.job) location += `${location ? ', ' : ''}job ${JSON.stringify(String(ciWiring.job))}`
61
+ if (ciWiring.step) location += `${location ? ', ' : ''}step ${JSON.stringify(String(ciWiring.step))}`
62
+ return location || 'the selected CI test step'
63
63
  }
64
64
 
65
65
  function formatPath (filename) {
@@ -16,13 +16,15 @@ const MODULE_OR_TRANSFORM_PATTERN =
16
16
  /\b(?:Cannot find (?:module|package)|ERR_MODULE_NOT_FOUND|MODULE_NOT_FOUND|ERR_PACKAGE_PATH_NOT_EXPORTED|Package subpath\b[\s\S]+\bnot defined by "exports"|Could not resolve|transform failed)\b/i
17
17
  const BUILD_ARTIFACT_PATH_PATTERN = String.raw`(?:^|[\\/])(?:build|dist|generated)(?:[\\/]|['"])`
18
18
  const MISSING_ARTIFACT_MESSAGE_PATTERN =
19
- '(?:Cannot find (?:module|package)|ERR_MODULE_NOT_FOUND|MODULE_NOT_FOUND|ENOENT|no such file or directory|' +
20
- 'is not found|does not exist|could not be found)'
19
+ /Cannot find (?:module|package)|ERR_MODULE_NOT_FOUND|MODULE_NOT_FOUND|ENOENT|no such file or directory|is not found|does not exist|could not be found/
20
+ /* eslint-disable regexp/no-useless-non-capturing-group, regexp/prefer-character-class --
21
+ * The interpolated message fragment contains alternatives and must stay grouped on both sides of the path. */
21
22
  const BUILD_ARTIFACT_MISSING_PATTERN = new RegExp(
22
- String.raw`(?:${MISSING_ARTIFACT_MESSAGE_PATTERN}[^\r\n]{0,500}${BUILD_ARTIFACT_PATH_PATTERN}|` +
23
- String.raw`${BUILD_ARTIFACT_PATH_PATTERN}[^\r\n]{0,500}${MISSING_ARTIFACT_MESSAGE_PATTERN})`,
23
+ String.raw`(?:(?:${MISSING_ARTIFACT_MESSAGE_PATTERN.source})[^\r\n]{0,500}${BUILD_ARTIFACT_PATH_PATTERN}|` +
24
+ String.raw`${BUILD_ARTIFACT_PATH_PATTERN}[^\r\n]{0,500}(?:${MISSING_ARTIFACT_MESSAGE_PATTERN.source}))`,
24
25
  'im'
25
26
  )
27
+ /* eslint-enable regexp/no-useless-non-capturing-group, regexp/prefer-character-class */
26
28
  const FILE_PATH_REFERENCE_PATTERN = /(?:^|[\s('"`])((?:\.{1,2}[\\/]|[\\/]|[A-Za-z]:[\\/])[^'"`\s),;]*)/g
27
29
  const CUCUMBER_CONFIG_OPTION_UNSUPPORTED_PATTERN = /unknown option ['"]--config['"]/i
28
30
  const CYPRESS_BINARY_PATTERN =
@@ -41,7 +43,7 @@ const PUPPETEER_BROWSER_PATTERN =
41
43
  const PUPPETEER_BROWSER_ABORT_PATTERN =
42
44
  /Failed to launch the browser process[\s\S]*?(?:signal=SIGABRT|Received signal 6|Abort trap: 6)/i
43
45
  const CUCUMBER_BROWSER_FAILURE_PATTERN =
44
- /(?:(?:browser|puppeteer|playwright|webdriver)[^\r\n]{0,160}\b(?:aborted|closed|crashed|failed|terminated|unavailable)\b|(?:Failed|Unable) to (?:connect to|launch|start) (?:the )?browser)/i
46
+ /(?:browser|puppeteer|playwright|webdriver)[^\r\n]{1,160}\b(?:aborted|closed|crashed|failed|terminated|unavailable)\b|(?:Failed|Unable) to (?:connect to|launch|start) (?:the )?browser/i
45
47
  const VITEST_BROWSER_PROVIDER_PATTERN =
46
48
  /Cannot find (?:module|package).*@vitest\/browser|@vitest\/browser-[^\s'"].*(?:missing|not (?:found|installed))/i
47
49
  const RUNNER_COMMAND_NOT_FOUND_PATTERN =
@@ -478,7 +478,7 @@ function getYamlStringProfileDefinitions (source) {
478
478
  const definitions = new Map()
479
479
  for (const line of source.split(/\r?\n/)) {
480
480
  if (!line.trim() || /^\s*#/.test(line)) continue
481
- const match = /^([A-Za-z0-9_-]+):\s*(.*)$/.exec(line)
481
+ const match = /^([A-Za-z0-9_-]+):(.*)$/.exec(line)
482
482
  const definition = match && !/^\s/.test(line) ? getYamlStringProfileDefinition(match[2]) : undefined
483
483
  if (definition === undefined) {
484
484
  throw new Error('YAML profiles must be literal one-line command strings')
@@ -40,20 +40,18 @@ function getTestExtension (filename) {
40
40
  * @returns {string} canonical generated Cypress source
41
41
  */
42
42
  function getGeneratedTestContent ({ scenarioId, testName }) {
43
- const lines = []
43
+ let content = ''
44
44
  if (scenarioId === 'atr-fail-once') {
45
- lines.push('let attempt = 0', '')
45
+ content = 'let attempt = 0\n\n'
46
46
  }
47
- lines.push(
48
- "describe('dd-test-optimization-validation', () => {",
49
- ` it(${JSON.stringify(testName)}, () => {`,
50
- scenarioId === 'atr-fail-once'
51
- ? ' expect(attempt++).to.equal(1)'
52
- : ' expect(true).to.equal(true)',
53
- ' })',
47
+ content += "describe('dd-test-optimization-validation', () => {\n" +
48
+ ` it(${JSON.stringify(testName)}, () => {\n` +
49
+ (scenarioId === 'atr-fail-once'
50
+ ? ' expect(attempt++).to.equal(1)\n'
51
+ : ' expect(true).to.equal(true)\n') +
52
+ ' })\n' +
54
53
  '})'
55
- )
56
- return lines.join('\n')
54
+ return content
57
55
  }
58
56
 
59
57
  /**
@@ -213,7 +213,7 @@ function getProjectObject (source, nameIndex, workspaceConfig) {
213
213
  function isStandaloneProjectObject (source, range) {
214
214
  const before = maskJavaScriptNonCode(source.slice(0, range.start))
215
215
  const after = maskJavaScriptNonCode(source.slice(range.end + 1))
216
- return PROJECT_CALL_PATTERN.test(before) && /^\s*,?\s*\)[\s;]*$/.test(after)
216
+ return PROJECT_CALL_PATTERN.test(before) && /^\s*(?:,\s*)?\)[\s;]*$/.test(after)
217
217
  }
218
218
 
219
219
  /**
@@ -259,7 +259,7 @@ function isExportedConfigObject (source, range) {
259
259
  const before = maskJavaScriptNonCode(source.slice(0, range.start))
260
260
  const after = maskJavaScriptNonCode(source.slice(range.end + 1))
261
261
  return (DIRECT_EXPORT_PATTERN.test(before) && /^[\s;]*$/.test(after)) ||
262
- (CONFIG_CALL_PATTERN.test(before) && /^\s*,?\s*\)[\s;]*$/.test(after))
262
+ (CONFIG_CALL_PATTERN.test(before) && /^\s*(?:,\s*)?\)[\s;]*$/.test(after))
263
263
  }
264
264
 
265
265
  /**
@@ -276,7 +276,7 @@ function isWorkspaceProjectEntry (source, range) {
276
276
  const before = maskJavaScriptNonCode(source.slice(0, workspaceArray.start))
277
277
  const after = maskJavaScriptNonCode(source.slice(workspaceArray.end + 1))
278
278
  return (DIRECT_EXPORT_PATTERN.test(before) && /^[\s;]*$/.test(after)) ||
279
- (WORKSPACE_ARRAY_CALL_PATTERN.test(before) && /^\s*,?\s*\)[\s;]*$/.test(after))
279
+ (WORKSPACE_ARRAY_CALL_PATTERN.test(before) && /^\s*(?:,\s*)?\)[\s;]*$/.test(after))
280
280
  }
281
281
 
282
282
  /**
@@ -88,7 +88,7 @@ function getFailureDetail (result) {
88
88
  }
89
89
 
90
90
  function sanitizeLine (value) {
91
- return sanitizeString(String(value)).replaceAll(/\p{Cc}+/gu, ' ').trim().slice(0, 1000).replace(/[.]+$/, '')
91
+ return sanitizeString(String(value)).replaceAll(/\p{Cc}+/gu, ' ').trim().slice(0, 1000).replace(/\.+$/, '')
92
92
  }
93
93
 
94
94
  module.exports = { checkInstalledPackage, getInstalledPackageFailure }
@@ -273,11 +273,13 @@ function getCiVerdict (results) {
273
273
  if (ci.evidence?.reasonCode === 'remote-ci-command-unavailable') {
274
274
  return 'INCOMPLETE — test execution is delegated to unavailable remote CI code'
275
275
  }
276
- const facts = []
277
- if (ci.evidence?.ciFacts?.initialization?.status === 'missing') facts.push('initialization not visible')
278
- if (ci.evidence?.ciFacts?.transport?.status === 'missing') facts.push('transport not visible')
279
- if (ci.evidence?.ciFacts?.runnerInvocation?.status === 'unresolved') facts.push('runner path unresolved')
280
- return `INCOMPLETE${facts.length > 0 ? ` — ${facts.join('; ')}` : ''}`
276
+ let facts = ''
277
+ if (ci.evidence?.ciFacts?.initialization?.status === 'missing') facts = 'initialization not visible'
278
+ if (ci.evidence?.ciFacts?.transport?.status === 'missing') facts += `${facts ? '; ' : ''}transport not visible`
279
+ if (ci.evidence?.ciFacts?.runnerInvocation?.status === 'unresolved') {
280
+ facts += `${facts ? '; ' : ''}runner path unresolved`
281
+ }
282
+ return `INCOMPLETE${facts ? ` — ${facts}` : ''}`
281
283
  }
282
284
 
283
285
  function getPrerequisiteVerdict (results) {
@@ -184,12 +184,13 @@ function runCiWiring ({ manifest, framework, projectFileSources }) {
184
184
  }
185
185
 
186
186
  if (resolution.status !== 'confirmed') {
187
- const visibleFacts = []
187
+ let visibleFacts = ''
188
188
  if (initialization.status === 'missing') {
189
- visibleFacts.push('The selected job has no visible dd-trace/ci/init preload.')
189
+ visibleFacts = 'The selected job has no visible dd-trace/ci/init preload.'
190
190
  }
191
191
  if (ciFacts.transport.status === 'missing') {
192
- visibleFacts.push('The recorded review found no visible Datadog Agent or agentless reporting transport.')
192
+ if (visibleFacts) visibleFacts += ' '
193
+ visibleFacts += 'The recorded review found no visible Datadog Agent or agentless reporting transport.'
193
194
  }
194
195
  const recommendation = /working directory/i.test(resolution.reason)
195
196
  ? 'Keep the CI job\'s actual working directory. Resolve the repository-root wrapper to the selected test ' +
@@ -199,7 +200,7 @@ function runCiWiring ({ manifest, framework, projectFileSources }) {
199
200
  return getIncomplete(
200
201
  framework,
201
202
  'The CI audit remains incomplete because the selected command could not be resolved to the ' +
202
- `${framework.framework} runner: ${resolution.reason}. ${visibleFacts.join(' ')}`.trim(),
203
+ `${framework.framework} runner: ${resolution.reason}. ${visibleFacts}`.trim(),
203
204
  {
204
205
  ...evidence,
205
206
  recommendation,
@@ -0,0 +1,8 @@
1
+ try {
2
+ // Vitest does not expose setFn from its public setup API; keep this optional for strict installers.
3
+ const vitestRunner = await import('@vitest/runner')
4
+ globalThis[Symbol.for('dd-trace.vitest.set-fn')] = vitestRunner.setFn
5
+ } catch {}
6
+ globalThis[Symbol.for('dd-trace.vitest.browser-context-importer')] = () => import('@vitest/browser/context')
7
+
8
+ await import('./vitest-no-worker-init-setup.mjs')
@@ -23,14 +23,9 @@ const quarantinedTests = providedContext.quarantinedTests || {}
23
23
  const isRumCorrelationEnabled = providedContext.isRumCorrelationEnabled !== false
24
24
  const rumTestExecutionIdCookieName = providedContext.rumTestExecutionIdCookieName
25
25
  const testPropertiesByFilepath = providedContext.testPropertiesByFilepath || {}
26
- let setVitestTaskFn
27
- if (isNoWorkerInitActive) {
28
- try {
29
- // Vitest does not expose setFn from the public setup API; keep this optional for strict installers.
30
- const vitestRunner = await import('@vitest/runner')
31
- setVitestTaskFn = vitestRunner.setFn
32
- } catch {}
33
- }
26
+ const setVitestTaskFn = globalThis[Symbol.for('dd-trace.vitest.set-fn')]
27
+ const skipVitestTask = globalThis[Symbol.for('dd-trace.vitest.skip-task')]
28
+ const importVitestBrowserContext = globalThis[Symbol.for('dd-trace.vitest.browser-context-importer')]
34
29
  const earlyFlakeDetectionRetriesByTask = new WeakMap()
35
30
  const earlyFlakeDetectionSkippedResults = new WeakMap()
36
31
  const earlyFlakeDetectionStartByTask = new WeakMap()
@@ -62,7 +57,7 @@ if (typeof globalThis.process?.uptime === 'function') {
62
57
  async function requestBrowserEfdSuiteAdmission (testSuite, hasNewTest) {
63
58
  try {
64
59
  if (!browserCommands) {
65
- const vitestBrowser = await import('@vitest/browser/context')
60
+ const vitestBrowser = await importVitestBrowserContext()
66
61
  browserCommands = vitestBrowser.commands
67
62
  }
68
63
  return await browserCommands[efdSuiteAdmissionBrowserCommand](testSuite, hasNewTest) === true
@@ -100,7 +95,7 @@ if (isNoWorkerInitActive) {
100
95
  } else if (isAttemptToFixTest && attemptIndex > 0) {
101
96
  task.result.state = 'run'
102
97
  } else if (isEarlyFlakeDetectionTestAttempt) {
103
- const isSkippedRepeat = prepareEarlyFlakeDetectionAttempt(task, attemptIndex)
98
+ const isSkippedRepeat = prepareEarlyFlakeDetectionAttempt(task, attemptIndex, skip)
104
99
  if (!isSkippedRepeat && attemptIndex > 0) {
105
100
  task.result.state = 'run'
106
101
  }
@@ -624,7 +619,7 @@ function getPreviousErrorCount (errorCounts, repeatCount) {
624
619
  return 0
625
620
  }
626
621
 
627
- function prepareEarlyFlakeDetectionAttempt (task, attemptIndex) {
622
+ function prepareEarlyFlakeDetectionAttempt (task, attemptIndex, skip) {
628
623
  if (attemptIndex === 0) {
629
624
  earlyFlakeDetectionStartByTask.set(task, now())
630
625
  return false
@@ -646,7 +641,8 @@ function prepareEarlyFlakeDetectionAttempt (task, attemptIndex) {
646
641
  return false
647
642
  }
648
643
 
649
- if (!canReplaceVitestTaskFn()) {
644
+ const canReplaceTaskFn = canReplaceVitestTaskFn()
645
+ if (!canReplaceTaskFn && typeof skipVitestTask !== 'function') {
650
646
  earlyFlakeDetectionStartByTask.set(task, now())
651
647
  return false
652
648
  }
@@ -658,7 +654,11 @@ function prepareEarlyFlakeDetectionAttempt (task, attemptIndex) {
658
654
  })
659
655
  }
660
656
  task.meta.__ddTestOptEfdSkipCurrentAttempt = true
661
- replaceVitestTaskFn(task, noopTest)
657
+ if (canReplaceTaskFn) {
658
+ replaceVitestTaskFn(task, noopTest)
659
+ } else {
660
+ skipVitestTask(skip)
661
+ }
662
662
  return true
663
663
  }
664
664
 
@@ -0,0 +1,4 @@
1
+ globalThis[Symbol.for('dd-trace.vitest.browser-context-importer')] = () => import('vitest/browser')
2
+ globalThis[Symbol.for('dd-trace.vitest.skip-task')] = skip => skip('Skipped by Datadog Test Optimization')
3
+
4
+ await import('./vitest-no-worker-init-setup.mjs')
package/index.d.ts CHANGED
@@ -358,6 +358,16 @@ declare namespace tracer {
358
358
  links?: { context: SpanContext, attributes?: Object }[]
359
359
  }
360
360
 
361
+ export interface Exception {
362
+ message: string;
363
+ name?: string;
364
+ stack?: string;
365
+ }
366
+
367
+ export type SpanEventAttributeValue =
368
+ string | number | boolean | Array<string> | Array<number> | Array<boolean>;
369
+ export type SpanEventAttributes = Record<string, SpanEventAttributeValue>;
370
+
361
371
  /**
362
372
  * Span represents a logical unit of work as part of a broader Trace.
363
373
  * Examples of span might include remote procedure calls or a in-process
@@ -368,6 +378,14 @@ declare namespace tracer {
368
378
  export interface Span extends opentracing.Span {
369
379
  context (): SpanContext;
370
380
 
381
+ /**
382
+ * Records an exception as a span event without marking the span as failed.
383
+ *
384
+ * @param exception The exception to record.
385
+ * @param attributes Additional attributes for the exception event.
386
+ */
387
+ recordException (exception: Exception, attributes?: SpanEventAttributes): void;
388
+
371
389
  /**
372
390
  * Causally links another span to the current span
373
391
  *
@@ -859,6 +877,13 @@ declare namespace tracer {
859
877
  * Programmatic configuration takes precedence over the environment variables listed above.
860
878
  */
861
879
  maxMessagesLength?: number,
880
+ /**
881
+ * Whether AI Guard applies backend-provided sensitive-data redaction replacements.
882
+ * @default true
883
+ * @env DD_AI_GUARD_REDACTION_ENABLED
884
+ * Programmatic configuration takes precedence over the environment variables listed above.
885
+ */
886
+ redactionEnabled?: boolean,
862
887
  /**
863
888
  * Max size of the content property set in the meta-struct
864
889
  * @env DD_AI_GUARD_MAX_CONTENT_SIZE
@@ -1818,6 +1843,25 @@ declare namespace tracer {
1818
1843
  };
1819
1844
  }
1820
1845
 
1846
+ /**
1847
+ * A structured content part in an AI Guard message.
1848
+ */
1849
+ export interface ContentPart {
1850
+ type: string;
1851
+ text?: string;
1852
+ image_url?: { url: string };
1853
+ }
1854
+
1855
+ /**
1856
+ * A conversational message whose content is represented by structured parts.
1857
+ */
1858
+ export interface ContentPartsMessage {
1859
+ role: string;
1860
+ content: ContentPart[];
1861
+ tool_call_id?: string;
1862
+ tool_calls?: ToolCall[];
1863
+ }
1864
+
1821
1865
  /**
1822
1866
  * A standard conversational message exchanged with a Large Language Model (LLM).
1823
1867
  */
@@ -1889,10 +1933,25 @@ declare namespace tracer {
1889
1933
 
1890
1934
  export type Message =
1891
1935
  | TextMessage
1936
+ | ContentPartsMessage
1892
1937
  | AssistantTextMessage
1893
1938
  | AssistantToolCallMessage
1894
1939
  | ToolMessage;
1895
1940
 
1941
+ /**
1942
+ * A sensitive data replacement the AI Guard service determined for the evaluated conversation.
1943
+ */
1944
+ export interface RedactionReplacement {
1945
+ /**
1946
+ * Location of the replaced value within the evaluated conversation (e.g. `messages[0].content`).
1947
+ */
1948
+ path: string;
1949
+ /**
1950
+ * The value that replaces the sensitive data found at `path`.
1951
+ */
1952
+ replacement: string;
1953
+ }
1954
+
1896
1955
  /**
1897
1956
  * The result returned by AI Guard after evaluating a conversation.
1898
1957
  */
@@ -1920,6 +1979,16 @@ declare namespace tracer {
1920
1979
  * Sensitive Data Scanner findings from the evaluation.
1921
1980
  */
1922
1981
  sds: Object[];
1982
+ /**
1983
+ * The evaluated conversation, redacted when required by the AI Guard service.
1984
+ * This may contain sensitive data when redaction is disabled or no replacement was applied.
1985
+ */
1986
+ messages: Message[];
1987
+ /**
1988
+ * The replacements the AI Guard service determined for the evaluated conversation, reported whether or not
1989
+ * the tracer applied them. Empty when the service determined no replacement.
1990
+ */
1991
+ redactionReplacements: RedactionReplacement[];
1923
1992
  }
1924
1993
 
1925
1994
  /**
@@ -2317,7 +2386,7 @@ declare namespace tracer {
2317
2386
  * This plugin automatically instruments the
2318
2387
  * [Vercel AI SDK](https://ai-sdk.dev/docs/introduction) module.
2319
2388
  */
2320
- interface ai extends Instrumentation {}
2389
+ interface ai extends Instrumentation, LLMObsIntegration {}
2321
2390
 
2322
2391
  /**
2323
2392
  * This plugin automatically instruments the
@@ -2335,13 +2404,13 @@ declare namespace tracer {
2335
2404
  * This plugin automatically instruments the
2336
2405
  * [@anthropic-ai/claude-agent-sdk](https://www.npmjs.com/package/@anthropic-ai/claude-agent-sdk) module.
2337
2406
  */
2338
- interface claude_agent_sdk extends Instrumentation {}
2407
+ interface claude_agent_sdk extends Instrumentation, LLMObsIntegration {}
2339
2408
 
2340
2409
  /**
2341
2410
  * This plugin automatically instruments the
2342
2411
  * [anthropic](https://www.npmjs.com/package/@anthropic-ai/sdk) module.
2343
2412
  */
2344
- interface anthropic extends Instrumentation {}
2413
+ interface anthropic extends Instrumentation, LLMObsIntegration {}
2345
2414
 
2346
2415
  /**
2347
2416
  * Currently this plugin automatically instruments
@@ -2402,7 +2471,7 @@ declare namespace tracer {
2402
2471
  * This plugin automatically instruments the
2403
2472
  * [aws-sdk](https://github.com/aws/aws-sdk-js) module.
2404
2473
  */
2405
- interface aws_sdk extends Instrumentation {
2474
+ interface aws_sdk extends Instrumentation, LLMObsIntegration {
2406
2475
  /**
2407
2476
  * The service name to be used for this plugin. When a function is used it is called with the AWS
2408
2477
  * request parameters (e.g. `{ TableName }` for DynamoDB, `{ Bucket }` for S3) and its return value
@@ -2637,13 +2706,13 @@ declare namespace tracer {
2637
2706
  * This plugin automatically instruments the
2638
2707
  * [@google-cloud/vertexai](https://github.com/googleapis/nodejs-vertexai) module.
2639
2708
  */
2640
- interface google_cloud_vertexai extends Integration {}
2709
+ interface google_cloud_vertexai extends Integration, LLMObsIntegration {}
2641
2710
 
2642
2711
  /**
2643
2712
  * This plugin automatically instruments the
2644
2713
  * [@google-genai](https://github.com/googleapis/js-genai) module.
2645
2714
  */
2646
- interface google_genai extends Integration {}
2715
+ interface google_genai extends Integration, LLMObsIntegration {}
2647
2716
 
2648
2717
  /** @hidden */
2649
2718
  interface ExecutionArgs {
@@ -3001,7 +3070,7 @@ declare namespace tracer {
3001
3070
  * This plugin automatically instruments the
3002
3071
  * [langgraph](https://github.com/npmjs/package/langgraph) library.
3003
3072
  */
3004
- interface langgraph extends Instrumentation {}
3073
+ interface langgraph extends Instrumentation, LLMObsIntegration {}
3005
3074
 
3006
3075
  /**
3007
3076
  * This plugin automatically instruments the
@@ -3161,13 +3230,13 @@ declare namespace tracer {
3161
3230
  * [DogStatsD](https://docs.datadoghq.com/developers/dogstatsd/?tab=hostagent#setup)
3162
3231
  * in the agent.
3163
3232
  */
3164
- interface openai extends Instrumentation {}
3233
+ interface openai extends Instrumentation, LLMObsIntegration {}
3165
3234
 
3166
3235
  /**
3167
3236
  * This plugin automatically instruments the
3168
3237
  * [@openai/agents](https://www.npmjs.com/package/@openai/agents) library.
3169
3238
  */
3170
- interface openai_agents extends Instrumentation {}
3239
+ interface openai_agents extends Instrumentation, LLMObsIntegration {}
3171
3240
 
3172
3241
  /**
3173
3242
  * This plugin automatically instruments the
@@ -3816,7 +3885,7 @@ declare namespace tracer {
3816
3885
  *
3817
3886
  * @deprecated Enabling LLM Observability via `llmobs.enable()` is deprecated and will be removed in dd-trace@7.0.0. Please instantiate LLM Observability via DD_LLMOBS_ENABLED or `tracer.init({ llmobs: ...options })`.
3818
3887
  */
3819
- enable (options: LLMObsEnableOptions): void,
3888
+ enable (options: LLMObsRuntimeEnableOptions): void,
3820
3889
 
3821
3890
  /**
3822
3891
  * Disable LLM Observability tracing.
@@ -3995,21 +4064,35 @@ declare namespace tracer {
3995
4064
  metadata?: Array<Record<string, any>>
3996
4065
  ) => any | Promise<any>
3997
4066
 
4067
+ interface DatasetRecord {
4068
+ id: string | null
4069
+ input: JSONType
4070
+ expectedOutput: JSONType
4071
+ metadata: Record<string, JSONType>
4072
+ tags: string[]
4073
+ }
4074
+
4075
+ interface DatasetRecordNew {
4076
+ id?: string
4077
+ inputData: JSONType
4078
+ expectedOutput?: JSONType
4079
+ metadata?: Record<string, JSONType>
4080
+ tags?: string[]
4081
+ }
4082
+
3998
4083
  interface CreateDatasetOptions {
4084
+ /** Override the configured project for this dataset. */
4085
+ projectName?: string
3999
4086
  description?: string
4000
- records?: Array<{
4001
- id?: string,
4002
- inputData: JSONType,
4003
- expectedOutput?: JSONType,
4004
- metadata?: Record<string, JSONType>,
4005
- tags?: string[]
4006
- }>
4087
+ records?: DatasetRecordNew[]
4007
4088
  }
4008
4089
 
4009
4090
  interface ExperimentOptions {
4010
4091
  name: string
4011
4092
  dataset: Dataset
4012
4093
  task: ExperimentTask
4094
+ /** Override the configured project for this experiment. */
4095
+ projectName?: string
4013
4096
  /** Evaluators keyed by metric label, or named functions. */
4014
4097
  evaluators?: Record<string, ExperimentEvaluator> | ExperimentEvaluator[]
4015
4098
  /** Summary evaluators keyed by metric label, or named functions. */
@@ -4017,6 +4100,8 @@ declare namespace tracer {
4017
4100
  description?: string
4018
4101
  config?: Record<string, JSONType>
4019
4102
  tags?: Record<string, string>
4103
+ /** Number of full experiment runs to execute. Default 1. */
4104
+ runs?: number
4020
4105
  }
4021
4106
 
4022
4107
  interface ExperimentRunOptions {
@@ -4026,9 +4111,13 @@ declare namespace tracer {
4026
4111
  retryDelay?: (attempt: number) => number
4027
4112
  /** Reject on the first task/evaluator error instead of capturing it. Default false. */
4028
4113
  throwOnErrors?: boolean
4114
+ /** Maximum number of task/evaluator executions to process concurrently. Default 10. */
4115
+ concurrency?: number
4029
4116
  }
4030
4117
 
4031
4118
  interface PullDatasetOptions {
4119
+ /** Override the configured project for this dataset pull. */
4120
+ projectName?: string
4032
4121
  /** Dataset version to pull. Defaults to latest. */
4033
4122
  version?: number
4034
4123
  /** Wait until at least this many records are readable (absorbs write lag). */
@@ -4057,17 +4146,21 @@ declare namespace tracer {
4057
4146
 
4058
4147
  interface ExperimentRun {
4059
4148
  runId: string
4149
+ /** 1-based run iteration. */
4060
4150
  runIteration: number
4151
+ /** Whether this run had a task, row-evaluator, or summary-evaluator error. */
4152
+ hasError: boolean
4061
4153
  rows: ExperimentResultRow[]
4062
4154
  summaryEvaluations: Record<string, { value: any, error: string | null }>
4063
4155
  }
4064
4156
 
4065
4157
  interface ExperimentResult {
4066
4158
  experimentId: string
4159
+ /** Rows from the first run, kept as a compatibility alias. */
4067
4160
  rows: ExperimentResultRow[]
4068
- /** Single-run summary evaluator results. */
4161
+ /** Summary evaluator results from the first run, kept as a compatibility alias. */
4069
4162
  summaryEvaluations: Record<string, { value: any, error: string | null }>
4070
- /** Experiment runs. P0 Node experiments currently return one run. */
4163
+ /** All experiment runs. */
4071
4164
  runs: ExperimentRun[]
4072
4165
  /** Dashboard URL for the experiment. */
4073
4166
  url: string
@@ -4160,6 +4253,8 @@ declare namespace tracer {
4160
4253
  metadata?: Record<string, JSONType>,
4161
4254
  tags?: string[]
4162
4255
  ): Dataset
4256
+ /** Add multiple records to the dataset. */
4257
+ addRecords (records: DatasetRecordNew[]): Dataset
4163
4258
  /** Update fields on an existing dataset record. */
4164
4259
  update (index: number, fields: {
4165
4260
  input?: JSONType
@@ -4180,15 +4275,11 @@ declare namespace tracer {
4180
4275
  description (): string
4181
4276
  id (): string | null
4182
4277
  projectId (): string | null
4278
+ /** Project associated with the client used to create or pull this dataset. */
4279
+ projectName (): string | null | undefined
4183
4280
  version (): number | null
4184
4281
  latestVersion (): number | null
4185
- records (): Array<{
4186
- id: string | null,
4187
- input: JSONType,
4188
- expectedOutput: JSONType,
4189
- metadata: Record<string, JSONType>,
4190
- tags: string[]
4191
- }>
4282
+ records (): DatasetRecord[]
4192
4283
  /** Return the tags used to filter this dataset. */
4193
4284
  filterTags (): string[]
4194
4285
  /** Dashboard URL for the dataset, or null until pushed. */
@@ -4706,6 +4797,13 @@ declare namespace tracer {
4706
4797
  * Options for enabling LLM Observability tracing.
4707
4798
  */
4708
4799
  interface LLMObsEnableOptions {
4800
+ /**
4801
+ * The name of the LLM Observability project used for experiments.
4802
+ * @env DD_LLMOBS_PROJECT_NAME
4803
+ * Programmatic configuration takes precedence over the environment variables listed above.
4804
+ */
4805
+ projectName?: string,
4806
+
4709
4807
  /**
4710
4808
  * The name of your ML application.
4711
4809
  * @env DD_LLMOBS_ML_APP
@@ -4729,6 +4827,10 @@ declare namespace tracer {
4729
4827
  */
4730
4828
  sampleRate?: number,
4731
4829
  }
4830
+
4831
+ /** Options accepted by the deprecated runtime `llmobs.enable()` method. */
4832
+ type LLMObsRuntimeEnableOptions = Omit<LLMObsEnableOptions, 'projectName'>
4833
+
4732
4834
  /** @hidden */
4733
4835
  type spanKind = 'agent' | 'workflow' | 'task' | 'tool' | 'retrieval' | 'embedding' | 'llm'
4734
4836
  }