@depup/dd-trace 5.97.0-depup.0 → 6.5.0-depup.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 (712) hide show
  1. package/LICENSE-3rdparty.csv +89 -104
  2. package/README.electron.md +7 -0
  3. package/README.md +2 -2
  4. package/changes.json +1 -1
  5. package/ci/diagnose.js +2100 -0
  6. package/ci/init.js +46 -5
  7. package/ci/runbook.md +198 -0
  8. package/ci/test-optimization-validation/approval-artifacts.js +143 -0
  9. package/ci/test-optimization-validation/approval.js +299 -0
  10. package/ci/test-optimization-validation/artifact-id.js +20 -0
  11. package/ci/test-optimization-validation/bounded-json.js +121 -0
  12. package/ci/test-optimization-validation/ci-command-candidate.js +83 -0
  13. package/ci/test-optimization-validation/ci-discovery.js +181 -0
  14. package/ci/test-optimization-validation/ci-remediation.js +210 -0
  15. package/ci/test-optimization-validation/cli.js +903 -0
  16. package/ci/test-optimization-validation/command-blocker.js +81 -0
  17. package/ci/test-optimization-validation/command-output-policy.js +206 -0
  18. package/ci/test-optimization-validation/command-runner.js +707 -0
  19. package/ci/test-optimization-validation/command-suitability.js +471 -0
  20. package/ci/test-optimization-validation/executable-approval.js +48 -0
  21. package/ci/test-optimization-validation/executable.js +480 -0
  22. package/ci/test-optimization-validation/generated-file-policy.js +63 -0
  23. package/ci/test-optimization-validation/generated-files.js +351 -0
  24. package/ci/test-optimization-validation/generated-verifier.js +196 -0
  25. package/ci/test-optimization-validation/init-probe-preload.js +163 -0
  26. package/ci/test-optimization-validation/init-probe.js +246 -0
  27. package/ci/test-optimization-validation/late-initialization.js +63 -0
  28. package/ci/test-optimization-validation/local-command.js +163 -0
  29. package/ci/test-optimization-validation/manifest-loader.js +133 -0
  30. package/ci/test-optimization-validation/manifest-scaffold.js +738 -0
  31. package/ci/test-optimization-validation/manifest-schema.js +862 -0
  32. package/ci/test-optimization-validation/offline-fixtures.js +327 -0
  33. package/ci/test-optimization-validation/offline-output.js +406 -0
  34. package/ci/test-optimization-validation/payload-normalizer.js +72 -0
  35. package/ci/test-optimization-validation/plan-writer.js +1120 -0
  36. package/ci/test-optimization-validation/preflight-runner.js +114 -0
  37. package/ci/test-optimization-validation/redaction.js +331 -0
  38. package/ci/test-optimization-validation/report-writer.js +1508 -0
  39. package/ci/test-optimization-validation/safe-files.js +203 -0
  40. package/ci/test-optimization-validation/scenarios/auto-test-retries.js +159 -0
  41. package/ci/test-optimization-validation/scenarios/basic-reporting.js +657 -0
  42. package/ci/test-optimization-validation/scenarios/ci-wiring.js +780 -0
  43. package/ci/test-optimization-validation/scenarios/early-flake-detection.js +141 -0
  44. package/ci/test-optimization-validation/scenarios/helpers.js +539 -0
  45. package/ci/test-optimization-validation/scenarios/test-management.js +218 -0
  46. package/ci/test-optimization-validation/setup-runner.js +97 -0
  47. package/ci/test-optimization-validation/static-diagnosis.js +159 -0
  48. package/ci/test-optimization-validation/test-output.js +129 -0
  49. package/ci/test-optimization-validation-manifest.schema.json +1 -0
  50. package/ci/validate-test-optimization.js +3 -0
  51. package/ci/vitest-no-worker-init-setup.mjs +430 -0
  52. package/ext/exporters.js +2 -0
  53. package/ext/tags.js +3 -0
  54. package/index.d.ts +436 -252
  55. package/index.electron.js +3 -0
  56. package/init.js +18 -0
  57. package/initialize.mjs +10 -9
  58. package/loader-hook.mjs +170 -53
  59. package/openfeature.d.ts +1 -0
  60. package/openfeature.js +4 -0
  61. package/package.json +118 -80
  62. package/packages/datadog-core/src/storage.js +47 -48
  63. package/packages/datadog-esbuild/index.js +32 -1
  64. package/packages/datadog-esbuild/src/utils.js +46 -3
  65. package/packages/datadog-instrumentations/src/aerospike.js +3 -3
  66. package/packages/datadog-instrumentations/src/ai.js +137 -76
  67. package/packages/datadog-instrumentations/src/amqplib.js +6 -7
  68. package/packages/datadog-instrumentations/src/anthropic.js +10 -10
  69. package/packages/datadog-instrumentations/src/apollo-server-core.js +3 -3
  70. package/packages/datadog-instrumentations/src/apollo-server.js +10 -18
  71. package/packages/datadog-instrumentations/src/avsc.js +6 -6
  72. package/packages/datadog-instrumentations/src/aws-durable-execution-sdk-js-context-methods.js +18 -0
  73. package/packages/datadog-instrumentations/src/aws-durable-execution-sdk-js.js +111 -0
  74. package/packages/datadog-instrumentations/src/aws-sdk.js +172 -72
  75. package/packages/datadog-instrumentations/src/azure-cosmos.js +7 -0
  76. package/packages/datadog-instrumentations/src/azure-durable-functions.js +8 -8
  77. package/packages/datadog-instrumentations/src/azure-functions.js +3 -0
  78. package/packages/datadog-instrumentations/src/bluebird.js +2 -2
  79. package/packages/datadog-instrumentations/src/body-parser.js +5 -2
  80. package/packages/datadog-instrumentations/src/cassandra-driver.js +12 -9
  81. package/packages/datadog-instrumentations/src/child_process.js +16 -16
  82. package/packages/datadog-instrumentations/src/claude-agent-sdk.js +587 -0
  83. package/packages/datadog-instrumentations/src/confluentinc-kafka-javascript.js +41 -24
  84. package/packages/datadog-instrumentations/src/connect.js +14 -12
  85. package/packages/datadog-instrumentations/src/cookie-parser.js +5 -4
  86. package/packages/datadog-instrumentations/src/cookie.js +9 -3
  87. package/packages/datadog-instrumentations/src/couchbase.js +73 -238
  88. package/packages/datadog-instrumentations/src/crypto.js +49 -4
  89. package/packages/datadog-instrumentations/src/cucumber-worker-threads.js +25 -0
  90. package/packages/datadog-instrumentations/src/cucumber.js +762 -189
  91. package/packages/datadog-instrumentations/src/cypress-config.js +547 -93
  92. package/packages/datadog-instrumentations/src/cypress.js +5 -3
  93. package/packages/datadog-instrumentations/src/dns.js +60 -59
  94. package/packages/datadog-instrumentations/src/elasticsearch.js +9 -12
  95. package/packages/datadog-instrumentations/src/electron/preload.js +42 -0
  96. package/packages/datadog-instrumentations/src/electron.js +240 -0
  97. package/packages/datadog-instrumentations/src/express-mongo-sanitize.js +11 -9
  98. package/packages/datadog-instrumentations/src/express-session.js +14 -13
  99. package/packages/datadog-instrumentations/src/express.js +52 -30
  100. package/packages/datadog-instrumentations/src/fastify.js +166 -87
  101. package/packages/datadog-instrumentations/src/fetch.js +5 -5
  102. package/packages/datadog-instrumentations/src/fs.js +22 -20
  103. package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +5 -7
  104. package/packages/datadog-instrumentations/src/google-genai.js +4 -4
  105. package/packages/datadog-instrumentations/src/graphql.js +26 -362
  106. package/packages/datadog-instrumentations/src/grpc/client.js +48 -32
  107. package/packages/datadog-instrumentations/src/grpc/server.js +20 -2
  108. package/packages/datadog-instrumentations/src/hapi.js +2 -2
  109. package/packages/datadog-instrumentations/src/helpers/callback-instrumentor.js +74 -0
  110. package/packages/datadog-instrumentations/src/helpers/check-require-cache.js +85 -9
  111. package/packages/datadog-instrumentations/src/helpers/hook.js +31 -7
  112. package/packages/datadog-instrumentations/src/helpers/hooks.js +12 -0
  113. package/packages/datadog-instrumentations/src/helpers/instrument.js +36 -3
  114. package/packages/datadog-instrumentations/src/helpers/kafka.js +58 -0
  115. package/packages/datadog-instrumentations/src/helpers/optional-peer-bundler.js +65 -0
  116. package/packages/datadog-instrumentations/src/helpers/promise-instrumentor.js +42 -0
  117. package/packages/datadog-instrumentations/src/helpers/promise.js +2 -2
  118. package/packages/datadog-instrumentations/src/helpers/register.js +7 -5
  119. package/packages/datadog-instrumentations/src/helpers/rewriter/compiler.js +13 -5
  120. package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +24 -7
  121. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/ai.js +6 -6
  122. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/aws-durable-execution-sdk-js.js +31 -0
  123. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/azure-cosmos.js +50 -0
  124. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/claude-agent-sdk.js +17 -0
  125. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql.js +201 -0
  126. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/index.js +7 -0
  127. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/langgraph.js +4 -2
  128. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/mercurius.js +31 -0
  129. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/modelcontextprotocol-sdk.js +35 -0
  130. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/playwright.js +111 -0
  131. package/packages/datadog-instrumentations/src/helpers/rewriter/loader.mjs +18 -2
  132. package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +49 -224
  133. package/packages/datadog-instrumentations/src/helpers/router-helper.js +8 -8
  134. package/packages/datadog-instrumentations/src/hono.js +71 -9
  135. package/packages/datadog-instrumentations/src/http/client.js +48 -24
  136. package/packages/datadog-instrumentations/src/http/server.js +75 -29
  137. package/packages/datadog-instrumentations/src/http2/client.js +15 -12
  138. package/packages/datadog-instrumentations/src/http2/server.js +156 -23
  139. package/packages/datadog-instrumentations/src/ioredis.js +17 -14
  140. package/packages/datadog-instrumentations/src/iovalkey.js +1 -2
  141. package/packages/datadog-instrumentations/src/jest/bail-reporter.js +42 -0
  142. package/packages/datadog-instrumentations/src/jest/coverage-backfill.js +163 -0
  143. package/packages/datadog-instrumentations/src/jest.js +1809 -401
  144. package/packages/datadog-instrumentations/src/kafkajs.js +284 -170
  145. package/packages/datadog-instrumentations/src/knex.js +17 -17
  146. package/packages/datadog-instrumentations/src/koa.js +15 -14
  147. package/packages/datadog-instrumentations/src/ldapjs.js +5 -5
  148. package/packages/datadog-instrumentations/src/light-my-request.js +2 -2
  149. package/packages/datadog-instrumentations/src/limitd-client.js +4 -4
  150. package/packages/datadog-instrumentations/src/lodash.js +4 -4
  151. package/packages/datadog-instrumentations/src/mariadb.js +18 -16
  152. package/packages/datadog-instrumentations/src/memcached.js +4 -3
  153. package/packages/datadog-instrumentations/src/mercurius.js +11 -0
  154. package/packages/datadog-instrumentations/src/microgateway-core.js +2 -2
  155. package/packages/datadog-instrumentations/src/mocha/common.js +7 -4
  156. package/packages/datadog-instrumentations/src/mocha/main.js +557 -120
  157. package/packages/datadog-instrumentations/src/mocha/utils.js +531 -135
  158. package/packages/datadog-instrumentations/src/mocha/worker.js +27 -9
  159. package/packages/datadog-instrumentations/src/modelcontextprotocol-sdk.js +254 -0
  160. package/packages/datadog-instrumentations/src/mongodb-core.js +43 -31
  161. package/packages/datadog-instrumentations/src/mongodb.js +82 -8
  162. package/packages/datadog-instrumentations/src/mongoose.js +46 -37
  163. package/packages/datadog-instrumentations/src/mquery.js +7 -7
  164. package/packages/datadog-instrumentations/src/multer.js +5 -4
  165. package/packages/datadog-instrumentations/src/mysql.js +17 -17
  166. package/packages/datadog-instrumentations/src/mysql2.js +39 -5
  167. package/packages/datadog-instrumentations/src/nats.js +182 -0
  168. package/packages/datadog-instrumentations/src/net.js +19 -11
  169. package/packages/datadog-instrumentations/src/next.js +68 -10
  170. package/packages/datadog-instrumentations/src/nyc.js +43 -8
  171. package/packages/datadog-instrumentations/src/openai.js +124 -38
  172. package/packages/datadog-instrumentations/src/oracledb.js +12 -7
  173. package/packages/datadog-instrumentations/src/otel-sdk-trace.js +27 -6
  174. package/packages/datadog-instrumentations/src/passport-utils.js +5 -5
  175. package/packages/datadog-instrumentations/src/path-to-regexp.js +44 -0
  176. package/packages/datadog-instrumentations/src/pg.js +58 -25
  177. package/packages/datadog-instrumentations/src/pino.js +25 -41
  178. package/packages/datadog-instrumentations/src/playwright-browser-scripts.js +27 -0
  179. package/packages/datadog-instrumentations/src/playwright.js +1229 -356
  180. package/packages/datadog-instrumentations/src/process.js +3 -0
  181. package/packages/datadog-instrumentations/src/protobufjs.js +16 -16
  182. package/packages/datadog-instrumentations/src/redis.js +28 -15
  183. package/packages/datadog-instrumentations/src/restify.js +6 -5
  184. package/packages/datadog-instrumentations/src/router.js +253 -87
  185. package/packages/datadog-instrumentations/src/selenium.js +53 -28
  186. package/packages/datadog-instrumentations/src/stripe.js +47 -33
  187. package/packages/datadog-instrumentations/src/tedious.js +28 -0
  188. package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +1297 -0
  189. package/packages/datadog-instrumentations/src/vitest-main.js +1590 -0
  190. package/packages/datadog-instrumentations/src/vitest-util.js +251 -0
  191. package/packages/datadog-instrumentations/src/vitest-worker.js +822 -0
  192. package/packages/datadog-instrumentations/src/vitest.js +11 -1262
  193. package/packages/datadog-instrumentations/src/winston.js +4 -4
  194. package/packages/datadog-instrumentations/src/ws.js +9 -8
  195. package/packages/datadog-instrumentations/src/zlib.js +29 -0
  196. package/packages/datadog-plugin-ai/src/index.js +1 -1
  197. package/packages/datadog-plugin-ai/src/tracing.js +66 -3
  198. package/packages/datadog-plugin-ai/src/utils.js +17 -4
  199. package/packages/datadog-plugin-apollo/src/gateway/request.js +1 -21
  200. package/packages/datadog-plugin-avsc/src/schema_iterator.js +3 -3
  201. package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/checkpoint.js +31 -0
  202. package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/client.js +55 -0
  203. package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/context.js +123 -0
  204. package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/handler.js +129 -0
  205. package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/index.js +19 -0
  206. package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/trace-checkpoint.js +224 -0
  207. package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/util.js +80 -0
  208. package/packages/datadog-plugin-aws-sdk/src/base.js +86 -50
  209. package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/tracing.js +1 -1
  210. package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/utils.js +218 -4
  211. package/packages/datadog-plugin-aws-sdk/src/services/cloudwatchlogs.js +1 -1
  212. package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +2 -1
  213. package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +59 -14
  214. package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +174 -75
  215. package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +34 -23
  216. package/packages/datadog-plugin-aws-sdk/src/services/redshift.js +2 -1
  217. package/packages/datadog-plugin-aws-sdk/src/services/s3.js +1 -1
  218. package/packages/datadog-plugin-aws-sdk/src/services/sns.js +26 -26
  219. package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +187 -101
  220. package/packages/datadog-plugin-aws-sdk/src/services/stepfunctions.js +20 -18
  221. package/packages/datadog-plugin-aws-sdk/src/util.js +2 -2
  222. package/packages/datadog-plugin-azure-cosmos/src/index.js +144 -0
  223. package/packages/datadog-plugin-azure-event-hubs/src/producer.js +8 -15
  224. package/packages/datadog-plugin-azure-functions/src/index.js +7 -3
  225. package/packages/datadog-plugin-azure-service-bus/src/producer.js +5 -10
  226. package/packages/datadog-plugin-bullmq/src/consumer.js +5 -4
  227. package/packages/datadog-plugin-bullmq/src/filter.js +35 -0
  228. package/packages/datadog-plugin-bullmq/src/producer.js +121 -33
  229. package/packages/datadog-plugin-bunyan/src/index.js +28 -0
  230. package/packages/datadog-plugin-child_process/src/index.js +13 -2
  231. package/packages/datadog-plugin-child_process/src/scrub-cmd-params.js +6 -6
  232. package/packages/datadog-plugin-claude-agent-sdk/src/index.js +31 -0
  233. package/packages/datadog-plugin-claude-agent-sdk/src/tracing.js +107 -0
  234. package/packages/datadog-plugin-claude-agent-sdk/src/util.js +15 -0
  235. package/packages/datadog-plugin-couchbase/src/index.js +58 -52
  236. package/packages/datadog-plugin-cucumber/src/index.js +47 -29
  237. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +929 -98
  238. package/packages/datadog-plugin-cypress/src/index.js +109 -2
  239. package/packages/datadog-plugin-cypress/src/plugin.js +6 -14
  240. package/packages/datadog-plugin-cypress/src/source-map-utils.js +48 -1
  241. package/packages/datadog-plugin-cypress/src/support.js +272 -51
  242. package/packages/datadog-plugin-dd-trace-api/src/index.js +1 -1
  243. package/packages/datadog-plugin-dns/src/lookup.js +8 -6
  244. package/packages/datadog-plugin-elasticsearch/src/index.js +28 -8
  245. package/packages/datadog-plugin-electron/src/index.js +17 -0
  246. package/packages/datadog-plugin-electron/src/ipc.js +143 -0
  247. package/packages/datadog-plugin-electron/src/net.js +82 -0
  248. package/packages/datadog-plugin-express/src/code_origin.js +1 -1
  249. package/packages/datadog-plugin-fastify/src/code_origin.js +1 -1
  250. package/packages/datadog-plugin-fs/src/index.js +2 -1
  251. package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +2 -5
  252. package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +27 -18
  253. package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +5 -8
  254. package/packages/datadog-plugin-graphql/src/execute.js +748 -34
  255. package/packages/datadog-plugin-graphql/src/index.js +43 -9
  256. package/packages/datadog-plugin-graphql/src/parse.js +45 -4
  257. package/packages/datadog-plugin-graphql/src/request.js +135 -0
  258. package/packages/datadog-plugin-graphql/src/tools/signature.js +32 -7
  259. package/packages/datadog-plugin-graphql/src/tools/transforms.js +118 -100
  260. package/packages/datadog-plugin-graphql/src/utils.js +261 -3
  261. package/packages/datadog-plugin-graphql/src/validate.js +54 -8
  262. package/packages/datadog-plugin-grpc/src/client.js +7 -8
  263. package/packages/datadog-plugin-grpc/src/server.js +1 -1
  264. package/packages/datadog-plugin-grpc/src/util.js +57 -22
  265. package/packages/datadog-plugin-http/src/client.js +12 -14
  266. package/packages/datadog-plugin-http/src/index.js +6 -8
  267. package/packages/datadog-plugin-http/src/server.js +63 -20
  268. package/packages/datadog-plugin-http2/src/client.js +7 -4
  269. package/packages/datadog-plugin-http2/src/server.js +48 -8
  270. package/packages/datadog-plugin-jest/src/index.js +133 -67
  271. package/packages/datadog-plugin-jest/src/util.js +37 -16
  272. package/packages/datadog-plugin-kafkajs/src/batch-consumer.js +1 -1
  273. package/packages/datadog-plugin-kafkajs/src/consumer.js +2 -9
  274. package/packages/datadog-plugin-kafkajs/src/producer.js +37 -8
  275. package/packages/datadog-plugin-langchain/src/handlers/embedding.js +2 -1
  276. package/packages/datadog-plugin-langchain/src/handlers/language_models.js +2 -1
  277. package/packages/datadog-plugin-langchain/src/tokens.js +2 -2
  278. package/packages/datadog-plugin-langgraph/src/stream.js +1 -1
  279. package/packages/datadog-plugin-memcached/src/index.js +1 -1
  280. package/packages/datadog-plugin-mocha/src/index.js +66 -20
  281. package/packages/datadog-plugin-modelcontextprotocol-sdk/src/index.js +24 -0
  282. package/packages/datadog-plugin-modelcontextprotocol-sdk/src/tracing.js +173 -0
  283. package/packages/datadog-plugin-modelcontextprotocol-sdk/src/utils.js +30 -0
  284. package/packages/datadog-plugin-mongodb-core/src/bulk-write.js +43 -0
  285. package/packages/datadog-plugin-mongodb-core/src/index.js +8 -206
  286. package/packages/datadog-plugin-mongodb-core/src/query.js +452 -0
  287. package/packages/datadog-plugin-mysql/src/index.js +9 -4
  288. package/packages/datadog-plugin-nats/src/consumer.js +43 -0
  289. package/packages/datadog-plugin-nats/src/index.js +20 -0
  290. package/packages/datadog-plugin-nats/src/producer.js +62 -0
  291. package/packages/datadog-plugin-nats/src/util.js +33 -0
  292. package/packages/datadog-plugin-next/src/index.js +12 -4
  293. package/packages/datadog-plugin-openai/src/services.js +4 -3
  294. package/packages/datadog-plugin-openai/src/tracing.js +27 -25
  295. package/packages/datadog-plugin-oracledb/src/index.js +13 -2
  296. package/packages/datadog-plugin-pg/src/index.js +13 -3
  297. package/packages/datadog-plugin-pino/src/index.js +42 -0
  298. package/packages/datadog-plugin-playwright/src/index.js +195 -72
  299. package/packages/datadog-plugin-protobufjs/src/schema_iterator.js +3 -3
  300. package/packages/datadog-plugin-redis/src/index.js +54 -25
  301. package/packages/datadog-plugin-rhea/src/producer.js +1 -1
  302. package/packages/datadog-plugin-router/src/index.js +55 -44
  303. package/packages/datadog-plugin-selenium/src/index.js +5 -36
  304. package/packages/datadog-plugin-tedious/src/index.js +1 -1
  305. package/packages/datadog-plugin-undici/src/index.js +24 -2
  306. package/packages/datadog-plugin-vitest/src/index.js +160 -90
  307. package/packages/datadog-plugin-winston/src/index.js +30 -0
  308. package/packages/datadog-plugin-ws/src/close.js +5 -2
  309. package/packages/datadog-plugin-ws/src/producer.js +4 -1
  310. package/packages/datadog-plugin-ws/src/receiver.js +4 -2
  311. package/packages/datadog-plugin-ws/src/server.js +2 -1
  312. package/packages/datadog-shimmer/src/shimmer.js +101 -39
  313. package/packages/datadog-webpack/index.js +17 -1
  314. package/packages/datadog-webpack/src/optional-peer-loader.js +17 -0
  315. package/packages/dd-trace/index.electron.js +3 -0
  316. package/packages/dd-trace/index.js +2 -36
  317. package/packages/dd-trace/src/aiguard/channels.js +7 -0
  318. package/packages/dd-trace/src/aiguard/index.js +16 -34
  319. package/packages/dd-trace/src/aiguard/integrations/evaluate.js +46 -0
  320. package/packages/dd-trace/src/aiguard/integrations/index.js +34 -0
  321. package/packages/dd-trace/src/aiguard/integrations/openai.js +80 -0
  322. package/packages/dd-trace/src/aiguard/integrations/vercel-ai.js +92 -0
  323. package/packages/dd-trace/src/aiguard/messages/openai.js +382 -0
  324. package/packages/{datadog-instrumentations/src/helpers/ai-messages.js → dd-trace/src/aiguard/messages/vercel-ai.js} +30 -27
  325. package/packages/dd-trace/src/aiguard/sdk.js +148 -55
  326. package/packages/dd-trace/src/aiguard/tags.js +26 -10
  327. package/packages/dd-trace/src/appsec/api_security/index.js +55 -0
  328. package/packages/dd-trace/src/appsec/api_security/sampler.js +147 -0
  329. package/packages/dd-trace/src/appsec/blocked_templates.js +4 -3
  330. package/packages/dd-trace/src/appsec/blocking.js +82 -42
  331. package/packages/dd-trace/src/appsec/channels.js +5 -1
  332. package/packages/dd-trace/src/appsec/downstream_requests.js +116 -62
  333. package/packages/dd-trace/src/appsec/graphql.js +20 -17
  334. package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-password-rules.js +1 -1
  335. package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-secret-rules.js +81 -81
  336. package/packages/dd-trace/src/appsec/iast/analyzers/nosql-injection-mongodb-analyzer.js +23 -23
  337. package/packages/dd-trace/src/appsec/iast/index.js +3 -2
  338. package/packages/dd-trace/src/appsec/iast/security-controls/index.js +4 -4
  339. package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +2 -2
  340. package/packages/dd-trace/src/appsec/iast/taint-tracking/plugins/kafka.js +2 -2
  341. package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +4 -4
  342. package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +2 -2
  343. package/packages/dd-trace/src/appsec/iast/telemetry/index.js +2 -1
  344. package/packages/dd-trace/src/appsec/iast/telemetry/span-tags.js +3 -1
  345. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/ldap-sensitive-analyzer.js +54 -12
  346. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/url-sensitive-analyzer.js +5 -1
  347. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +31 -4
  348. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/index.js +1 -3
  349. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/utils.js +83 -48
  350. package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +1 -1
  351. package/packages/dd-trace/src/appsec/index.js +65 -47
  352. package/packages/dd-trace/src/appsec/lambda.js +135 -0
  353. package/packages/dd-trace/src/appsec/rasp/command_injection.js +4 -5
  354. package/packages/dd-trace/src/appsec/rasp/lfi.js +8 -4
  355. package/packages/dd-trace/src/appsec/rasp/sql_injection.js +5 -10
  356. package/packages/dd-trace/src/appsec/rasp/ssrf.js +26 -18
  357. package/packages/dd-trace/src/appsec/recommended.json +2438 -13
  358. package/packages/dd-trace/src/appsec/reporter.js +87 -28
  359. package/packages/dd-trace/src/appsec/rule_manager.js +4 -2
  360. package/packages/dd-trace/src/appsec/sdk/set_user.js +1 -1
  361. package/packages/dd-trace/src/appsec/sdk/track_event.js +5 -5
  362. package/packages/dd-trace/src/appsec/sdk/user_blocking.js +7 -11
  363. package/packages/dd-trace/src/appsec/sdk/utils.js +5 -3
  364. package/packages/dd-trace/src/appsec/store.js +50 -0
  365. package/packages/dd-trace/src/appsec/telemetry/api_security.js +34 -0
  366. package/packages/dd-trace/src/appsec/telemetry/index.js +27 -1
  367. package/packages/dd-trace/src/appsec/user_tracking.js +5 -4
  368. package/packages/dd-trace/src/appsec/waf/index.js +19 -9
  369. package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +35 -20
  370. package/packages/dd-trace/src/appsec/waf/waf_manager.js +1 -1
  371. package/packages/dd-trace/src/azure_metadata.js +19 -7
  372. package/packages/dd-trace/src/baggage.js +32 -13
  373. package/packages/dd-trace/src/bootstrap.js +39 -0
  374. package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +123 -33
  375. package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +122 -24
  376. package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +22 -7
  377. package/packages/dd-trace/src/ci-visibility/exporters/agent-proxy/index.js +5 -2
  378. package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +2 -2
  379. package/packages/dd-trace/src/ci-visibility/exporters/agentless/di-logs-writer.js +2 -2
  380. package/packages/dd-trace/src/ci-visibility/exporters/agentless/index.js +6 -2
  381. package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +2 -2
  382. package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/index.js +160 -0
  383. package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/msgpack-to-json.js +288 -0
  384. package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/payload-projection.js +84 -0
  385. package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/sink.js +369 -0
  386. package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/writer.js +60 -0
  387. package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +188 -27
  388. package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +3 -4
  389. package/packages/dd-trace/src/ci-visibility/exporters/test-worker/index.js +28 -10
  390. package/packages/dd-trace/src/ci-visibility/exporters/test-worker/writer.js +22 -0
  391. package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +110 -22
  392. package/packages/dd-trace/src/ci-visibility/lage.js +2 -1
  393. package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +4 -5
  394. package/packages/dd-trace/src/ci-visibility/requests/fs-cache.js +4 -5
  395. package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +73 -55
  396. package/packages/dd-trace/src/ci-visibility/requests/request.js +14 -50
  397. package/packages/dd-trace/src/ci-visibility/requests/upload-coverage-report.js +10 -6
  398. package/packages/dd-trace/src/ci-visibility/requests/upload-test-screenshot.js +156 -0
  399. package/packages/dd-trace/src/ci-visibility/rum.js +7 -0
  400. package/packages/dd-trace/src/ci-visibility/test-api-manual/test-api-manual-plugin.js +9 -3
  401. package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +24 -6
  402. package/packages/dd-trace/src/ci-visibility/test-optimization-cache.js +70 -6
  403. package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache-schema.js +256 -0
  404. package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache.js +451 -0
  405. package/packages/dd-trace/src/ci-visibility/test-screenshot.js +90 -0
  406. package/packages/dd-trace/src/config/config-types.d.ts +8 -6
  407. package/packages/dd-trace/src/config/defaults.js +71 -44
  408. package/packages/dd-trace/src/config/generated-config-types.d.ts +692 -131
  409. package/packages/dd-trace/src/config/git_properties.js +2 -2
  410. package/packages/dd-trace/src/config/helper.js +140 -33
  411. package/packages/dd-trace/src/config/index.js +127 -131
  412. package/packages/dd-trace/src/config/major-overrides.js +100 -0
  413. package/packages/dd-trace/src/config/normalize-service.js +31 -0
  414. package/packages/dd-trace/src/config/parsers.js +138 -10
  415. package/packages/dd-trace/src/config/remote_config.js +1 -1
  416. package/packages/dd-trace/src/config/supported-configurations.json +460 -203
  417. package/packages/dd-trace/src/constants.js +15 -0
  418. package/packages/dd-trace/src/crashtracking/crashtracker.js +18 -6
  419. package/packages/dd-trace/src/datastreams/checkpointer.js +6 -12
  420. package/packages/dd-trace/src/datastreams/context.js +4 -2
  421. package/packages/dd-trace/src/datastreams/encoding.js +39 -28
  422. package/packages/dd-trace/src/datastreams/index.js +2 -1
  423. package/packages/dd-trace/src/datastreams/manager.js +1 -1
  424. package/packages/dd-trace/src/datastreams/pathway.js +35 -30
  425. package/packages/dd-trace/src/datastreams/processor.js +31 -22
  426. package/packages/dd-trace/src/datastreams/size.js +6 -2
  427. package/packages/dd-trace/src/datastreams/writer.js +15 -6
  428. package/packages/dd-trace/src/debugger/config.js +9 -4
  429. package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +49 -35
  430. package/packages/dd-trace/src/debugger/devtools_client/condition.js +5 -8
  431. package/packages/dd-trace/src/debugger/devtools_client/config.js +3 -2
  432. package/packages/dd-trace/src/debugger/devtools_client/index.js +33 -71
  433. package/packages/dd-trace/src/debugger/devtools_client/probe_sampler.js +83 -0
  434. package/packages/dd-trace/src/debugger/devtools_client/send.js +27 -6
  435. package/packages/dd-trace/src/debugger/devtools_client/snapshot/collector.js +2 -2
  436. package/packages/dd-trace/src/debugger/devtools_client/snapshot/processor.js +5 -2
  437. package/packages/dd-trace/src/debugger/devtools_client/snapshot-pruner.js +1 -0
  438. package/packages/dd-trace/src/debugger/devtools_client/source-maps.js +1 -1
  439. package/packages/dd-trace/src/debugger/devtools_client/state.js +3 -1
  440. package/packages/dd-trace/src/debugger/index.js +13 -9
  441. package/packages/dd-trace/src/debugger/probe_sampler.js +112 -0
  442. package/packages/dd-trace/src/debugger/probe_sampler_constants.js +19 -0
  443. package/packages/dd-trace/src/dogstatsd.js +34 -28
  444. package/packages/dd-trace/src/encode/0.4.js +829 -268
  445. package/packages/dd-trace/src/encode/0.5.js +158 -22
  446. package/packages/dd-trace/src/encode/agentless-ci-visibility.js +141 -65
  447. package/packages/dd-trace/src/encode/agentless-json.js +12 -6
  448. package/packages/dd-trace/src/encode/coverage-ci-visibility.js +52 -15
  449. package/packages/dd-trace/src/encode/span-stats.js +19 -16
  450. package/packages/dd-trace/src/encode/tags-processors.js +30 -25
  451. package/packages/dd-trace/src/exporter.js +5 -1
  452. package/packages/dd-trace/src/exporters/agent/index.js +4 -5
  453. package/packages/dd-trace/src/exporters/agent/writer.js +1 -2
  454. package/packages/dd-trace/src/exporters/agentless/index.js +12 -13
  455. package/packages/dd-trace/src/exporters/agentless/intake.js +43 -0
  456. package/packages/dd-trace/src/exporters/agentless/writer.js +12 -11
  457. package/packages/dd-trace/src/exporters/common/agents.js +3 -1
  458. package/packages/dd-trace/src/exporters/common/buffering-exporter.js +3 -3
  459. package/packages/dd-trace/src/exporters/common/client-library-headers.js +21 -0
  460. package/packages/dd-trace/src/exporters/common/request.js +93 -44
  461. package/packages/dd-trace/src/exporters/common/retry.js +104 -0
  462. package/packages/dd-trace/src/exporters/common/url.js +48 -0
  463. package/packages/dd-trace/src/exporters/common/util.js +2 -2
  464. package/packages/dd-trace/src/exporters/common/writer.js +17 -1
  465. package/packages/dd-trace/src/exporters/electron/index.js +49 -0
  466. package/packages/dd-trace/src/exporters/span-stats/index.js +1 -2
  467. package/packages/dd-trace/src/exporters/span-stats/writer.js +1 -3
  468. package/packages/dd-trace/src/external-logger/src/index.js +2 -1
  469. package/packages/dd-trace/src/feature-registry.js +29 -0
  470. package/packages/dd-trace/src/git_metadata.js +68 -0
  471. package/packages/dd-trace/src/git_metadata_tagger.js +13 -5
  472. package/packages/dd-trace/src/guardrails/index.js +11 -6
  473. package/packages/dd-trace/src/guardrails/telemetry.js +40 -3
  474. package/packages/dd-trace/src/heap_snapshots.js +4 -4
  475. package/packages/dd-trace/src/id.js +46 -27
  476. package/packages/dd-trace/src/index.js +7 -8
  477. package/packages/dd-trace/src/lambda/handler-paths.js +52 -0
  478. package/packages/dd-trace/src/lambda/handler.js +2 -6
  479. package/packages/dd-trace/src/lambda/index.js +62 -14
  480. package/packages/dd-trace/src/lambda/runtime/patch.js +21 -46
  481. package/packages/dd-trace/src/llmobs/constants/tags.js +13 -0
  482. package/packages/dd-trace/src/llmobs/experiments/client.js +113 -0
  483. package/packages/dd-trace/src/llmobs/experiments/dataset.js +154 -0
  484. package/packages/dd-trace/src/llmobs/experiments/experiment.js +283 -0
  485. package/packages/dd-trace/src/llmobs/experiments/index.js +152 -0
  486. package/packages/dd-trace/src/llmobs/experiments/noop.js +30 -0
  487. package/packages/dd-trace/src/llmobs/experiments/result.js +34 -0
  488. package/packages/dd-trace/src/llmobs/index.js +37 -7
  489. package/packages/dd-trace/src/llmobs/noop.js +6 -0
  490. package/packages/dd-trace/src/llmobs/plugins/ai/ddTelemetry.js +403 -0
  491. package/packages/dd-trace/src/llmobs/plugins/ai/index.js +8 -395
  492. package/packages/dd-trace/src/llmobs/plugins/ai/util.js +119 -7
  493. package/packages/dd-trace/src/llmobs/plugins/ai/vercelTelemetry.js +380 -0
  494. package/packages/dd-trace/src/llmobs/plugins/{anthropic.js → anthropic/index.js} +32 -79
  495. package/packages/dd-trace/src/llmobs/plugins/anthropic/util.js +109 -0
  496. package/packages/dd-trace/src/llmobs/plugins/base.js +4 -4
  497. package/packages/dd-trace/src/llmobs/plugins/bedrockruntime.js +89 -37
  498. package/packages/dd-trace/src/llmobs/plugins/claude-agent-sdk/index.js +270 -0
  499. package/packages/dd-trace/src/llmobs/plugins/claude-agent-sdk/utils.js +10 -0
  500. package/packages/dd-trace/src/llmobs/plugins/genai/index.js +5 -1
  501. package/packages/dd-trace/src/llmobs/plugins/genai/util.js +81 -16
  502. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chain.js +3 -2
  503. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chat_model.js +3 -2
  504. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/embedding.js +2 -1
  505. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/index.js +1 -50
  506. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/vectorstore.js +2 -1
  507. package/packages/dd-trace/src/llmobs/plugins/langchain/index.js +14 -8
  508. package/packages/dd-trace/src/llmobs/plugins/langchain/messages.js +76 -0
  509. package/packages/dd-trace/src/llmobs/plugins/langgraph/index.js +4 -29
  510. package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/index.js +68 -0
  511. package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/utils.js +57 -0
  512. package/packages/dd-trace/src/llmobs/plugins/openai/constants.js +8 -0
  513. package/packages/dd-trace/src/llmobs/plugins/openai/index.js +68 -64
  514. package/packages/dd-trace/src/llmobs/plugins/openai/utils.js +43 -0
  515. package/packages/dd-trace/src/llmobs/sdk.js +73 -35
  516. package/packages/dd-trace/src/llmobs/span_processor.js +90 -11
  517. package/packages/dd-trace/src/llmobs/tagger.js +197 -4
  518. package/packages/dd-trace/src/llmobs/telemetry.js +33 -2
  519. package/packages/dd-trace/src/llmobs/util.js +234 -9
  520. package/packages/dd-trace/src/llmobs/writers/base.js +11 -5
  521. package/packages/dd-trace/src/llmobs/writers/spans.js +1 -1
  522. package/packages/dd-trace/src/llmobs/writers/util.js +1 -2
  523. package/packages/dd-trace/src/log/index.js +19 -31
  524. package/packages/dd-trace/src/log/writer.js +3 -1
  525. package/packages/dd-trace/src/msgpack/chunk.js +430 -11
  526. package/packages/dd-trace/src/msgpack/index.js +101 -2
  527. package/packages/dd-trace/src/noop/proxy.js +5 -4
  528. package/packages/dd-trace/src/noop/span.js +3 -1
  529. package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +322 -0
  530. package/packages/dd-trace/src/openfeature/configuration_source.js +90 -0
  531. package/packages/dd-trace/src/openfeature/encoding.js +70 -0
  532. package/packages/dd-trace/src/openfeature/eval-metrics-hook.js +103 -0
  533. package/packages/dd-trace/src/openfeature/flagging_provider.js +32 -16
  534. package/packages/dd-trace/src/openfeature/index.js +0 -2
  535. package/packages/dd-trace/src/openfeature/noop.js +41 -64
  536. package/packages/dd-trace/src/openfeature/register.js +35 -0
  537. package/packages/dd-trace/src/openfeature/remote_config.js +16 -14
  538. package/packages/dd-trace/src/openfeature/require-provider.js +18 -0
  539. package/packages/dd-trace/src/openfeature/span-enrichment-hook.js +143 -0
  540. package/packages/dd-trace/src/openfeature/span-enrichment.js +149 -0
  541. package/packages/dd-trace/src/openfeature/writers/base.js +3 -11
  542. package/packages/dd-trace/src/openfeature/writers/exposures.js +82 -70
  543. package/packages/dd-trace/src/openfeature/writers/util.js +1 -2
  544. package/packages/dd-trace/src/opentelemetry/active-span-proxy.js +42 -0
  545. package/packages/dd-trace/src/opentelemetry/bridge-span-base.js +107 -0
  546. package/packages/dd-trace/src/opentelemetry/context_manager.js +27 -13
  547. package/packages/dd-trace/src/opentelemetry/logs/index.js +6 -6
  548. package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +3 -2
  549. package/packages/dd-trace/src/opentelemetry/metrics/index.js +61 -12
  550. package/packages/dd-trace/src/opentelemetry/metrics/instruments.js +28 -14
  551. package/packages/dd-trace/src/opentelemetry/metrics/meter.js +7 -10
  552. package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +3 -2
  553. package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_exporter.js +40 -0
  554. package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_transformer.js +169 -0
  555. package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +99 -5
  556. package/packages/dd-trace/src/opentelemetry/metrics/time.js +19 -0
  557. package/packages/dd-trace/src/opentelemetry/otlp/common.proto +2 -2
  558. package/packages/dd-trace/src/opentelemetry/otlp/logs.proto +1 -1
  559. package/packages/dd-trace/src/opentelemetry/otlp/logs_service.proto +1 -1
  560. package/packages/dd-trace/src/opentelemetry/otlp/metrics.proto +1 -1
  561. package/packages/dd-trace/src/opentelemetry/otlp/metrics_service.proto +1 -1
  562. package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +56 -82
  563. package/packages/dd-trace/src/opentelemetry/otlp/otlp_transformer_base.js +1 -2
  564. package/packages/dd-trace/src/opentelemetry/otlp/protobuf_loader.js +14 -2
  565. package/packages/dd-trace/src/opentelemetry/otlp/trace.proto +358 -0
  566. package/packages/dd-trace/src/opentelemetry/otlp/trace_service.proto +78 -0
  567. package/packages/dd-trace/src/opentelemetry/span-ending-hook.js +10 -0
  568. package/packages/dd-trace/src/opentelemetry/span-helpers.js +325 -0
  569. package/packages/dd-trace/src/opentelemetry/span.js +64 -109
  570. package/packages/dd-trace/src/opentelemetry/span_context.js +1 -0
  571. package/packages/dd-trace/src/opentelemetry/span_processor.js +7 -5
  572. package/packages/dd-trace/src/opentelemetry/trace/index.js +75 -0
  573. package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +75 -0
  574. package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +375 -0
  575. package/packages/dd-trace/src/opentelemetry/tracer.js +20 -69
  576. package/packages/dd-trace/src/opentelemetry/tracer_provider.js +33 -17
  577. package/packages/dd-trace/src/opentracing/propagation/log.js +28 -8
  578. package/packages/dd-trace/src/opentracing/propagation/text_map.js +278 -148
  579. package/packages/dd-trace/src/opentracing/propagation/text_map_dsm.js +11 -11
  580. package/packages/dd-trace/src/opentracing/propagation/tracestate.js +98 -32
  581. package/packages/dd-trace/src/opentracing/span.js +127 -73
  582. package/packages/dd-trace/src/opentracing/span_context.js +68 -3
  583. package/packages/dd-trace/src/opentracing/tracer.js +46 -19
  584. package/packages/dd-trace/src/payload-tagging/config/index.js +2 -2
  585. package/packages/dd-trace/src/plugin_manager.js +36 -14
  586. package/packages/dd-trace/src/plugins/apollo.js +3 -1
  587. package/packages/dd-trace/src/plugins/ci_plugin.js +407 -91
  588. package/packages/dd-trace/src/plugins/database.js +61 -18
  589. package/packages/dd-trace/src/plugins/index.js +14 -0
  590. package/packages/dd-trace/src/plugins/log_injection.js +56 -0
  591. package/packages/dd-trace/src/plugins/log_plugin.js +4 -44
  592. package/packages/dd-trace/src/plugins/outbound.js +1 -1
  593. package/packages/dd-trace/src/plugins/plugin.js +19 -28
  594. package/packages/dd-trace/src/plugins/storage.js +2 -2
  595. package/packages/dd-trace/src/plugins/tracing.js +70 -13
  596. package/packages/dd-trace/src/plugins/util/ci.js +127 -40
  597. package/packages/dd-trace/src/plugins/util/git-cache.js +23 -23
  598. package/packages/dd-trace/src/plugins/util/git.js +6 -3
  599. package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +276 -0
  600. package/packages/dd-trace/src/plugins/util/inferred_proxy.js +29 -5
  601. package/packages/dd-trace/src/plugins/util/llm.js +6 -1
  602. package/packages/dd-trace/src/plugins/util/stacktrace.js +2 -2
  603. package/packages/dd-trace/src/plugins/util/test.js +950 -69
  604. package/packages/dd-trace/src/plugins/util/url.js +71 -5
  605. package/packages/dd-trace/src/plugins/util/user-provided-git.js +18 -16
  606. package/packages/dd-trace/src/plugins/util/web.js +116 -180
  607. package/packages/dd-trace/src/priority_sampler.js +12 -21
  608. package/packages/dd-trace/src/profiling/config.js +132 -212
  609. package/packages/dd-trace/src/profiling/constants.js +4 -7
  610. package/packages/dd-trace/src/profiling/exporter_cli.js +10 -10
  611. package/packages/dd-trace/src/profiling/exporters/agent.js +61 -28
  612. package/packages/dd-trace/src/profiling/exporters/event_serializer.js +45 -14
  613. package/packages/dd-trace/src/profiling/exporters/file.js +16 -5
  614. package/packages/dd-trace/src/profiling/oom.js +71 -0
  615. package/packages/dd-trace/src/profiling/profiler.js +84 -105
  616. package/packages/dd-trace/src/profiling/profilers/event_plugins/crypto.js +32 -0
  617. package/packages/dd-trace/src/profiling/profilers/event_plugins/zlib.js +19 -0
  618. package/packages/dd-trace/src/profiling/profilers/events.js +57 -13
  619. package/packages/dd-trace/src/profiling/profilers/space.js +27 -16
  620. package/packages/dd-trace/src/profiling/profilers/wall.js +49 -35
  621. package/packages/dd-trace/src/profiling/ssi-heuristics.js +3 -3
  622. package/packages/dd-trace/src/propagation-hash/index.js +1 -1
  623. package/packages/dd-trace/src/proxy.js +128 -37
  624. package/packages/dd-trace/src/rate_limiter.js +1 -1
  625. package/packages/dd-trace/src/remote_config/index.js +6 -5
  626. package/packages/dd-trace/src/remote_config/scheduler.js +1 -1
  627. package/packages/dd-trace/src/ritm.js +6 -3
  628. package/packages/dd-trace/src/runtime_metrics/client.js +30 -0
  629. package/packages/dd-trace/src/runtime_metrics/index.js +14 -4
  630. package/packages/dd-trace/src/runtime_metrics/otlp_runtime_metrics.js +284 -0
  631. package/packages/dd-trace/src/runtime_metrics/runtime_metrics.js +42 -41
  632. package/packages/dd-trace/src/sampling_rule.js +7 -7
  633. package/packages/dd-trace/src/scope.js +10 -15
  634. package/packages/dd-trace/src/serverless.js +6 -7
  635. package/packages/dd-trace/src/service-naming/extra-services.js +14 -0
  636. package/packages/dd-trace/src/service-naming/index.js +1 -1
  637. package/packages/dd-trace/src/service-naming/schemas/definition.js +4 -1
  638. package/packages/dd-trace/src/service-naming/schemas/util.js +48 -3
  639. package/packages/dd-trace/src/service-naming/schemas/v0/graphql.js +6 -0
  640. package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +61 -2
  641. package/packages/dd-trace/src/service-naming/schemas/v0/serverless.js +12 -0
  642. package/packages/dd-trace/src/service-naming/schemas/v0/storage.js +60 -0
  643. package/packages/dd-trace/src/service-naming/schemas/v0/web.js +25 -1
  644. package/packages/dd-trace/src/service-naming/schemas/v0/websocket.js +5 -0
  645. package/packages/dd-trace/src/service-naming/schemas/v1/graphql.js +8 -0
  646. package/packages/dd-trace/src/service-naming/schemas/v1/messaging.js +32 -0
  647. package/packages/dd-trace/src/service-naming/schemas/v1/serverless.js +12 -0
  648. package/packages/dd-trace/src/service-naming/schemas/v1/storage.js +17 -0
  649. package/packages/dd-trace/src/service-naming/schemas/v1/web.js +23 -3
  650. package/packages/dd-trace/src/service-naming/schemas/v1/websocket.js +6 -0
  651. package/packages/dd-trace/src/service-naming/source-resolver.js +50 -0
  652. package/packages/dd-trace/src/span_format.js +269 -81
  653. package/packages/dd-trace/src/span_processor.js +18 -13
  654. package/packages/dd-trace/src/span_stats.js +101 -79
  655. package/packages/dd-trace/src/spanleak.js +1 -2
  656. package/packages/dd-trace/src/standalone/index.js +0 -36
  657. package/packages/dd-trace/src/startup-log.js +3 -3
  658. package/packages/dd-trace/src/tagger.js +2 -4
  659. package/packages/dd-trace/src/telemetry/dependencies.js +2 -2
  660. package/packages/dd-trace/src/telemetry/endpoints.js +7 -5
  661. package/packages/dd-trace/src/telemetry/index.js +2 -2
  662. package/packages/dd-trace/src/telemetry/logs/index.js +1 -1
  663. package/packages/dd-trace/src/telemetry/send-data.js +22 -22
  664. package/packages/dd-trace/src/telemetry/session-propagation.js +1 -1
  665. package/packages/dd-trace/src/telemetry/telemetry.js +16 -14
  666. package/packages/dd-trace/src/tracer.js +23 -9
  667. package/packages/dd-trace/src/tracer_metadata.js +1 -1
  668. package/packages/dd-trace/src/util.js +57 -0
  669. package/register.js +58 -1
  670. package/vendor/dist/@apm-js-collab/code-transformer/index.js +94 -42
  671. package/vendor/dist/@datadog/sketches-js/LICENSE +10 -36
  672. package/vendor/dist/@datadog/sketches-js/index.js +1 -1
  673. package/vendor/dist/pprof-format/index.js +1 -1
  674. package/vendor/dist/protobufjs/index.js +1 -1
  675. package/vendor/dist/protobufjs/minimal/index.js +1 -1
  676. package/vendor/dist/shell-quote/index.js +1 -1
  677. package/packages/datadog-plugin-graphql/src/resolve.js +0 -178
  678. package/packages/dd-trace/src/agent/url.js +0 -28
  679. package/packages/dd-trace/src/appsec/api_security_sampler.js +0 -117
  680. package/packages/dd-trace/src/lambda/runtime/ritm.js +0 -133
  681. package/packages/dd-trace/src/log/utils.js +0 -16
  682. package/packages/dd-trace/src/msgpack/encoder.js +0 -308
  683. package/packages/dd-trace/src/plugins/structured_log_plugin.js +0 -9
  684. package/scripts/preinstall.js +0 -34
  685. package/vendor/dist/ignore/LICENSE +0 -21
  686. package/vendor/dist/ignore/index.js +0 -1
  687. package/vendor/dist/opentracing/LICENSE +0 -201
  688. package/vendor/dist/opentracing/binary_carrier.d.ts +0 -11
  689. package/vendor/dist/opentracing/constants.d.ts +0 -61
  690. package/vendor/dist/opentracing/examples/demo/demo.d.ts +0 -2
  691. package/vendor/dist/opentracing/ext/tags.d.ts +0 -90
  692. package/vendor/dist/opentracing/functions.d.ts +0 -20
  693. package/vendor/dist/opentracing/global_tracer.d.ts +0 -14
  694. package/vendor/dist/opentracing/index.d.ts +0 -12
  695. package/vendor/dist/opentracing/index.js +0 -1
  696. package/vendor/dist/opentracing/mock_tracer/index.d.ts +0 -5
  697. package/vendor/dist/opentracing/mock_tracer/mock_context.d.ts +0 -13
  698. package/vendor/dist/opentracing/mock_tracer/mock_report.d.ts +0 -16
  699. package/vendor/dist/opentracing/mock_tracer/mock_span.d.ts +0 -50
  700. package/vendor/dist/opentracing/mock_tracer/mock_tracer.d.ts +0 -26
  701. package/vendor/dist/opentracing/noop.d.ts +0 -8
  702. package/vendor/dist/opentracing/reference.d.ts +0 -33
  703. package/vendor/dist/opentracing/span.d.ts +0 -147
  704. package/vendor/dist/opentracing/span_context.d.ts +0 -26
  705. package/vendor/dist/opentracing/test/api_compatibility.d.ts +0 -16
  706. package/vendor/dist/opentracing/test/mocktracer_implemenation.d.ts +0 -3
  707. package/vendor/dist/opentracing/test/noop_implementation.d.ts +0 -4
  708. package/vendor/dist/opentracing/test/opentracing_api.d.ts +0 -3
  709. package/vendor/dist/opentracing/test/unittest.d.ts +0 -2
  710. package/vendor/dist/opentracing/tracer.d.ts +0 -127
  711. package/vendor/dist/path-to-regexp/LICENSE +0 -21
  712. package/vendor/dist/path-to-regexp/index.js +0 -1
@@ -1,11 +1,118 @@
1
1
  'use strict'
2
2
 
3
+ const NoopTracer = require('../../dd-trace/src/noop/tracer')
3
4
  const Plugin = require('../../dd-trace/src/plugins/plugin')
4
5
 
5
- // Cypress plugin does not patch any library. This is just a placeholder to
6
- // follow the structure of the plugins
6
+ /**
7
+ * Cypress plugin handles setup-node-events from the instrumentation layer
8
+ * via a diagnostic channel, keeping the instrumentation free of tracer references.
9
+ */
7
10
  class CypressPlugin extends Plugin {
8
11
  static id = 'cypress'
12
+
13
+ constructor (...args) {
14
+ super(...args)
15
+
16
+ this.addSub('ci:cypress:setup-node-events', (payload) => {
17
+ // Bail out if the tracer failed to init (e.g. invalid DD_SITE).
18
+ // Mirrors the guard in the manual plugin entrypoint (plugin.js).
19
+ if (this._tracer._tracer instanceof NoopTracer) return
20
+
21
+ const {
22
+ on,
23
+ config,
24
+ userAfterSpecHandlers,
25
+ userAfterRunHandlers,
26
+ userAfterScreenshotHandlers,
27
+ cleanupWrapper,
28
+ } = payload
29
+
30
+ const registerAfterRunWithCleanup = (afterRunHandler) => {
31
+ on('after:run', (results) => {
32
+ const chain = userAfterRunHandlers.reduce(
33
+ (p, h) => p.then(() => h(results)),
34
+ Promise.resolve()
35
+ )
36
+ if (afterRunHandler) {
37
+ return chain.then(() => afterRunHandler(results)).finally(cleanupWrapper)
38
+ }
39
+ return chain.finally(cleanupWrapper)
40
+ })
41
+ }
42
+
43
+ const cypressPlugin = require('./cypress-plugin')
44
+ const datadogAfterScreenshotHandler = cypressPlugin.getAfterScreenshotHandler()
45
+
46
+ // Cypress keeps a single after:screenshot handler, so registering the
47
+ // plugin's would drop any user handler (e.g. one that moves/renames a
48
+ // screenshot). Chain the user handler(s) first, threading the returned
49
+ // { path, size, dimensions } forward — Cypress uses the final path for
50
+ // downstream steps — then run the plugin's afterScreenshot on those
51
+ // details and propagate the value back to Cypress. The user handler runs
52
+ // regardless of whether screenshot upload is enabled.
53
+ const registerAfterScreenshot = (afterScreenshotHandler) => {
54
+ const filteredUserAfterScreenshotHandlers = userAfterScreenshotHandlers.filter(
55
+ handler => handler !== afterScreenshotHandler
56
+ )
57
+ if (filteredUserAfterScreenshotHandlers.length === 0) {
58
+ if (afterScreenshotHandler) on('after:screenshot', afterScreenshotHandler)
59
+ return
60
+ }
61
+
62
+ on('after:screenshot', (details) => {
63
+ const chain = filteredUserAfterScreenshotHandlers.reduce(
64
+ (p, h) => p.then((latestDetails) => Promise.resolve(h(latestDetails)).then(
65
+ // Merge the user handler's (possibly partial) return into the running details
66
+ // rather than replacing them, so Cypress metadata such as `testFailure` and
67
+ // `takenAt` survives a handler that only returns { path, size, dimensions }.
68
+ (returned) => (returned == null ? latestDetails : { ...latestDetails, ...returned })
69
+ )),
70
+ Promise.resolve(details)
71
+ )
72
+ return chain.then((finalDetails) => {
73
+ if (afterScreenshotHandler) afterScreenshotHandler(finalDetails)
74
+ return finalDetails
75
+ })
76
+ })
77
+ }
78
+
79
+ if (cypressPlugin._isInit) {
80
+ // Already initialized by manual plugin call — just chain user handlers.
81
+ // Pass the plugin's afterScreenshot so chaining a user handler doesn't drop the upload
82
+ // (the chained registration replaces the one plugin.js set, so it must include it).
83
+ if (userAfterSpecHandlers.length > 0) {
84
+ on('after:spec', (spec, results) => userAfterSpecHandlers.reduce(
85
+ (chain, handler) => chain.then(() => handler(spec, results)),
86
+ Promise.resolve()
87
+ ))
88
+ }
89
+ registerAfterScreenshot(datadogAfterScreenshotHandler)
90
+ registerAfterRunWithCleanup()
91
+ payload.registered = true
92
+ return
93
+ }
94
+
95
+ on('before:run', cypressPlugin.beforeRun.bind(cypressPlugin))
96
+ registerAfterScreenshot(datadogAfterScreenshotHandler)
97
+
98
+ on('after:spec', (spec, results) => {
99
+ const chain = userAfterSpecHandlers.reduce(
100
+ (p, h) => p.then(() => h(spec, results)),
101
+ Promise.resolve()
102
+ )
103
+ return chain.then(() => cypressPlugin.afterSpec(spec, results))
104
+ })
105
+
106
+ registerAfterRunWithCleanup((results) => cypressPlugin.afterRun(results))
107
+
108
+ on('task', cypressPlugin.getTasks())
109
+
110
+ payload.registered = true
111
+ // cypressPlugin.init expects the proxy tracer (with ._tracer._exporter),
112
+ // not the unwrapped internal tracer that this.tracer returns.
113
+ payload.configPromise = Promise.resolve(cypressPlugin.init(this._tracer, config)).then(() => config)
114
+ })
115
+ }
9
116
  }
10
117
 
11
118
  module.exports = CypressPlugin
@@ -23,22 +23,13 @@ const noopTask = {
23
23
  module.exports = function CypressPlugin (on, config) {
24
24
  const tracer = require('../../dd-trace')
25
25
 
26
- if (satisfies(config.version, '<10.2.0')) {
27
- if (DD_MAJOR >= 6) {
28
- // eslint-disable-next-line no-console
29
- console.error(
30
- 'ERROR: dd-trace v6 has deleted support for Cypress<10.2.0.'
31
- )
32
- on('task', noopTask)
33
- return config
34
- }
35
-
36
- // console.warn does not seem to work in cypress, so using console.log instead
26
+ if (DD_MAJOR >= 6 && satisfies(config.version, '<12.0.0')) {
37
27
  // eslint-disable-next-line no-console
38
- console.log(
39
- 'WARNING: dd-trace support for Cypress<10.2.0 is deprecated' +
40
- ' and will not be supported in future versions of dd-trace.'
28
+ console.error(
29
+ 'ERROR: dd-trace v6 has deleted support for Cypress<12.0.0.'
41
30
  )
31
+ on('task', noopTask)
32
+ return config
42
33
  }
43
34
 
44
35
  // The tracer was not init correctly for whatever reason (such as invalid DD_SITE)
@@ -49,6 +40,7 @@ module.exports = function CypressPlugin (on, config) {
49
40
  }
50
41
 
51
42
  on('before:run', cypressPlugin.beforeRun.bind(cypressPlugin))
43
+ on('after:screenshot', cypressPlugin.getAfterScreenshotHandler())
52
44
  on('after:spec', cypressPlugin.afterSpec.bind(cypressPlugin))
53
45
  on('after:run', cypressPlugin.afterRun.bind(cypressPlugin))
54
46
  on('task', cypressPlugin.getTasks())
@@ -165,6 +165,48 @@ function resolveOriginalSourcePosition (absoluteFilePath, generatedLine) {
165
165
  return null
166
166
  }
167
167
 
168
+ /**
169
+ * Given a generated file's absolute path, returns the first original source file
170
+ * referenced by its source map. This is useful for file-level metadata when the
171
+ * first generated line has no source mapping, such as TypeScript-emitted prologue
172
+ * statements.
173
+ * @param {string} absoluteFilePath - Absolute path to the generated file
174
+ * @returns {string | null}
175
+ */
176
+ function resolveOriginalSourceFile (absoluteFilePath) {
177
+ const sourceMap = getCachedSourceMap(absoluteFilePath)
178
+ if (!sourceMap) return null
179
+ const { mappings, sources, sourceRoot } = sourceMap
180
+ if (!mappings || !sources?.length) return null
181
+
182
+ const mapDir = path.dirname(absoluteFilePath)
183
+ const cursor = { pos: 0 }
184
+ let srcFile = 0
185
+
186
+ const lines = mappings.split(';')
187
+ for (const line of lines) {
188
+ if (!line) continue
189
+ cursor.pos = 0
190
+ while (cursor.pos < line.length) {
191
+ decodeVLQ(line, cursor) // genCol - not needed
192
+ if (cursor.pos < line.length && line[cursor.pos] !== ',') {
193
+ srcFile += decodeVLQ(line, cursor)
194
+ decodeVLQ(line, cursor) // srcLine - not needed
195
+ decodeVLQ(line, cursor) // srcCol - not needed
196
+ if (cursor.pos < line.length && line[cursor.pos] !== ',') {
197
+ decodeVLQ(line, cursor) // namesIndex - not needed
198
+ }
199
+
200
+ const sourcePath = sources[srcFile]
201
+ if (!sourcePath) return null
202
+ return resolveSourcePath(mapDir, sourceRoot, sourcePath)
203
+ }
204
+ if (cursor.pos < line.length && line[cursor.pos] === ',') cursor.pos++
205
+ }
206
+ }
207
+ return null
208
+ }
209
+
168
210
  /**
169
211
  * Convert a template literal body (the text between backticks, with `${…}` interpolations)
170
212
  * into a regex that matches the runtime-evaluated string. Each `${…}` expression is replaced
@@ -294,4 +336,9 @@ function resolveSourceLineForTest (absoluteFilePath, testName, invocationStack)
294
336
  return null
295
337
  }
296
338
 
297
- module.exports = { resolveOriginalSourcePosition, resolveSourceLineForTest, shouldTrustInvocationDetailsLine }
339
+ module.exports = {
340
+ resolveOriginalSourceFile,
341
+ resolveOriginalSourcePosition,
342
+ resolveSourceLineForTest,
343
+ shouldTrustInvocationDetailsLine,
344
+ }
@@ -1,7 +1,7 @@
1
1
  'use strict'
2
2
 
3
- const DD_CIVISIBILITY_TEST_EXECUTION_ID_COOKIE_NAME = 'datadog-ci-visibility-test-execution-id'
4
3
  let rumFlushWaitMillis = 500
4
+ let rumTestExecutionIdCookieName
5
5
 
6
6
  let isEarlyFlakeDetectionEnabled = false
7
7
  let isKnownTestsEnabled = false
@@ -13,10 +13,12 @@ let testManagementTests = {}
13
13
  let isImpactedTestsEnabled = false
14
14
  let isModifiedTest = false
15
15
  let isTestIsolationEnabled = false
16
+ let hasWarnedMissingBeforeEachTaskResult = false
17
+ let hasWarnedMissingBeforeEachRetryResult = false
16
18
  // Array of test names that have been retried and the reason
17
19
  const retryReasonsByTestName = new Map()
18
- // Track quarantined test errors - we catch them in Cypress.on('fail') but need to report to Datadog
19
- const quarantinedTestErrors = new Map()
20
+ // Track test errors suppressed by test management so we can still report them to Datadog.
21
+ const suppressedTestFailures = new Map()
20
22
 
21
23
  // Track the most recently loaded window in the AUT. Updated via the 'window:load'
22
24
  // event so we always get the real app window (after cy.visit()), not the
@@ -24,6 +26,40 @@ const quarantinedTestErrors = new Map()
24
26
  // to a cross-origin URL, safeGetRum() handles the access error.
25
27
  let originalWindow
26
28
 
29
+ let currentTestCommands = []
30
+ const commandStartTimes = new Map()
31
+ const INTERNAL_CYPRESS_COMMANDS = new Set(['wrap', 'then', 'noop'])
32
+
33
+ Cypress.on('command:start', (command) => {
34
+ commandStartTimes.set(command.get('id'), { startTime: Date.now(), name: command.get('name') })
35
+ })
36
+
37
+ Cypress.on('command:end', (command) => {
38
+ const id = command.get('id')
39
+ const entry = commandStartTimes.get(id)
40
+ commandStartTimes.delete(id)
41
+
42
+ const name = command.get('name')
43
+ const args = command.get('args')
44
+ if (name === 'task' && args && typeof args[0] === 'string' && args[0].startsWith('dd:')) {
45
+ return
46
+ }
47
+ if (INTERNAL_CYPRESS_COMMANDS.has(name)) {
48
+ return
49
+ }
50
+ if (entry == null) {
51
+ return
52
+ }
53
+ const err = command.get('err')
54
+ currentTestCommands.push({
55
+ name,
56
+ startTime: entry.startTime,
57
+ endTime: Date.now(),
58
+ // Serialize the error to a plain object so it survives cy.task JSON transport.
59
+ error: err ? { message: err.message, stack: err.stack, name: err.name } : null,
60
+ })
61
+ })
62
+
27
63
  // If the test is using multi domain with cy.origin, trying to access
28
64
  // window properties will result in a cross origin error.
29
65
  function safeGetRum (window) {
@@ -52,22 +88,170 @@ function getTestProperties (testName) {
52
88
  return { isAttemptToFix, isDisabled, isQuarantined }
53
89
  }
54
90
 
91
+ /**
92
+ * @param {string} message
93
+ * @returns {void}
94
+ */
95
+ function warnMissingBeforeEachTaskResult (message) {
96
+ // eslint-disable-next-line no-console
97
+ console.warn(message)
98
+ }
99
+
100
+ /**
101
+ * @param {object} test
102
+ * @returns {Cypress.Chainable<{ traceId?: string, shouldSkip?: boolean, shouldDiscard?: boolean }>}
103
+ */
104
+ function runBeforeEachTask (test) {
105
+ return cy.task('dd:beforeEach', test).then((taskResult) => {
106
+ if (taskResult !== undefined && taskResult !== null) {
107
+ return taskResult
108
+ }
109
+
110
+ if (!hasWarnedMissingBeforeEachTaskResult) {
111
+ hasWarnedMissingBeforeEachTaskResult = true
112
+ warnMissingBeforeEachTaskResult('Datadog Cypress dd:beforeEach task returned no result. Retrying once.')
113
+ }
114
+
115
+ return cy.task('dd:beforeEach', test).then((retryTaskResult) => {
116
+ if (retryTaskResult !== undefined && retryTaskResult !== null) {
117
+ return retryTaskResult
118
+ }
119
+
120
+ if (!hasWarnedMissingBeforeEachRetryResult) {
121
+ hasWarnedMissingBeforeEachRetryResult = true
122
+ warnMissingBeforeEachTaskResult(
123
+ 'Datadog Cypress dd:beforeEach task returned no result after retry. Continuing with an empty task result.'
124
+ )
125
+ }
126
+
127
+ return {}
128
+ })
129
+ })
130
+ }
131
+
132
+ /**
133
+ * @param {string} message
134
+ * @param {unknown} error
135
+ * @returns {false}
136
+ */
137
+ function logRumCorrelationCookieError (message, error) {
138
+ try {
139
+ Cypress.log({
140
+ name: 'dd-trace',
141
+ message,
142
+ consoleProps: () => ({ Error: error }),
143
+ })
144
+ } catch (loggingError) {
145
+ // eslint-disable-next-line no-console
146
+ console.error(message, error, loggingError)
147
+ }
148
+ return false
149
+ }
150
+
151
+ /**
152
+ * @param {unknown} error
153
+ * @returns {false}
154
+ */
155
+ function handleRumCorrelationCookieError (error) {
156
+ return logRumCorrelationCookieError('Could not set the RUM correlation cookie', error)
157
+ }
158
+
159
+ /**
160
+ * @param {unknown} error
161
+ * @returns {false}
162
+ */
163
+ function handleRumCorrelationCookieCleanupError (error) {
164
+ return logRumCorrelationCookieError('Could not clear the previous RUM correlation cookie', error)
165
+ }
166
+
167
+ /**
168
+ * @param {string} traceId
169
+ * @returns {Promise<boolean>}
170
+ */
171
+ function setRumCorrelationCookie (traceId) {
172
+ if (typeof cy.now !== 'function') {
173
+ return Cypress.Promise.resolve(handleRumCorrelationCookieError(new Error('Cypress cy.now is not available')))
174
+ }
175
+
176
+ let clearCookiePromise = Cypress.Promise.resolve()
177
+ if (!isTestIsolationEnabled) {
178
+ clearCookiePromise = Cypress.Promise.try(() => {
179
+ return cy.now('clearCookie', rumTestExecutionIdCookieName, { log: false })
180
+ }).then(undefined, handleRumCorrelationCookieCleanupError)
181
+ }
182
+
183
+ return clearCookiePromise.then(() => {
184
+ return Cypress.Promise.try(() => {
185
+ return cy.now('setCookie', rumTestExecutionIdCookieName, traceId, { log: false })
186
+ })
187
+ }).then(() => true, handleRumCorrelationCookieError)
188
+ }
189
+
190
+ /**
191
+ * @param {boolean} isCookieSet
192
+ * @returns {void}
193
+ */
194
+ function restartRumSession (isCookieSet) {
195
+ if (!isCookieSet || isTestIsolationEnabled || !originalWindow) {
196
+ return
197
+ }
198
+
199
+ const rum = safeGetRum(originalWindow)
200
+ if (rum) {
201
+ try {
202
+ const evt = new originalWindow.MouseEvent('click', { bubbles: true, cancelable: true })
203
+ // The browser-sdk addEventListener wrapper filters out untrusted synthetic events
204
+ // unless __ddIsTrusted is set. Set it so the click triggers expandOrRenewSession().
205
+ // See: https://github.com/DataDog/browser-sdk/blob/v6.27.1/packages/core/src/browser/addEventListener.ts#L119
206
+ Object.defineProperty(evt, '__ddIsTrusted', { value: true })
207
+ originalWindow.dispatchEvent(evt)
208
+ } catch {}
209
+ if (rum.startView) {
210
+ rum.startView()
211
+ }
212
+ }
213
+ }
214
+
55
215
  // Catch test failures for quarantined tests and suppress them
56
216
  // By not re-throwing the error, Cypress marks the test as passed
57
217
  // This allows quarantined tests to run but not affect the exit code
58
218
  Cypress.on('fail', (err, runnable) => {
219
+ // For commands that time out, command:end may never fire.
220
+ // Finalize any in-flight commands so their step spans carry the error.
221
+ const hadInFlightCommands = commandStartTimes.size > 0
222
+ for (const [, { startTime, name }] of commandStartTimes) {
223
+ if (INTERNAL_CYPRESS_COMMANDS.has(name)) continue
224
+ currentTestCommands.push({
225
+ name,
226
+ startTime,
227
+ endTime: Date.now(),
228
+ error: { message: err.message, stack: err.stack, name: err.name },
229
+ })
230
+ }
231
+ commandStartTimes.clear()
232
+
233
+ // If command:end fired for all commands (none in-flight) but the last command
234
+ // has no error, it means command:end fired before the error was attached to it.
235
+ if (!hadInFlightCommands && currentTestCommands.length > 0) {
236
+ // We have to support very old cypress versions in v5
237
+ // eslint-disable-next-line unicorn/prefer-at
238
+ const lastCommand = currentTestCommands[currentTestCommands.length - 1]
239
+ if (!lastCommand.error) {
240
+ lastCommand.error = { message: err.message, stack: err.stack, name: err.name }
241
+ }
242
+ }
243
+
59
244
  if (!isTestManagementEnabled) {
60
245
  throw err
61
246
  }
62
247
 
63
248
  const testName = runnable.fullTitle()
64
- const { isQuarantined, isDisabled } = getTestProperties(testName)
249
+ const { isAttemptToFix, isQuarantined, isDisabled } = getTestProperties(testName)
65
250
 
66
251
  // Suppress failures for quarantined or disabled tests so they don't affect the exit code.
67
- // This applies regardless of attempt-to-fix status: per spec, quarantined/disabled test
68
- // results are always ignored.
69
- if (isQuarantined || isDisabled) {
70
- quarantinedTestErrors.set(testName, err)
252
+ // Attempt-to-fix ignores quarantine/disabled suppression and keeps the normal framework result.
253
+ if (!isAttemptToFix && (isQuarantined || isDisabled)) {
254
+ suppressedTestFailures.set(testName, { error: err, isQuarantined, isDisabled })
71
255
  return
72
256
  }
73
257
 
@@ -80,6 +264,10 @@ function getRetriedTests (test, numRetries, tags) {
80
264
  // TODO: signal in framework logs that this is a retry.
81
265
  // TODO: Change it so these tests are allowed to fail.
82
266
  const clonedTest = test.clone()
267
+ disableFrameworkRetries(clonedTest)
268
+ if (tags.includes('_ddIsEfdRetry')) {
269
+ clonedTest._ddEfdRetryIndex = retryIndex + 1
270
+ }
83
271
  for (const tag of tags) {
84
272
  if (tag) {
85
273
  clonedTest[tag] = true
@@ -90,6 +278,19 @@ function getRetriedTests (test, numRetries, tags) {
90
278
  return retriedTests
91
279
  }
92
280
 
281
+ function disableFrameworkRetries (test) {
282
+ test._retries = 0
283
+ }
284
+
285
+ function shouldDisableFrameworkRetries (test) {
286
+ return test && (
287
+ test._ddIsAttemptToFix ||
288
+ (isTestIsolationEnabled &&
289
+ isEarlyFlakeDetectionEnabled &&
290
+ (test._ddIsNew || test._ddIsModified))
291
+ )
292
+ }
293
+
93
294
  const oldRunTests = Cypress.mocha.getRunner().runTests
94
295
  Cypress.mocha.getRunner().runTests = function (suite, fn) {
95
296
  if (!isKnownTestsEnabled && !isTestManagementEnabled && !isImpactedTestsEnabled) {
@@ -129,9 +330,11 @@ Cypress.mocha.getRunner().runTests = function (suite, fn) {
129
330
  let retryMessage = ''
130
331
  if (isAtemptToFix) {
131
332
  test._ddIsAttemptToFix = true
333
+ disableFrameworkRetries(test)
132
334
  retryMessage = 'because it is an attempt to fix'
133
335
  retriedTests = getRetriedTests(test, testManagementAttemptToFixRetries, ['_ddIsAttemptToFix'])
134
336
  } else if (isModified && isEarlyFlakeDetectionEnabled) {
337
+ disableFrameworkRetries(test)
135
338
  retryMessage = 'to detect flakes because it is modified'
136
339
  retriedTests = getRetriedTests(test, earlyFlakeDetectionNumRetries, [
137
340
  '_ddIsModified',
@@ -139,6 +342,7 @@ Cypress.mocha.getRunner().runTests = function (suite, fn) {
139
342
  isKnownTestsEnabled && isNewTest(test) && '_ddIsNew',
140
343
  ])
141
344
  } else if (isNew && isEarlyFlakeDetectionEnabled) {
345
+ disableFrameworkRetries(test)
142
346
  retryMessage = 'to detect flakes because it is new'
143
347
  retriedTests = getRetriedTests(test, earlyFlakeDetectionNumRetries, ['_ddIsNew', '_ddIsEfdRetry'])
144
348
  }
@@ -155,8 +359,21 @@ Cypress.mocha.getRunner().runTests = function (suite, fn) {
155
359
  return oldRunTests.apply(this, [suite, fn])
156
360
  }
157
361
 
362
+ Cypress.on('test:before:run', (attributes, test) => {
363
+ if (shouldDisableFrameworkRetries(test)) {
364
+ disableFrameworkRetries(test)
365
+ }
366
+ })
367
+
368
+ Cypress.on('test:before:run:async', (attributes, test) => {
369
+ if (shouldDisableFrameworkRetries(test)) {
370
+ disableFrameworkRetries(test)
371
+ }
372
+ })
373
+
158
374
  beforeEach(function () {
159
- const testName = Cypress.mocha.getRunner().suite.ctx.currentTest.fullTitle()
375
+ const currentTest = Cypress.mocha.getRunner().suite.ctx.currentTest
376
+ const testName = currentTest.fullTitle()
160
377
 
161
378
  const retryMessage = retryReasonsByTestName.get(testName)
162
379
  if (retryMessage) {
@@ -167,44 +384,38 @@ beforeEach(function () {
167
384
  retryReasonsByTestName.delete(testName)
168
385
  }
169
386
 
387
+ currentTestCommands = []
388
+ commandStartTimes.clear()
389
+
170
390
  cy.on('window:load', (win) => {
171
391
  originalWindow = win
172
392
  })
173
393
 
174
- cy.task('dd:beforeEach', {
394
+ runBeforeEachTask({
395
+ testId: currentTest.id,
175
396
  testName,
176
397
  testSuite: Cypress.mocha.getRootSuite().file,
177
- }).then(({ traceId, shouldSkip }) => {
398
+ isEfdRetry: Cypress.mocha.getRunner().suite.ctx.currentTest._ddIsEfdRetry,
399
+ efdRetryIndex: Cypress.mocha.getRunner().suite.ctx.currentTest._ddEfdRetryIndex,
400
+ }).then(({ traceId, shouldSkip, shouldDiscard }) => {
401
+ if (shouldDiscard) {
402
+ this.currentTest._ddShouldDiscard = true
403
+ }
404
+ let rumCookiePromise
178
405
  if (traceId) {
179
- cy.setCookie(DD_CIVISIBILITY_TEST_EXECUTION_ID_COOKIE_NAME, traceId).then(() => {
180
- // When testIsolation:false, the page is not reset between tests, so the RUM session
181
- // stopped in afterEach must be explicitly restarted so events in this test are
182
- // associated with the new testExecutionId.
183
- //
184
- // After stopSession(), the RUM SDK creates a new session upon a user interaction
185
- // (click, scroll, keydown, or touchstart). We dispatch a synthetic click on the window
186
- // to trigger session renewal, then call startView() to establish a view boundary.
187
- if (!isTestIsolationEnabled && originalWindow) {
188
- const rum = safeGetRum(originalWindow)
189
- if (rum) {
190
- try {
191
- const evt = new originalWindow.MouseEvent('click', { bubbles: true, cancelable: true })
192
- // The browser-sdk addEventListener wrapper filters out untrusted synthetic events
193
- // unless __ddIsTrusted is set. Set it so the click triggers expandOrRenewSession().
194
- // See: https://github.com/DataDog/browser-sdk/blob/v6.27.1/packages/core/src/browser/addEventListener.ts#L119
195
- Object.defineProperty(evt, '__ddIsTrusted', { value: true })
196
- originalWindow.dispatchEvent(evt)
197
- } catch {}
198
- if (rum.startView) {
199
- rum.startView()
200
- }
201
- }
202
- }
203
- })
406
+ rumCookiePromise = setRumCorrelationCookie(traceId)
204
407
  }
205
408
  if (shouldSkip) {
206
409
  this.skip()
207
410
  }
411
+ if (rumCookiePromise) {
412
+ return rumCookiePromise.then(restartRumSession)
413
+ }
414
+ }).then(() => {
415
+ // Clear any commands accumulated during DD-owned setup (e.g. setCookie, RUM restart)
416
+ // so they are not reported as user test steps.
417
+ currentTestCommands = []
418
+ commandStartTimes.clear()
208
419
  })
209
420
  })
210
421
 
@@ -224,6 +435,7 @@ before(function () {
224
435
  isImpactedTestsEnabled = suiteConfig.isImpactedTestsEnabled
225
436
  isModifiedTest = suiteConfig.isModifiedTest
226
437
  isTestIsolationEnabled = suiteConfig.isTestIsolationEnabled
438
+ rumTestExecutionIdCookieName = suiteConfig.rumTestExecutionIdCookieName
227
439
  if (Number.isFinite(suiteConfig.rumFlushWaitMillis)) {
228
440
  rumFlushWaitMillis = suiteConfig.rumFlushWaitMillis
229
441
  }
@@ -243,15 +455,19 @@ after(() => {
243
455
 
244
456
  afterEach(function () {
245
457
  const currentTest = Cypress.mocha.getRunner().suite.ctx.currentTest
458
+ if (currentTest._ddShouldDiscard) {
459
+ return
460
+ }
246
461
  const testName = currentTest.fullTitle()
247
462
 
248
- // Check if this was a quarantined test that we suppressed the failure for
249
- const quarantinedError = quarantinedTestErrors.get(testName)
250
- const isQuarantinedTestThatFailed = !!quarantinedError
463
+ // Check if this was a test management test that we suppressed the failure for.
464
+ const suppressedTestFailure = suppressedTestFailures.get(testName)
465
+ const suppressedError = suppressedTestFailure && suppressedTestFailure.error
466
+ const isTestManagementTestThatFailed = !!suppressedError
251
467
 
252
- // For quarantined tests, convert Error to a serializable format for cy.task
253
- const errorToReport = isQuarantinedTestThatFailed
254
- ? { message: quarantinedError.message, stack: quarantinedError.stack }
468
+ // For suppressed test management tests, convert Error to a serializable format for cy.task.
469
+ const errorToReport = isTestManagementTestThatFailed
470
+ ? { message: suppressedError.message, stack: suppressedError.stack }
255
471
  : currentTest.err
256
472
 
257
473
  const testInfo = {
@@ -259,16 +475,18 @@ afterEach(function () {
259
475
  testItTitle: currentTest.title,
260
476
  testSuite: Cypress.mocha.getRootSuite().file,
261
477
  testSuiteAbsolutePath: Cypress.spec && Cypress.spec.absolute,
262
- // For quarantined tests, report the actual state (failed) to Datadog, not what Cypress thinks (passed)
263
- state: isQuarantinedTestThatFailed ? 'failed' : currentTest.state,
264
- // For quarantined tests, include the actual error that was suppressed
478
+ // Report the actual failed state to Datadog, not the pass state Cypress sees after suppression.
479
+ state: isTestManagementTestThatFailed ? 'failed' : currentTest.state,
480
+ // Include the actual error that was suppressed.
265
481
  error: errorToReport,
266
482
  isNew: currentTest._ddIsNew,
267
483
  isEfdRetry: currentTest._ddIsEfdRetry,
268
484
  isAttemptToFix: currentTest._ddIsAttemptToFix,
269
485
  isModified: currentTest._ddIsModified,
270
- // Mark quarantined tests that failed so the plugin knows to tag them appropriately
271
- isQuarantined: isQuarantinedTestThatFailed,
486
+ duration: currentTest.duration,
487
+ // Mark suppressed tests so the plugin can tag them with the correct test management reason.
488
+ isQuarantined: isTestManagementTestThatFailed && suppressedTestFailure.isQuarantined,
489
+ isDisabled: isTestManagementTestThatFailed && suppressedTestFailure.isDisabled,
272
490
  }
273
491
  try {
274
492
  const invocationDetails = Cypress.mocha.getRunner().currentRunnable.invocationDetails
@@ -276,6 +494,9 @@ afterEach(function () {
276
494
  testInfo.testSourceStack = invocationDetails.stack
277
495
  } catch {}
278
496
 
497
+ // Snapshot before any DD-owned Cypress commands so they are not reported as test steps.
498
+ const commandsToReport = [...currentTestCommands]
499
+
279
500
  const rum = safeGetRum(originalWindow)
280
501
  if (rum) {
281
502
  testInfo.isRUMActive = true
@@ -292,10 +513,10 @@ afterEach(function () {
292
513
  // ignore error and continue
293
514
  }
294
515
 
295
- // Clean up the quarantined error tracking
296
- if (isQuarantinedTestThatFailed) {
297
- quarantinedTestErrors.delete(testName)
516
+ // Clean up the suppressed error tracking.
517
+ if (isTestManagementTestThatFailed) {
518
+ suppressedTestFailures.delete(testName)
298
519
  }
299
520
 
300
- cy.task('dd:afterEach', { test: testInfo, coverage })
521
+ cy.task('dd:afterEach', { test: testInfo, coverage, commands: commandsToReport })
301
522
  })
@@ -14,7 +14,7 @@ module.exports = class DdTraceApiPlugin extends Plugin {
14
14
  super(...args)
15
15
 
16
16
  const tracer = this._tracer
17
- const injectionEnabledTag = `injection_enabled:${this._tracerConfig.injectionEnabled ? 'yes' : 'no'}`
17
+ const injectionEnabledTag = `injection_enabled:${this._tracerConfig.DD_INJECTION_ENABLED ? 'yes' : 'no'}`
18
18
 
19
19
  this.addSub('datadog-api:v1:tracerinit', ({ proxy }) => {
20
20
  const proxyVal = proxy()