dd-trace 6.24.0 → 6.26.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 (352) hide show
  1. package/README.md +3 -0
  2. package/ci/cypress/support.js +2 -1
  3. package/ci/init.js +2 -22
  4. package/ci/vitest-no-worker-init-node-setup.mjs +2 -1
  5. package/ci/vitest-no-worker-init-runner-setup.mjs +2 -1
  6. package/ci/vitest-no-worker-init-setup.mjs +729 -724
  7. package/ci/vitest-no-worker-init-v5-setup.mjs +2 -1
  8. package/ext/exporters.js +0 -1
  9. package/index.d.ts +105 -5
  10. package/initialize.mjs +5 -2
  11. package/package.json +41 -36
  12. package/packages/datadog-esbuild/index.js +16 -70
  13. package/packages/datadog-esbuild/src/log.js +2 -29
  14. package/packages/datadog-instrumentations/src/ai.js +6 -1
  15. package/packages/datadog-instrumentations/src/aws-lambda.js +88 -0
  16. package/packages/datadog-instrumentations/src/cucumber.js +5 -2
  17. package/packages/datadog-instrumentations/src/cypress-config.js +20 -9
  18. package/packages/datadog-instrumentations/src/elevenlabs/activity.js +114 -0
  19. package/packages/datadog-instrumentations/src/elevenlabs/audio.js +104 -0
  20. package/packages/datadog-instrumentations/src/elevenlabs/index.js +288 -0
  21. package/packages/datadog-instrumentations/src/elevenlabs/session.js +444 -0
  22. package/packages/datadog-instrumentations/src/graphql.js +20 -17
  23. package/packages/datadog-instrumentations/src/helpers/bundler-esm-exports.js +582 -0
  24. package/packages/datadog-instrumentations/src/helpers/bundler-log.js +38 -0
  25. package/packages/datadog-instrumentations/src/helpers/bundler-transform.js +576 -0
  26. package/packages/datadog-instrumentations/src/helpers/bundler-utils.js +104 -0
  27. package/packages/datadog-instrumentations/src/helpers/fetch.js +51 -6
  28. package/packages/datadog-instrumentations/src/helpers/hook.js +29 -1
  29. package/packages/datadog-instrumentations/src/helpers/hooks.js +3 -7
  30. package/packages/datadog-instrumentations/src/helpers/lambda-handler.js +189 -0
  31. package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +8 -0
  32. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +26 -1
  33. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/async-mutex.js +41 -0
  34. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/elevenlabs.js +25 -0
  35. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql.js +0 -36
  36. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/modelcontextprotocol-client.js +30 -0
  37. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/modelcontextprotocol-server.js +23 -0
  38. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/next.js +61 -0
  39. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/openai-agents-realtime.js +23 -0
  40. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/postgres.js +33 -4
  41. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/trpc.js +148 -0
  42. package/packages/datadog-instrumentations/src/helpers/rewriter/target-patterns.json +80 -0
  43. package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +23 -3
  44. package/packages/datadog-instrumentations/src/helpers/rewriter/transforms/postgres.js +122 -0
  45. package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +59 -2
  46. package/packages/datadog-instrumentations/src/ioredis.js +101 -3
  47. package/packages/datadog-instrumentations/src/microgateway-core.js +1 -2
  48. package/packages/datadog-instrumentations/src/modelcontextprotocol-client.js +21 -0
  49. package/packages/datadog-instrumentations/src/modelcontextprotocol-sdk.js +7 -1
  50. package/packages/datadog-instrumentations/src/modelcontextprotocol-server.js +41 -0
  51. package/packages/datadog-instrumentations/src/next.js +203 -26
  52. package/packages/datadog-instrumentations/src/openai-agents-realtime.js +149 -0
  53. package/packages/datadog-instrumentations/src/openai-realtime/audio-accumulator.js +27 -0
  54. package/packages/datadog-instrumentations/src/openai-realtime/index.js +17 -6
  55. package/packages/datadog-instrumentations/src/openai-realtime/server-playback.js +887 -0
  56. package/packages/datadog-instrumentations/src/openai-realtime/session.js +150 -25
  57. package/packages/datadog-instrumentations/src/openai-realtime/turns.js +29 -2
  58. package/packages/datadog-instrumentations/src/otel-sdk-trace.js +11 -9
  59. package/packages/datadog-instrumentations/src/router.js +35 -12
  60. package/packages/datadog-instrumentations/src/vitest-main.js +10 -2
  61. package/packages/datadog-instrumentations/src/webdriverio.js +12 -12
  62. package/packages/datadog-plugin-async-mutex/src/index.js +50 -0
  63. package/packages/datadog-plugin-aws-lambda/src/arn.js +41 -0
  64. package/packages/datadog-plugin-aws-lambda/src/event-type-guards.js +170 -0
  65. package/packages/datadog-plugin-aws-lambda/src/index.js +106 -0
  66. package/packages/datadog-plugin-aws-lambda/src/trigger.js +339 -0
  67. package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +7 -0
  68. package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +32 -10
  69. package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +10 -1
  70. package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +4 -0
  71. package/packages/datadog-plugin-aws-sdk/src/services/stepfunctions.js +3 -0
  72. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +50 -13
  73. package/packages/datadog-plugin-cypress/src/support.mjs +1353 -0
  74. package/packages/datadog-plugin-elevenlabs/src/index.js +69 -0
  75. package/packages/datadog-plugin-express/src/code_origin.js +2 -2
  76. package/packages/datadog-plugin-fastify/src/code_origin.js +2 -2
  77. package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +20 -7
  78. package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +21 -52
  79. package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +11 -2
  80. package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-request-context.js +25 -4
  81. package/packages/datadog-plugin-google-cloud-pubsub/src/resource-names.js +24 -0
  82. package/packages/datadog-plugin-graphql/src/tools/transforms.js +1 -0
  83. package/packages/datadog-plugin-http/src/client.js +34 -10
  84. package/packages/datadog-plugin-http2/src/client.js +40 -14
  85. package/packages/datadog-plugin-modelcontextprotocol-sdk/src/tracing.js +28 -2
  86. package/packages/datadog-plugin-modelcontextprotocol-sdk/src/utils.js +1 -0
  87. package/packages/datadog-plugin-mongodb-core/src/query.js +17 -1
  88. package/packages/datadog-plugin-next/src/index.js +112 -14
  89. package/packages/datadog-plugin-postgres/src/index.js +118 -41
  90. package/packages/datadog-plugin-prisma/src/datadog-tracing-helper.js +5 -3
  91. package/packages/datadog-plugin-supabase/src/supabase-auth-js-gotrueclient-getuser.js +18 -8
  92. package/packages/datadog-plugin-supabase/src/supabase-functions-js-functionsclient-invoke.js +49 -13
  93. package/packages/datadog-plugin-supabase/src/supabase-storage-js-handle-request.js +34 -9
  94. package/packages/datadog-plugin-trpc/src/index.js +15 -0
  95. package/packages/datadog-plugin-trpc/src/procedure.js +48 -0
  96. package/packages/datadog-plugin-trpc/src/request.js +81 -0
  97. package/packages/datadog-plugin-undici/src/index.js +22 -7
  98. package/packages/datadog-plugin-vitest/src/index.js +3 -2
  99. package/packages/datadog-plugin-ws/src/close.js +3 -5
  100. package/packages/datadog-plugin-ws/src/producer.js +1 -4
  101. package/packages/datadog-plugin-ws/src/receiver.js +3 -5
  102. package/packages/datadog-plugin-ws/src/server.js +44 -13
  103. package/packages/datadog-turbopack/index.js +4 -28
  104. package/packages/datadog-turbopack/src/loader.js +14 -452
  105. package/packages/datadog-vite/index.js +537 -0
  106. package/packages/datadog-vite/src/log.js +5 -0
  107. package/packages/datadog-webpack/index.js +3 -55
  108. package/packages/datadog-webpack/src/log.js +2 -29
  109. package/packages/dd-trace/src/aiguard/evaluation.js +62 -1
  110. package/packages/dd-trace/src/aiguard/index.js +1 -1
  111. package/packages/dd-trace/src/aiguard/integrations/index.js +6 -5
  112. package/packages/dd-trace/src/aiguard/sdk.js +8 -2
  113. package/packages/dd-trace/src/aiguard/tags.js +2 -0
  114. package/packages/dd-trace/src/appsec/blocking/index.js +21 -1
  115. package/packages/dd-trace/src/appsec/channels.js +7 -0
  116. package/packages/dd-trace/src/appsec/downstream_requests.js +105 -0
  117. package/packages/dd-trace/src/appsec/graphql.js +89 -7
  118. package/packages/dd-trace/src/appsec/handlers/auth.js +1 -3
  119. package/packages/dd-trace/src/appsec/handlers/http-request.js +60 -65
  120. package/packages/dd-trace/src/appsec/handlers/http-response.js +61 -7
  121. package/packages/dd-trace/src/appsec/handlers/payments.js +23 -27
  122. package/packages/dd-trace/src/appsec/index.js +6 -0
  123. package/packages/dd-trace/src/appsec/lambda.js +17 -17
  124. package/packages/dd-trace/src/appsec/rasp/command_injection.js +4 -4
  125. package/packages/dd-trace/src/appsec/rasp/index.js +8 -1
  126. package/packages/dd-trace/src/appsec/rasp/lfi.js +2 -2
  127. package/packages/dd-trace/src/appsec/rasp/sql_injection.js +7 -17
  128. package/packages/dd-trace/src/appsec/rasp/ssrf.js +80 -16
  129. package/packages/dd-trace/src/appsec/rasp/utils.js +33 -3
  130. package/packages/dd-trace/src/appsec/recommended.json +1358 -94
  131. package/packages/dd-trace/src/appsec/reporter.js +9 -0
  132. package/packages/dd-trace/src/appsec/sdk/set_user.js +3 -3
  133. package/packages/dd-trace/src/appsec/sdk/track_event.js +4 -4
  134. package/packages/dd-trace/src/appsec/sdk/user_blocking.js +1 -1
  135. package/packages/dd-trace/src/appsec/user_tracking.js +6 -8
  136. package/packages/dd-trace/src/appsec/waf/index.js +65 -6
  137. package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +33 -38
  138. package/packages/dd-trace/src/appsec/waf/waf_manager.js +18 -2
  139. package/packages/dd-trace/src/before-exit.js +32 -0
  140. package/packages/dd-trace/src/bootstrap.js +5 -3
  141. package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +15 -2
  142. package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +12 -34
  143. package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +41 -13
  144. package/packages/dd-trace/src/ci-visibility/exporters/request.js +2 -3
  145. package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +1 -2
  146. package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +1 -1
  147. package/packages/dd-trace/src/ci-visibility/telemetry.js +6 -0
  148. package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +1 -1
  149. package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache-schema.js +9 -134
  150. package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache.js +11 -156
  151. package/packages/dd-trace/src/config/config-types.d.ts +3 -0
  152. package/packages/dd-trace/src/config/defaults.js +5 -0
  153. package/packages/dd-trace/src/config/generated-config-types.d.ts +46 -4
  154. package/packages/dd-trace/src/config/index.js +63 -31
  155. package/packages/dd-trace/src/config/parsers.js +44 -0
  156. package/packages/dd-trace/src/config/remote-config-layers.js +38 -0
  157. package/packages/dd-trace/src/config/remote_config.js +2 -1
  158. package/packages/dd-trace/src/config/supported-configurations.json +172 -10
  159. package/packages/dd-trace/src/constants.js +1 -0
  160. package/packages/dd-trace/src/datastreams/fnv.js +27 -0
  161. package/packages/dd-trace/src/datastreams/pathway.js +113 -28
  162. package/packages/dd-trace/src/datastreams/processor.js +5 -4
  163. package/packages/dd-trace/src/debugger/config.js +1 -1
  164. package/packages/dd-trace/src/debugger/devtools_client/request-options.js +7 -9
  165. package/packages/dd-trace/src/debugger/devtools_client/send.js +1 -1
  166. package/packages/dd-trace/src/debugger/devtools_client/state.js +3 -1
  167. package/packages/dd-trace/src/debugger/devtools_client/tags.js +1 -1
  168. package/packages/dd-trace/src/debugger/index.js +2 -2
  169. package/packages/dd-trace/src/debugger/inspect-segment.js +3 -2
  170. package/packages/dd-trace/src/debugger/pause-duration-histogram.js +6 -2
  171. package/packages/dd-trace/src/debugger/probe_sampler.js +39 -17
  172. package/packages/dd-trace/src/debugger/unsupported-runtime.js +2 -0
  173. package/packages/dd-trace/src/exporter.js +0 -11
  174. package/packages/dd-trace/src/exporters/common/request.js +81 -48
  175. package/packages/dd-trace/src/exporters/common/retry.js +12 -7
  176. package/packages/dd-trace/src/exporters/common/url.js +1 -1
  177. package/packages/dd-trace/src/git_metadata.js +2 -1
  178. package/packages/dd-trace/src/id.js +1 -1
  179. package/packages/dd-trace/src/index.js +6 -3
  180. package/packages/dd-trace/src/lambda/facade.js +75 -0
  181. package/packages/dd-trace/src/lambda/handler.js +3 -41
  182. package/packages/dd-trace/src/lambda/index.js +38 -15
  183. package/packages/dd-trace/src/lambda/runtime/patch.js +19 -3
  184. package/packages/dd-trace/src/lambda/wrap.js +44 -0
  185. package/packages/dd-trace/src/llmobs/constants/tags.js +2 -0
  186. package/packages/dd-trace/src/llmobs/experiments/experiment.js +10 -5
  187. package/packages/dd-trace/src/llmobs/plugins/elevenlabs.js +96 -0
  188. package/packages/dd-trace/src/llmobs/plugins/genai/util.js +19 -6
  189. package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/index.js +54 -3
  190. package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/utils.js +81 -1
  191. package/packages/dd-trace/src/llmobs/plugins/openai/realtime.js +38 -11
  192. package/packages/dd-trace/src/llmobs/plugins/vertexai.js +10 -2
  193. package/packages/dd-trace/src/llmobs/sdk.js +19 -0
  194. package/packages/dd-trace/src/llmobs/span_processor.js +9 -0
  195. package/packages/dd-trace/src/llmobs/tagger.js +22 -0
  196. package/packages/dd-trace/src/log/channels.js +4 -0
  197. package/packages/dd-trace/src/log/writer.js +6 -1
  198. package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +7 -0
  199. package/packages/dd-trace/src/openfeature/configuration_source.js +55 -27
  200. package/packages/dd-trace/src/openfeature/flag-selection.js +152 -0
  201. package/packages/dd-trace/src/openfeature/flagging_provider.js +19 -1
  202. package/packages/dd-trace/src/openfeature/writers/base.js +1 -3
  203. package/packages/dd-trace/src/opentelemetry/logs/index.js +11 -0
  204. package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +1 -1
  205. package/packages/dd-trace/src/opentelemetry/metrics/index.js +7 -1
  206. package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +1 -1
  207. package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_exporter.js +4 -1
  208. package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +19 -1
  209. package/packages/dd-trace/src/opentelemetry/span-ending-hook.js +5 -1
  210. package/packages/dd-trace/src/opentelemetry/span-helpers.js +6 -1
  211. package/packages/dd-trace/src/opentelemetry/span.js +2 -2
  212. package/packages/dd-trace/src/opentelemetry/startup-config.js +174 -0
  213. package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +1 -1
  214. package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +7 -1
  215. package/packages/dd-trace/src/opentracing/propagation/tracestate.js +77 -23
  216. package/packages/dd-trace/src/opentracing/tracer.js +24 -0
  217. package/packages/dd-trace/src/otel-thread-ctx.js +28 -31
  218. package/packages/dd-trace/src/plugin_manager.js +34 -7
  219. package/packages/dd-trace/src/plugins/ci_plugin.js +143 -17
  220. package/packages/dd-trace/src/plugins/index.js +8 -0
  221. package/packages/dd-trace/src/plugins/plugin.js +4 -2
  222. package/packages/dd-trace/src/plugins/tracing.js +1 -1
  223. package/packages/dd-trace/src/plugins/util/ci.js +52 -1
  224. package/packages/dd-trace/src/plugins/util/git-cache.js +4 -4
  225. package/packages/dd-trace/src/plugins/util/git.js +263 -82
  226. package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +80 -56
  227. package/packages/dd-trace/src/plugins/util/inferred_proxy.js +12 -4
  228. package/packages/dd-trace/src/plugins/util/status-validator.js +23 -10
  229. package/packages/dd-trace/src/plugins/util/tags.js +6 -0
  230. package/packages/dd-trace/src/plugins/util/test.js +92 -40
  231. package/packages/dd-trace/src/plugins/util/url.js +18 -7
  232. package/packages/dd-trace/src/plugins/util/user-provided-git.js +6 -6
  233. package/packages/dd-trace/src/plugins/util/web.js +65 -10
  234. package/packages/dd-trace/src/process-tags/index.js +1 -1
  235. package/packages/dd-trace/src/profiler.js +74 -12
  236. package/packages/dd-trace/src/profiling/profiler.js +30 -2
  237. package/packages/dd-trace/src/profiling/profilers/space.js +3 -1
  238. package/packages/dd-trace/src/profiling/profilers/wall.js +4 -4
  239. package/packages/dd-trace/src/profiling/remote-config.js +354 -0
  240. package/packages/dd-trace/src/profiling/runtime-capabilities.js +11 -0
  241. package/packages/dd-trace/src/profiling/webspan-utils.js +6 -5
  242. package/packages/dd-trace/src/propagation-hash/index.js +7 -0
  243. package/packages/dd-trace/src/proxy.js +46 -54
  244. package/packages/dd-trace/src/span_processor.js +20 -0
  245. package/packages/dd-trace/src/startup-log.js +8 -6
  246. package/packages/dd-trace/src/telemetry/metrics.js +2 -1
  247. package/packages/dd-trace/src/tracer.js +0 -2
  248. package/packages/dd-trace/src/web-tags-cache.js +8 -9
  249. package/register.js +2 -1
  250. package/vendor/dist/@apm-js-collab/code-transformer/LICENSE +489 -0
  251. package/vendor/dist/@datadog/flagging-core/LICENSE +221 -0
  252. package/vendor/dist/@datadog/flagging-core/index.js +1 -0
  253. package/vendor/dist/@datadog/openfeature-node-server/LICENSE +21 -1
  254. package/vendor/dist/@datadog/openfeature-node-server/rules-based/LICENSE +3 -1
  255. package/vendor/dist/@datadog/sketches-js/LICENSE +263 -0
  256. package/vendor/dist/@datadog/source-map/LICENSE +1 -0
  257. package/vendor/dist/@isaacs/ttlcache/LICENSE +13 -0
  258. package/vendor/dist/@opentelemetry/core/LICENSE +220 -1
  259. package/vendor/dist/@opentelemetry/core/index.js +1 -1
  260. package/vendor/dist/crypto-randomuuid/LICENSE +3 -0
  261. package/vendor/dist/escape-string-regexp/LICENSE +13 -0
  262. package/vendor/dist/esquery/LICENSE +2 -0
  263. package/vendor/dist/https-proxy-agent/LICENSE +80 -1
  264. package/vendor/dist/istanbul-lib-coverage/LICENSE +2 -0
  265. package/vendor/dist/jest-docblock/LICENSE +16 -0
  266. package/vendor/dist/jsonpath-plus/LICENSE +13 -0
  267. package/vendor/dist/limiter/LICENSE +2 -0
  268. package/vendor/dist/lodash.sortby/LICENSE +2 -0
  269. package/vendor/dist/lru-cache/LICENSE +13 -0
  270. package/vendor/dist/meriyah/LICENSE +13 -0
  271. package/vendor/dist/module-details-from-path/LICENSE +2 -0
  272. package/vendor/dist/mutexify/promise/LICENSE +28 -0
  273. package/vendor/dist/pprof-format/LICENSE +13 -0
  274. package/vendor/dist/pprof-format/index.js +1 -1
  275. package/vendor/dist/protobufjs/LICENSE +219 -0
  276. package/vendor/dist/protobufjs/minimal/LICENSE +219 -0
  277. package/vendor/dist/proxy-from-env/LICENSE +13 -0
  278. package/vendor/dist/retry/LICENSE +2 -0
  279. package/vendor/dist/rfdc/LICENSE +2 -0
  280. package/vendor/dist/semifies/LICENSE +3 -1
  281. package/vendor/dist/shell-quote/LICENSE +3 -1
  282. package/vendor/dist/source-map/LICENSE +1 -0
  283. package/vendor/dist/source-map/lib/util/LICENSE +1 -0
  284. package/vendor/dist/tlhunter-sorted-set/LICENSE +2 -0
  285. package/vendor/dist/ttl-set/LICENSE +28 -0
  286. package/vite.d.ts +7 -0
  287. package/vite.js +3 -0
  288. package/ci/diagnose.js +0 -2215
  289. package/ci/runbook.md +0 -299
  290. package/ci/test-optimization-validation/approval-artifacts.js +0 -175
  291. package/ci/test-optimization-validation/approval.js +0 -386
  292. package/ci/test-optimization-validation/artifact-id.js +0 -18
  293. package/ci/test-optimization-validation/blocker-category.js +0 -24
  294. package/ci/test-optimization-validation/bounded-json.js +0 -120
  295. package/ci/test-optimization-validation/ci-command-candidate.js +0 -77
  296. package/ci/test-optimization-validation/ci-discovery.js +0 -192
  297. package/ci/test-optimization-validation/ci-package-scripts.js +0 -169
  298. package/ci/test-optimization-validation/ci-remediation.js +0 -283
  299. package/ci/test-optimization-validation/cli.js +0 -954
  300. package/ci/test-optimization-validation/command-blocker.js +0 -377
  301. package/ci/test-optimization-validation/command-output-policy.js +0 -188
  302. package/ci/test-optimization-validation/command-runner.js +0 -649
  303. package/ci/test-optimization-validation/environment.js +0 -88
  304. package/ci/test-optimization-validation/executable-approval.js +0 -47
  305. package/ci/test-optimization-validation/executable.js +0 -244
  306. package/ci/test-optimization-validation/execution-lock.js +0 -70
  307. package/ci/test-optimization-validation/framework-adapters/cucumber-validation.json +0 -3
  308. package/ci/test-optimization-validation/framework-adapters/cucumber.js +0 -767
  309. package/ci/test-optimization-validation/framework-adapters/cypress.js +0 -99
  310. package/ci/test-optimization-validation/framework-adapters/playwright.js +0 -175
  311. package/ci/test-optimization-validation/framework-adapters/vitest.js +0 -513
  312. package/ci/test-optimization-validation/generated-file-policy.js +0 -63
  313. package/ci/test-optimization-validation/generated-files.js +0 -425
  314. package/ci/test-optimization-validation/generated-test-contract.js +0 -284
  315. package/ci/test-optimization-validation/generated-verifier.js +0 -235
  316. package/ci/test-optimization-validation/literal-environment.js +0 -56
  317. package/ci/test-optimization-validation/literal-glob.js +0 -52
  318. package/ci/test-optimization-validation/manifest-loader.js +0 -116
  319. package/ci/test-optimization-validation/manifest-scaffold.js +0 -1276
  320. package/ci/test-optimization-validation/manifest-schema.js +0 -695
  321. package/ci/test-optimization-validation/offline-fixtures.js +0 -335
  322. package/ci/test-optimization-validation/offline-output.js +0 -406
  323. package/ci/test-optimization-validation/package-check.js +0 -97
  324. package/ci/test-optimization-validation/payload-normalizer.js +0 -72
  325. package/ci/test-optimization-validation/plan-writer.js +0 -541
  326. package/ci/test-optimization-validation/preflight-runner.js +0 -186
  327. package/ci/test-optimization-validation/project-build-artifact.js +0 -31
  328. package/ci/test-optimization-validation/redaction.js +0 -319
  329. package/ci/test-optimization-validation/report-writer.js +0 -666
  330. package/ci/test-optimization-validation/result-semantics.js +0 -103
  331. package/ci/test-optimization-validation/runner-command.js +0 -264
  332. package/ci/test-optimization-validation/runner-contract.js +0 -695
  333. package/ci/test-optimization-validation/safe-files.js +0 -202
  334. package/ci/test-optimization-validation/scenarios/auto-test-retries.js +0 -171
  335. package/ci/test-optimization-validation/scenarios/basic-reporting.js +0 -407
  336. package/ci/test-optimization-validation/scenarios/ci-wiring.js +0 -666
  337. package/ci/test-optimization-validation/scenarios/early-flake-detection.js +0 -142
  338. package/ci/test-optimization-validation/scenarios/helpers.js +0 -621
  339. package/ci/test-optimization-validation/scenarios/test-management.js +0 -219
  340. package/ci/test-optimization-validation/source-text.js +0 -84
  341. package/ci/test-optimization-validation/static-diagnosis.js +0 -166
  342. package/ci/test-optimization-validation/test-output.js +0 -120
  343. package/ci/test-optimization-validation/validation-blocker.js +0 -21
  344. package/ci/validate-test-optimization.js +0 -3
  345. package/packages/datadog-esbuild/src/resolver.js +0 -284
  346. package/packages/datadog-esbuild/src/utils.js +0 -318
  347. package/packages/datadog-plugin-cypress/src/support.js +0 -1348
  348. package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/index.js +0 -156
  349. package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/msgpack-to-json.js +0 -287
  350. package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/payload-projection.js +0 -84
  351. package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/sink.js +0 -368
  352. package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/writer.js +0 -59
@@ -7,4 +7,5 @@ captureDeclarations(test, TestRunner.getCurrentSuite)
7
7
  globalThis[Symbol.for('dd-trace.vitest.browser-context-importer')] = () => import('vitest/browser')
8
8
  globalThis[Symbol.for('dd-trace.vitest.skip-task')] = skip => skip('Skipped by Datadog Test Optimization')
9
9
 
10
- await import('./vitest-no-worker-init-setup.mjs')
10
+ const { setup } = await import('./vitest-no-worker-init-setup.mjs')
11
+ setup()
package/ext/exporters.js CHANGED
@@ -6,7 +6,6 @@ module.exports = {
6
6
  AGENTLESS: 'agentless',
7
7
  DATADOG: 'datadog',
8
8
  AGENT_PROXY: 'agent_proxy',
9
- CI_VALIDATION: 'ci_validation',
10
9
  JEST_WORKER: 'jest_worker',
11
10
  CUCUMBER_WORKER: 'cucumber_worker',
12
11
  MOCHA_WORKER: 'mocha_worker',
package/index.d.ts CHANGED
@@ -213,7 +213,9 @@ interface Tracer extends opentracing.Tracer {
213
213
  /**
214
214
  * OpenFeature Provider with agentless and Agent Remote Config delivery.
215
215
  *
216
- * Agentless delivery is enabled by default and starts when the provider is first accessed.
216
+ * Agentless delivery is enabled by default and starts when the provider is first accessed. The default agentless
217
+ * endpoint requires DD_API_KEY. Without it, provider initialization fails at once. A custom agentless base URL
218
+ * and Remote Config delivery do not need the key.
217
219
  *
218
220
  * @env DD_FEATURE_FLAGS_ENABLED
219
221
  * @env DD_FEATURE_FLAGS_CONFIGURATION_SOURCE
@@ -291,8 +293,10 @@ interface Plugins {
291
293
  "anthropic": tracer.plugins.anthropic;
292
294
  "claude-agent-sdk": tracer.plugins.claude_agent_sdk;
293
295
  "apollo": tracer.plugins.apollo;
296
+ "async-mutex": tracer.plugins.async_mutex;
294
297
  "avsc": tracer.plugins.avsc;
295
298
  "aws-durable-execution-sdk-js": tracer.plugins.aws_durable_execution_sdk_js;
299
+ "aws-lambda": tracer.plugins.aws_lambda;
296
300
  "aws-sdk": tracer.plugins.aws_sdk;
297
301
  "azure-cosmos": tracer.plugins.azure_cosmos;
298
302
  "azure-event-hubs": tracer.plugins.azure_event_hubs;
@@ -312,6 +316,7 @@ interface Plugins {
312
316
  "dns": tracer.plugins.dns;
313
317
  "elasticsearch": tracer.plugins.elasticsearch;
314
318
  "electron": tracer.plugins.electron;
319
+ "elevenlabs": tracer.plugins.elevenlabs;
315
320
  "express": tracer.plugins.express;
316
321
  "fastify": tracer.plugins.fastify;
317
322
  "fetch": tracer.plugins.fetch;
@@ -366,6 +371,7 @@ interface Plugins {
366
371
  "sharedb": tracer.plugins.sharedb;
367
372
  "supabase": tracer.plugins.supabase;
368
373
  "tedious": tracer.plugins.tedious;
374
+ "trpc": tracer.plugins.trpc;
369
375
  "typesafe": tracer.plugins.typesafe;
370
376
  "undici": tracer.plugins.undici;
371
377
  "vitest": tracer.plugins.vitest;
@@ -834,6 +840,25 @@ declare namespace tracer {
834
840
  * @env DD_FEATURE_FLAGS_EVALUATION_TELEMETRY_PER_SUBJECT_OPT_OUT_ENABLED
835
841
  */
836
842
  enableEvaluationTelemetryOptOutParameter?: boolean
843
+
844
+ /**
845
+ * Loads only the flags that have any of these tags or whose key matches any of these key patterns,
846
+ * instead of every flag. Each list accepts at most 31 values of at most 200 UTF-8 bytes each.
847
+ * A selection that cannot be sent is dropped with an error log, and every flag is loaded.
848
+ * Programmatic only, with no environment variable, so `dd-trace/init` cannot set it.
849
+ * Captured when `tracer.openfeature` is first accessed. Agentless delivery only.
850
+ */
851
+ flagSelection?: {
852
+ /**
853
+ * Flag tags, such as `checkout`, matched exactly and case-sensitively.
854
+ */
855
+ tags?: string[]
856
+ /**
857
+ * Flag key patterns, such as `checkout.*`, matched case-sensitively against the whole key.
858
+ * `*` matches any run of characters, including none; every other character, including `?`, is literal.
859
+ */
860
+ keyPatterns?: string[]
861
+ }
837
862
  }
838
863
 
839
864
  /**
@@ -922,7 +947,8 @@ declare namespace tracer {
922
947
  enabled?: boolean
923
948
  /**
924
949
  * Timeout in milliseconds for OpenFeature provider initialization.
925
- * If configuration is not received within this time, initialization fails.
950
+ * If configuration is not received within this time, initialization fails. It fails at once when the agentless
951
+ * configuration source cannot start, such as the default endpoint without DD_API_KEY.
926
952
  * Can be configured via DD_EXPERIMENTAL_FLAGGING_PROVIDER_INITIALIZATION_TIMEOUT_MS environment variable.
927
953
  *
928
954
  * @default 30000
@@ -2020,11 +2046,21 @@ declare namespace tracer {
2020
2046
  * @param opts - Optional configuration object:
2021
2047
  * - `block`: When true, throws an exception if evaluation result is not 'ALLOW'
2022
2048
  * and the AI Guard service has blocking mode enabled (default: false).
2049
+ * - `tags`: Custom tags to set on the AI Guard span. Keys are set verbatim. Keys equal to
2050
+ * `ai_guard` or starting with `ai_guard.` are reserved and ignored. Entries with an
2051
+ * empty key, a key longer than 200 characters, a string value longer than 25000
2052
+ * characters, or a value that is not a string, finite number or boolean are dropped.
2023
2053
  * @returns Promise resolving to an Evaluation with the security decision and reasoning.
2024
2054
  * The promise rejects with AIGuardAbortError when `opts.block` is true and the evaluation result would block the request.
2025
2055
  * The promise rejects with AIGuardClientError when communication with the AI Guard service fails.
2026
2056
  */
2027
- evaluate (messages: Message[], opts?: { block?: boolean }): Promise<Evaluation>;
2057
+ evaluate (
2058
+ messages: Message[],
2059
+ opts?: {
2060
+ block?: boolean,
2061
+ tags?: { [key: string]: string | number | boolean },
2062
+ }
2063
+ ): Promise<Evaluation>;
2028
2064
  }
2029
2065
  }
2030
2066
 
@@ -2418,6 +2454,12 @@ declare namespace tracer {
2418
2454
  };
2419
2455
  }
2420
2456
 
2457
+ /**
2458
+ * This plugin automatically instruments the
2459
+ * [async-mutex](https://github.com/DirtyHairy/async-mutex) module.
2460
+ */
2461
+ interface async_mutex extends Instrumentation {}
2462
+
2421
2463
  /**
2422
2464
  * This plugin automatically patches the [avsc](https://github.com/mtth/avsc) module
2423
2465
  * to collect avro message schemas when Datastreams Monitoring is enabled.
@@ -2430,6 +2472,46 @@ declare namespace tracer {
2430
2472
  */
2431
2473
  interface aws_durable_execution_sdk_js extends Integration {}
2432
2474
 
2475
+ /** Configuration for AWS Lambda invocation instrumentation in Lambda runtimes. */
2476
+ interface aws_lambda extends Instrumentation {
2477
+ /** @default true @env DD_TRACE_AWS_SERVICE_REPRESENTATION_ENABLED */
2478
+ serviceRepresentationEnabled?: boolean;
2479
+ /** @default true @env DD_ENHANCED_METRICS */
2480
+ enhancedMetrics?: boolean;
2481
+ /** @default false @env DD_CAPTURE_LAMBDA_PAYLOAD */
2482
+ captureLambdaPayload?: boolean;
2483
+ /** @default 10 @env DD_CAPTURE_LAMBDA_PAYLOAD_MAX_DEPTH */
2484
+ captureLambdaPayloadMaxDepth?: number;
2485
+ /** @default true @env DD_TRACE_MANAGED_SERVICES */
2486
+ createInferredSpan?: boolean;
2487
+ /** @default false @env DD_MERGE_XRAY_TRACES */
2488
+ mergeXrayTraces?: boolean;
2489
+ /** @default true @env DD_ENCODE_AUTHORIZER_CONTEXT */
2490
+ encodeAuthorizerContext?: boolean;
2491
+ /** @default true @env DD_DECODE_AUTHORIZER_CONTEXT */
2492
+ decodeAuthorizerContext?: boolean;
2493
+ /** @default true @env DD_COLD_START_TRACING */
2494
+ coldStartTracing?: boolean;
2495
+ /** @default 3 @env DD_MIN_COLD_START_DURATION */
2496
+ minColdStartTraceDurationMs?: number;
2497
+ /** @default './opentracing/tracer' @env DD_COLD_START_TRACE_SKIP_LIB */
2498
+ coldStartTraceSkipLib?: string;
2499
+ /** @default false @env DD_FLUSH_TO_LOG */
2500
+ logForwarding?: boolean;
2501
+ /** Defaults to true in AWS GovCloud regions. @env DD_LAMBDA_FIPS_MODE */
2502
+ fipsMode?: boolean;
2503
+ /** @env DD_KMS_API_KEY */
2504
+ apiKeyKms?: string;
2505
+ /** @env DD_API_KEY_SECRET_ARN */
2506
+ apiKeySecretArn?: string;
2507
+ /** @default true @env DD_TRACE_AWS_ADD_SPAN_POINTERS */
2508
+ addSpanPointers?: boolean;
2509
+ /** @default false @env DD_DATA_STREAMS_ENABLED */
2510
+ dataStreamsEnabled?: boolean;
2511
+ /** Force a second wrapper even when the handler carries the shared wrapped marker. */
2512
+ forceWrap?: boolean;
2513
+ }
2514
+
2433
2515
  /**
2434
2516
  * This plugin automatically instruments the
2435
2517
  * [aws-sdk](https://github.com/aws/aws-sdk-js) module.
@@ -2625,6 +2707,12 @@ declare namespace tracer {
2625
2707
  net?: boolean;
2626
2708
  }
2627
2709
 
2710
+ /**
2711
+ * This plugin automatically instruments the
2712
+ * [@elevenlabs/elevenlabs-js](https://www.npmjs.com/package/@elevenlabs/elevenlabs-js) module.
2713
+ */
2714
+ interface elevenlabs extends Instrumentation, LLMObsIntegration {}
2715
+
2628
2716
  /**
2629
2717
  * This plugin automatically instruments the
2630
2718
  * [express](http://expressjs.com/) module.
@@ -3234,12 +3322,12 @@ declare namespace tracer {
3234
3322
  */
3235
3323
  interface prisma extends PrismaClient, PrismaEngine {
3236
3324
  /**
3237
- * Configuration for prisma client.
3325
+ * Configuration for prisma client. Set to `false` to skip `prisma.client` spans.
3238
3326
  */
3239
3327
  client?: PrismaClient | boolean,
3240
3328
 
3241
3329
  /**
3242
- * Configuration for Prisma engine.
3330
+ * Configuration for Prisma engine. Set to `false` to skip `prisma.engine` spans.
3243
3331
  */
3244
3332
  engine?: PrismaEngine | boolean
3245
3333
  }
@@ -3366,6 +3454,12 @@ declare namespace tracer {
3366
3454
  */
3367
3455
  interface tedious extends Instrumentation {}
3368
3456
 
3457
+ /**
3458
+ * Traces tRPC server queries and mutations. Express requests with one resolved procedure
3459
+ * use its route as the HTTP resource; batches retain the Express mount route.
3460
+ */
3461
+ interface trpc extends Instrumentation {}
3462
+
3369
3463
  /**
3370
3464
  * This plugin automatically instruments the
3371
3465
  * [@typesafe-ai/sdk](https://www.npmjs.com/package/@typesafe-ai/sdk) module.
@@ -4512,6 +4606,12 @@ declare namespace tracer {
4512
4606
  */
4513
4607
  output: { content: JSONType, role?: string }[]
4514
4608
 
4609
+ /**
4610
+ * The expected output associated with an experiment span.
4611
+ * Delete this property or set it to `undefined` to omit the expected output.
4612
+ */
4613
+ expectedOutput?: JSONType
4614
+
4515
4615
  /**
4516
4616
  * Get a tag from the span.
4517
4617
  * @param key The key of the tag to get.
package/initialize.mjs CHANGED
@@ -9,7 +9,9 @@
9
9
  * hook will always be active for ESM support.
10
10
  */
11
11
 
12
- /* eslint n/no-unsupported-features/node-builtins: ['error', { ignores: ['module.register'] }] */
12
+ /* eslint n/no-unsupported-features/node-builtins: [
13
+ 'error', { ignores: ['module.register', 'module.registerHooks'] }
14
+ ] */
13
15
 
14
16
  import { Buffer } from 'buffer'
15
17
  import * as Module from 'module'
@@ -100,7 +102,8 @@ if (isMainThread) {
100
102
  const initialized = require('./init.js')
101
103
  // Only register the loader hook when instrumentation initialized. On a bailout the
102
104
  // loader has nothing to instrument and can keep a short-lived process from exiting.
103
- if (Module.register && initialized) {
105
+ // `registerHooks` alone keeps the gate open once Node.js drops `register` (nodejs/node#67090).
106
+ if ((Module.registerHooks || Module.register) && initialized) {
104
107
  require('./register.js')
105
108
  }
106
109
  }
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "dd-trace",
3
- "version": "6.24.0",
3
+ "version": "6.26.0",
4
4
  "description": "Datadog APM tracing client for JavaScript",
5
5
  "main": "index.js",
6
6
  "typings": "index.d.ts",
7
7
  "scripts": {
8
8
  "env": "bash ./plugin-env",
9
- "prepare": "node scripts/patch-istanbul-lib-coverage.js && node scripts/patch-v8-to-istanbul.js && cd vendor && npm ci --include=dev",
9
+ "prepare": "node scripts/patch-istanbul-lib-coverage.js && node scripts/patch-v8-to-istanbul.js && npm exec --yes --package=bun -- bun install --cwd vendor --config=../bunfig.toml --silent --frozen-lockfile",
10
10
  "prepack": "node scripts/release/swap-v5-types.js",
11
11
  "bench": "node benchmark/index.js",
12
+ "bench:elevenlabs": "node benchmark/elevenlabs.js",
12
13
  "bench:e2e:test-optimization": "node benchmark/e2e-test-optimization/benchmark-run.js",
13
- "dependencies:dedupe": "yarn-deduplicate yarn.lock",
14
14
  "generate:config:types": "node scripts/generate-config-types.js",
15
15
  "generate:electron-package": "node scripts/generate-electron-package.js",
16
16
  "verify:config:types": "node scripts/generate-config-types.js --check",
@@ -18,12 +18,12 @@
18
18
  "generate:rewriter:targets": "node scripts/generate-rewriter-targets.js",
19
19
  "verify:rewriter:targets": "node scripts/generate-rewriter-targets.js --check",
20
20
  "generate:supported-integrations": "node scripts/generate-supported-integrations.js",
21
- "verify:supported-integrations": "node scripts/generate-supported-integrations.js --check",
22
21
  "type:check": "tsc --noEmit -p tsconfig.dev.json",
23
- "type:doc:build": "cd docs && yarn && yarn build",
24
- "type:doc:test": "cd docs && yarn && yarn test",
22
+ "type:check:ci": "node scripts/type-check.js tsconfig.type-checked.json",
23
+ "type:doc:build": "cd docs && bun install --frozen-lockfile && bun run build",
24
+ "type:doc:test": "cd docs && bun install --frozen-lockfile && bun run test",
25
25
  "lint": "bash ./scripts/lint.sh",
26
- "lint:fix": "node scripts/check_licenses.js && node scripts/check-agents-md-size.js && node scripts/check-no-coverage-artifacts.js && node scripts/check-no-mcr-images.js && node scripts/check-docker-image-shas.js && eslint . --concurrency=auto --max-warnings 0 --fix",
26
+ "lint:fix": "node scripts/check_licenses.js && node scripts/check-agents-md-size.js && node scripts/check-no-coverage-artifacts.js && node scripts/check-no-mcr-images.js && node scripts/check-docker-image-shas.js && node scripts/check-workflow-inline-js.js && eslint . --concurrency=auto --max-warnings 0 --fix",
27
27
  "verify:carrier-fields": "node scripts/verify-carrier-fields.mjs",
28
28
  "lint:inspect": "npx @eslint/config-inspector@latest",
29
29
  "lint:codeowners": "codeowners-audit",
@@ -37,7 +37,7 @@
37
37
  "test:appsec": "mocha --exclude \"packages/dd-trace/test/appsec/**/*.plugin.spec.js\" \"packages/dd-trace/test/appsec/**/*.spec.js\"",
38
38
  "test:appsec:ci": "node scripts/c8-ci.js test:appsec",
39
39
  "test:appsec:plugins": "mocha \"packages/dd-trace/test/appsec/**/*.@(${PLUGINS}).plugin.spec.js\"",
40
- "test:appsec:plugins:ci": "yarn services && node scripts/c8-ci.js test:appsec:plugins",
40
+ "test:appsec:plugins:ci": "npm run services && node scripts/c8-ci.js test:appsec:plugins",
41
41
  "test:debugger": "mocha \"packages/dd-trace/test/debugger/**/*.spec.js\"",
42
42
  "test:debugger:ci": "node scripts/c8-ci.js test:debugger",
43
43
  "test:eslint-rules": "node scripts/run-eslint-rule-tests.mjs eslint-rules/*.test.mjs",
@@ -49,10 +49,12 @@
49
49
  "test:esbuild:ci": "node scripts/c8-ci.js test:esbuild",
50
50
  "test:turbopack": "mocha \"packages/datadog-turbopack/test/**/*.spec.js\"",
51
51
  "test:turbopack:ci": "node scripts/c8-ci.js test:turbopack",
52
+ "test:vite": "mocha \"packages/datadog-vite/test/**/*.spec.js\"",
53
+ "test:vite:ci": "node scripts/c8-ci.js test:vite",
52
54
  "test:webpack": "mocha \"packages/datadog-webpack/test/**/*.spec.js\"",
53
55
  "test:webpack:ci": "node scripts/c8-ci.js test:webpack",
54
56
  "test:instrumentations": "mocha --fail-zero \"packages/datadog-instrumentations/test/@(${PLUGINS}).spec.js\"",
55
- "test:instrumentations:ci": "yarn services && node scripts/c8-ci.js test:instrumentations",
57
+ "test:instrumentations:ci": "npm run services && node scripts/c8-ci.js test:instrumentations",
56
58
  "test:instrumentations:misc": "mocha \"packages/datadog-instrumentations/test/*/**/*.spec.{js,mjs}\"",
57
59
  "test:instrumentations:misc:ci": "node scripts/c8-ci.js test:instrumentations:misc",
58
60
  "test:core": "node scripts/mocha-parallel-files.js --expose-gc --timeout 30000 -- \"packages/datadog-core/test/**/*.spec.js\"",
@@ -65,19 +67,19 @@
65
67
  "test:llmobs:sdk": "mocha --exclude \"packages/dd-trace/test/llmobs/plugins/**/*.spec.js\" \"packages/dd-trace/test/llmobs/**/*.spec.js\"",
66
68
  "test:llmobs:sdk:ci": "node scripts/c8-ci.js test:llmobs:sdk",
67
69
  "test:llmobs:plugins": "mocha \"packages/dd-trace/test/llmobs/plugins/@(${PLUGINS})/*.spec.js\"",
68
- "test:llmobs:plugins:ci": "yarn services && node scripts/c8-ci.js test:llmobs:plugins",
70
+ "test:llmobs:plugins:ci": "npm run services && node scripts/c8-ci.js test:llmobs:plugins",
69
71
  "test:openfeature": "mocha \"packages/dd-trace/test/evp_proxy/**/*.spec.js\" \"packages/dd-trace/test/openfeature/**/*.spec.js\"",
70
72
  "test:openfeature:ci": "node scripts/c8-ci.js test:openfeature",
71
73
  "test:plugins": "node --expose-gc ./node_modules/mocha/bin/mocha.js --fail-zero \"packages/datadog-plugin-@(${PLUGINS})/test/**/${SPEC:-*}*.spec.js\"",
72
- "test:plugins:ci": "yarn services && node scripts/c8-ci.js test:plugins",
73
- "test:plugins:ci:flaky": "yarn services && node scripts/c8-ci.js test:plugins --bail --retries 2",
74
+ "test:plugins:ci": "npm run services && node scripts/c8-ci.js test:plugins",
75
+ "test:plugins:ci:flaky": "npm run services && node scripts/c8-ci.js test:plugins --bail --retries 2",
74
76
  "test:plugins:upstream": "node ./packages/dd-trace/test/plugins/suite.js",
75
77
  "test:profiler": "node scripts/mocha-parallel-files.js --expose-gc --timeout 30000 -- \"packages/dd-trace/test/profiling/**/*.spec.js\"",
76
78
  "test:profiler:ci": "node scripts/c8-ci.js test:profiler",
77
79
  "test:otel-thread-ctx": "mocha --timeout 60000 packages/dd-trace/test/otel-thread-ctx.spec.js",
78
80
  "test:docker:otel-thread-ctx": "./scripts/docker/run-otel-thread-ctx-spec.sh",
79
- "test:integration": "mocha --timeout 60000 \"integration-tests/*.spec.js\"",
80
- "test:integration:coverage": "node ./integration-tests/coverage/run-suite.js --timeout 60000 \"integration-tests/*.spec.js\"",
81
+ "test:integration": "mocha --timeout 60000 \"integration-tests/*.spec.js\" \"integration-tests/helpers/*.spec.js\"",
82
+ "test:integration:coverage": "node ./integration-tests/coverage/run-suite.js --timeout 60000 \"integration-tests/*.spec.js\" \"integration-tests/helpers/*.spec.js\"",
81
83
  "test:integration:aiguard": "mocha --timeout 60000 \"integration-tests/aiguard/*.spec.js\"",
82
84
  "test:integration:aiguard:coverage": "node ./integration-tests/coverage/run-suite.js --timeout 60000 \"integration-tests/aiguard/*.spec.js\"",
83
85
  "test:integration:appsec": "mocha --timeout 60000 \"integration-tests/appsec/*.spec.js\"",
@@ -106,7 +108,7 @@
106
108
  "test:integration:playwright:coverage": "node ./integration-tests/coverage/run-suite.js --timeout 60000 \"integration-tests/playwright/${SPEC:-playwright-*}.spec.js\"",
107
109
  "test:integration:selenium": "mocha --timeout 60000 \"integration-tests/selenium/*.spec.js\"",
108
110
  "test:integration:selenium:coverage": "node ./integration-tests/coverage/run-suite.js --timeout 60000 \"integration-tests/selenium/*.spec.js\"",
109
- "test:integration:test-optimization:helpers": "mocha \"integration-tests/cypress/config-lifecycle*.spec.js\" \"integration-tests/cypress/*dependencies.spec.js\" \"integration-tests/jest/*dependencies.spec.js\" \"integration-tests/playwright/version*.spec.js\" \"integration-tests/mocha/version*.spec.js\"",
111
+ "test:integration:test-optimization:helpers": "mocha \"integration-tests/cypress/config-lifecycle*.spec.js\" \"integration-tests/cypress/checkout-context*.spec.js\" \"integration-tests/cypress/*dependencies.spec.js\" \"integration-tests/jest/*dependencies.spec.js\" \"integration-tests/playwright/version*.spec.js\" \"integration-tests/mocha/version*.spec.js\"",
110
112
  "test:integration:webdriverio": "mocha --timeout 60000 \"integration-tests/webdriverio/${SPEC:-*}.spec.js\"",
111
113
  "test:integration:webdriverio:coverage": "node ./integration-tests/coverage/run-suite.js --timeout 60000 \"integration-tests/webdriverio/${SPEC:-*}.spec.js\"",
112
114
  "test:integration:vitest": "mocha --timeout 60000 \"integration-tests/vitest/${SPEC:-vitest*}.spec.js\"",
@@ -115,14 +117,15 @@
115
117
  "test:integration:testopt:coverage": "node ./integration-tests/coverage/run-suite.js --timeout 120000 \"integration-tests/ci-visibility/${SPEC:-*}.spec.js\"",
116
118
  "test:integration:profiler": "mocha --timeout 180000 \"integration-tests/profiler/*.spec.js\"",
117
119
  "test:integration:profiler:coverage": "node ./integration-tests/coverage/run-suite.js --timeout 180000 \"integration-tests/profiler/*.spec.js\"",
118
- "test:integration:plugins": "yarn services && mocha \"packages/datadog-plugin-@(${PLUGINS})/test/integration-test/**/${SPEC:-*}*.spec.js\"",
119
- "test:integration:plugins:coverage": "yarn services && node ./integration-tests/coverage/run-suite.js \"packages/datadog-plugin-@(${PLUGINS})/test/integration-test/**/${SPEC:-*}*.spec.js\"",
120
+ "test:integration:plugins": "npm run services && mocha \"packages/datadog-plugin-@(${PLUGINS})/test/integration-test/**/${SPEC:-*}*.spec.js\"",
121
+ "test:integration:plugins:coverage": "npm run services && node ./integration-tests/coverage/run-suite.js \"packages/datadog-plugin-@(${PLUGINS})/test/integration-test/**/${SPEC:-*}*.spec.js\"",
120
122
  "test:unit:plugins": "mocha \"packages/datadog-instrumentations/test/@(${PLUGINS}).spec.js\" \"packages/datadog-plugin-@(${PLUGINS})/test/**/*.spec.js\" --exclude \"packages/datadog-plugin-@(${PLUGINS})/test/integration-test/**/*.spec.js\"",
121
123
  "test:release": "mocha \"scripts/release/**/*.spec.js\"",
122
- "test:scripts": "mocha \"benchmark/e2e-test-optimization/*.spec.js\" \"benchmark/sirun/*.spec.js\" \"scripts/helpers/**/*.spec.js\" \"scripts/*.spec.mjs\"",
124
+ "test:scripts": "mocha \"benchmark/e2e-test-optimization/*.spec.js\" \"benchmark/sirun/*.spec.js\" \"scripts/helpers/**/*.spec.js\" \"scripts/test/**/*.spec.js\" \"scripts/*.spec.mjs\"",
123
125
  "test:shimmer": "mocha \"packages/datadog-shimmer/test/**/*.spec.js\"",
124
126
  "test:shimmer:ci": "node scripts/c8-ci.js test:shimmer",
125
127
  "verify:workflow-job-names": "node scripts/verify-workflow-job-names.js",
128
+ "verify:dependency-updates": "node scripts/verify-dependency-updates.js",
126
129
  "verify-exercised-tests": "node scripts/verify-exercised-tests.js"
127
130
  },
128
131
  "repository": {
@@ -156,6 +159,8 @@
156
159
  "esbuild.js",
157
160
  "next.js",
158
161
  "next.d.ts",
162
+ "vite.js",
163
+ "vite.d.ts",
159
164
  "webpack.js",
160
165
  "ext/**/*",
161
166
  "index.d.ts",
@@ -195,19 +200,19 @@
195
200
  "optionalDependencies": {
196
201
  "@datadog/libdatadog": "^0.21.0",
197
202
  "@datadog/libdatadog-extras": "^0.21.0",
198
- "@datadog/native-appsec": "11.0.3",
203
+ "@datadog/native-appsec": "12.0.0",
199
204
  "@datadog/native-iast-taint-tracking": "4.2.1",
200
205
  "@datadog/native-metrics": "4.0.0",
201
- "@datadog/pprof": "5.20.0",
206
+ "@datadog/pprof": "5.20.1",
202
207
  "@datadog/wasm-js-rewriter": "5.0.4",
203
- "@opentelemetry/api": ">=1.4.1 <1.10.0",
208
+ "@opentelemetry/api": ">=1.4.1 <1.11.0",
204
209
  "@opentelemetry/api-logs": "<1.0.0",
205
210
  "oxc-parser": "^0.132.0"
206
211
  },
207
212
  "devDependencies": {
208
213
  "@actions/core": "^3.0.1",
209
214
  "@actions/github": "^9.1.1",
210
- "@babel/helpers": "^8.0.10",
215
+ "@babel/helpers": "^8.1.2",
211
216
  "@eslint/eslintrc": "^3.3.7",
212
217
  "@eslint/js": "^10.0.1",
213
218
  "@eslint/plugin-kit": "^0.7.3",
@@ -219,34 +224,32 @@
219
224
  "@types/mocha": "^10.0.10",
220
225
  "@types/node": "^18.19.106",
221
226
  "@types/sinon": "^22.0.2",
222
- "@vercel/nft": "^1.11.0",
223
- "@yarnpkg/lockfile": "^1.1.0",
227
+ "@vercel/nft": "^1.11.1",
224
228
  "benchmark": "^2.1.4",
225
229
  "body-parser": "^2.4.0",
226
230
  "bun": "1.4.4",
227
231
  "c8": "^12.0.0",
228
232
  "codeowners-audit": "^2.9.0",
229
- "eslint": "^10.13.0",
230
- "eslint-plugin-cypress": "^7.0.2",
231
- "eslint-plugin-import-x": "^4.16.2",
232
- "eslint-plugin-jsdoc": "^65.4.2",
233
+ "eslint": "^10.14.0",
234
+ "eslint-plugin-cypress": "^7.0.4",
235
+ "eslint-plugin-import-x": "^4.18.1",
236
+ "eslint-plugin-jsdoc": "^65.4.5",
233
237
  "eslint-plugin-mocha": "^12.0.2",
234
238
  "eslint-plugin-n": "^18.5.0",
235
239
  "eslint-plugin-promise": "^7.3.0",
236
- "eslint-plugin-regexp": "^3.3.2",
240
+ "eslint-plugin-regexp": "^3.3.3",
237
241
  "eslint-plugin-sonarjs": "^4.2.2",
238
242
  "eslint-plugin-unicorn": "^79.0.0",
239
243
  "express": "^5.3.0",
240
244
  "glob": "^10.4.5",
241
- "globals": "^17.13.0",
245
+ "globals": "^17.14.0",
242
246
  "graphql": "*",
243
- "husky": "^9.1.7",
244
247
  "istanbul-lib-coverage": "^3.2.2",
245
248
  "istanbul-lib-report": "^3.0.0",
246
249
  "istanbul-reports": "^3.0.2",
247
250
  "jsonc-parser": "^3.3.1",
248
251
  "jszip": "^3.10.2",
249
- "minimatch": "^11.0.3",
252
+ "minimatch": "^11.0.8",
250
253
  "mocha": "^11.8.0",
251
254
  "mocha-junit-reporter": "^2.2.1",
252
255
  "mocha-multi-reporters": "^1.5.2",
@@ -259,7 +262,7 @@
259
262
  "proxyquire": "^2.1.3",
260
263
  "retry": "^0.13.1",
261
264
  "semifies": "^1.0.0",
262
- "semver": "^7.8.5",
265
+ "semver": "^7.8.6",
263
266
  "sinon": "^22.1.0",
264
267
  "source-map-support": "^0.5.21",
265
268
  "test-exclude": "^8.0.0",
@@ -267,7 +270,9 @@
267
270
  "typescript": "^6.0.3",
268
271
  "v8-to-istanbul": "^9.0.0",
269
272
  "workerpool": "^10.0.3",
270
- "yaml": "^2.9.1",
271
- "yarn-deduplicate": "^6.0.2"
272
- }
273
+ "yaml": "^2.9.1"
274
+ },
275
+ "trustedDependencies": [
276
+ "bun"
277
+ ]
273
278
  }
@@ -1,19 +1,22 @@
1
1
  'use strict'
2
2
 
3
- const { execSync } = require('node:child_process')
4
3
  const fs = require('node:fs')
5
4
  const path = require('node:path')
6
- const { pathToFileURL, fileURLToPath } = require('node:url')
5
+ const { fileURLToPath } = require('node:url')
7
6
 
8
7
  const instrumentations = require('../datadog-instrumentations/src/helpers/instrumentations')
8
+ const {
9
+ createEsmResolver,
10
+ createEsmWrapper,
11
+ processModule,
12
+ } = require('../datadog-instrumentations/src/helpers/bundler-esm-exports')
13
+ const { getGitMetadataBanner, isESMFile } = require('../datadog-instrumentations/src/helpers/bundler-utils')
9
14
  const extractPackageAndModulePath = require('../datadog-instrumentations/src/helpers/extract-package-and-module-path')
10
15
  const hooks = require('../datadog-instrumentations/src/helpers/hooks')
11
16
  const { createBundlerRewriter } = require('../datadog-instrumentations/src/helpers/rewriter')
12
17
  const { getRewriteTarget, isRewriteTargetName } = require('../datadog-instrumentations/src/helpers/rewriter/targets')
13
18
  const { getValueFromEnvSources } = require('../dd-trace/src/config/helper')
14
19
  const log = require('./src/log')
15
- const { createEsmResolver } = require('./src/resolver')
16
- const { isESMFile, processModule } = require('./src/utils')
17
20
 
18
21
  const ESM_INTERCEPTED_SUFFIX = '._dd_esbuild_intercepted'
19
22
  const INTERNAL_ESM_INTERCEPTED_PREFIX = '/_dd_esm_internal_/'
@@ -82,40 +85,6 @@ function isESMBuild (build) {
82
85
  return format === 'esm' || outputFile?.endsWith('.mjs') || outExtension === '.mjs'
83
86
  }
84
87
 
85
- function getGitMetadata () {
86
- /**
87
- * @type {object}
88
- * @property {string | null} repositoryURL
89
- * @property {string | null} commitSHA
90
- */
91
- const gitMetadata = {
92
- repositoryURL: null,
93
- commitSHA: null,
94
- }
95
-
96
- try {
97
- gitMetadata.repositoryURL = execSync('git config --get remote.origin.url', {
98
- encoding: 'utf8',
99
- stdio: ['pipe', 'pipe', 'ignore'],
100
- cwd: process.cwd(),
101
- }).trim()
102
- } catch (e) {
103
- log.warn('failed to get git repository URL:', e.message)
104
- }
105
-
106
- try {
107
- gitMetadata.commitSHA = execSync('git rev-parse HEAD', {
108
- encoding: 'utf8',
109
- stdio: ['pipe', 'pipe', 'ignore'],
110
- cwd: process.cwd(),
111
- }).trim()
112
- } catch (e) {
113
- log.warn('failed to get git commit SHA:', e.message)
114
- }
115
-
116
- return gitMetadata
117
- }
118
-
119
88
  module.exports.setup = function (build) {
120
89
  if (build.initialOptions.minify && !build.initialOptions.keepNames) {
121
90
  throw new Error(
@@ -156,25 +125,10 @@ ${build.initialOptions.banner.js}`
156
125
 
157
126
  // Bake DD_GIT_* into the banner unless DD_BUNDLER_INJECT_GIT_METADATA=false (stable artifact hashes).
158
127
  if (DD_BUNDLER_INJECT_GIT_METADATA) {
159
- const gitMetadata = getGitMetadata()
160
- if (gitMetadata.repositoryURL || gitMetadata.commitSHA) {
128
+ const banner = getGitMetadataBanner(log)
129
+ if (banner) {
161
130
  build.initialOptions.banner ??= {}
162
- build.initialOptions.banner.js ??= ''
163
-
164
- build.initialOptions.banner.js = `if (typeof process === 'object' && process !== null &&
165
- process.env !== null && typeof process.env === 'object') {
166
- ${gitMetadata.repositoryURL ? `process.env.DD_GIT_REPOSITORY_URL = '${gitMetadata.repositoryURL}';` : ''}
167
- ${gitMetadata.commitSHA ? `process.env.DD_GIT_COMMIT_SHA = '${gitMetadata.commitSHA}';` : ''}
168
- }
169
- ${build.initialOptions.banner.js}`
170
-
171
- log.debug(
172
- 'Automatically injected git metadata (DD_GIT_REPOSITORY_URL: %s, DD_GIT_COMMIT_SHA: %s)',
173
- gitMetadata.repositoryURL || 'not available',
174
- gitMetadata.commitSHA || 'not available'
175
- )
176
- } else {
177
- log.warn('No git metadata available - skipping injection')
131
+ build.initialOptions.banner.js = `${banner}${build.initialOptions.banner.js ?? ''}`
178
132
  }
179
133
  } else {
180
134
  log.debug('Skipping git metadata injection (DD_BUNDLER_INJECT_GIT_METADATA=false)')
@@ -395,20 +349,12 @@ ${build.initialOptions.banner.js}`
395
349
  transform: build.esbuild.transformSync,
396
350
  })
397
351
 
398
- const iitmPath = require.resolve('import-in-the-middle/lib/register.js')
399
- const toRegister = data.internal ? args.path : pathToFileURL(args.path)
400
- // Mimic a Module object (https://tc39.es/ecma262/#sec-module-namespace-objects).
401
- contents = `
402
- import { register } from ${JSON.stringify(iitmPath)};
403
- import * as namespace from ${JSON.stringify(args.path)};
404
- const _ = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
405
- const set = {};
406
- const get = {};
407
-
408
- ${[...setters.values()].join(';\n')};
409
-
410
- register(${JSON.stringify(toRegister)}, _, set, get, ${JSON.stringify(data.raw)});
411
- `
352
+ contents = createEsmWrapper({
353
+ path: args.path,
354
+ internal: data.internal,
355
+ specifier: data.raw,
356
+ setters: setters.values(),
357
+ })
412
358
  } else {
413
359
  contents = fs.readFileSync(args.path, 'utf8')
414
360
  }
@@ -1,32 +1,5 @@
1
1
  'use strict'
2
2
 
3
- const { format } = require('util')
3
+ const createBundlerLog = require('../../datadog-instrumentations/src/helpers/bundler-log')
4
4
 
5
- // eslint-disable-next-line eslint-rules/eslint-process-env
6
- const DD_TRACE_DEBUG = (process.env.DD_TRACE_DEBUG || '').trim().toLowerCase()
7
- const DEBUG = DD_TRACE_DEBUG === 'true' || DD_TRACE_DEBUG === '1'
8
-
9
- const noop = () => {}
10
-
11
- const formatWithLogPrefix = (prefix, str, ...args) => {
12
- if (typeof str === 'string') {
13
- return format(`${prefix} ${str}`, ...args)
14
- }
15
- return format(prefix, str, ...args)
16
- }
17
-
18
- module.exports = DEBUG
19
- ? {
20
- debug (...args) {
21
- // eslint-disable-next-line no-console
22
- console.log(formatWithLogPrefix('[dd-trace/esbuild]', ...args))
23
- },
24
- warn (...args) {
25
- // eslint-disable-next-line no-console
26
- console.warn(formatWithLogPrefix('[dd-trace/esbuild] Warning:', ...args))
27
- },
28
- }
29
- : {
30
- debug: noop,
31
- warn: noop,
32
- }
5
+ module.exports = createBundlerLog('esbuild')
@@ -279,7 +279,12 @@ addHook({ name: 'ai', versions: ['>=7.0.0'] }, exports => {
279
279
  },
280
280
  })
281
281
 
282
- ctx.result.stream = ctx.result.stream.pipeThrough(transform)
282
+ // The telemetry result may be a copy, but its stream is shared with the SDK.
283
+ // Preserve that identity and attach the observer when the SDK pipes the stream.
284
+ shimmer.wrap(ctx.result.stream, 'pipeThrough', pipeThrough => function () {
285
+ const stream = pipeThrough.call(this, transform)
286
+ return pipeThrough.apply(stream, arguments)
287
+ })
283
288
  },
284
289
  })
285
290