dd-trace 5.132.0 → 5.134.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. package/ci/diagnose.js +9 -14
  2. package/ci/init.js +1 -2
  3. package/ci/test-optimization-validation/ci-discovery.js +9 -4
  4. package/ci/test-optimization-validation/executable.js +1 -5
  5. package/ci/test-optimization-validation/framework-adapters/cypress.js +1 -4
  6. package/ci/test-optimization-validation/framework-adapters/vitest.js +1 -1
  7. package/ci/test-optimization-validation/generated-files.js +6 -4
  8. package/ci/test-optimization-validation/generated-test-contract.js +7 -3
  9. package/ci/test-optimization-validation/manifest-scaffold.js +7 -2
  10. package/ci/test-optimization-validation/manifest-schema.js +6 -7
  11. package/ci/test-optimization-validation/report-writer.js +6 -2
  12. package/ci/test-optimization-validation/runner-command.js +2 -4
  13. package/ci/test-optimization-validation/runner-contract.js +1 -2
  14. package/ci/test-optimization-validation/scenarios/auto-test-retries.js +1 -15
  15. package/ci/vitest-no-worker-init-runner-setup.mjs +27 -0
  16. package/ci/vitest-no-worker-init-setup.mjs +10 -7
  17. package/index.d.ts +41 -19
  18. package/initialize.mjs +1 -3
  19. package/openfeature/rules-based.d.ts +11 -0
  20. package/openfeature/rules-based.js +7 -0
  21. package/package.json +25 -22
  22. package/packages/datadog-core/src/storage.js +16 -0
  23. package/packages/datadog-esbuild/index.js +18 -12
  24. package/packages/datadog-instrumentations/index.js +2 -1
  25. package/packages/datadog-instrumentations/src/aerospike.js +3 -3
  26. package/packages/datadog-instrumentations/src/ai.js +3 -3
  27. package/packages/datadog-instrumentations/src/aws-durable-execution-sdk-js.js +0 -6
  28. package/packages/datadog-instrumentations/src/aws-sdk.js +21 -13
  29. package/packages/datadog-instrumentations/src/cassandra-driver.js +25 -20
  30. package/packages/datadog-instrumentations/src/claude-agent-sdk.js +9 -23
  31. package/packages/datadog-instrumentations/src/cucumber.js +65 -41
  32. package/packages/datadog-instrumentations/src/elasticsearch.js +1 -5
  33. package/packages/datadog-instrumentations/src/electron.js +6 -6
  34. package/packages/datadog-instrumentations/src/fastify.js +13 -4
  35. package/packages/datadog-instrumentations/src/fs.js +2 -2
  36. package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +9 -5
  37. package/packages/datadog-instrumentations/src/grpc/client.js +2 -0
  38. package/packages/datadog-instrumentations/src/helpers/bundler-register.js +28 -9
  39. package/packages/datadog-instrumentations/src/helpers/check-require-cache.js +1 -2
  40. package/packages/datadog-instrumentations/src/helpers/hooks.js +1 -0
  41. package/packages/datadog-instrumentations/src/helpers/instrument.js +1 -1
  42. package/packages/datadog-instrumentations/src/helpers/register.js +45 -1
  43. package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +2 -0
  44. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +89 -6
  45. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql-jit.js +5 -6
  46. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/jest.js +12 -0
  47. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/postgres.js +48 -31
  48. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/vitest.js +8 -0
  49. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/webdriverio.js +7 -7
  50. package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +5 -0
  51. package/packages/datadog-instrumentations/src/helpers/rewriter/transforms/postgres.js +42 -4
  52. package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +7 -10
  53. package/packages/datadog-instrumentations/src/ioredis.js +7 -5
  54. package/packages/datadog-instrumentations/src/iovalkey.js +7 -5
  55. package/packages/datadog-instrumentations/src/jest.js +72 -67
  56. package/packages/datadog-instrumentations/src/knex.js +9 -5
  57. package/packages/datadog-instrumentations/src/mariadb-bundle.js +3 -3
  58. package/packages/datadog-instrumentations/src/mocha/common.js +20 -8
  59. package/packages/datadog-instrumentations/src/mocha/main.js +140 -43
  60. package/packages/datadog-instrumentations/src/mocha/utils.js +38 -4
  61. package/packages/datadog-instrumentations/src/mocha/worker.js +1 -2
  62. package/packages/datadog-instrumentations/src/mongodb-core.js +3 -3
  63. package/packages/datadog-instrumentations/src/mongoose.js +3 -3
  64. package/packages/datadog-instrumentations/src/nova-sonic/audio.js +173 -0
  65. package/packages/datadog-instrumentations/src/nova-sonic/index.js +209 -0
  66. package/packages/datadog-instrumentations/src/nova-sonic/session.js +492 -0
  67. package/packages/datadog-instrumentations/src/openai-realtime/index.js +18 -6
  68. package/packages/datadog-instrumentations/src/openai-realtime/session.js +1 -1
  69. package/packages/datadog-instrumentations/src/openai.js +7 -0
  70. package/packages/datadog-instrumentations/src/pino.js +5 -6
  71. package/packages/datadog-instrumentations/src/playwright.js +2 -0
  72. package/packages/datadog-instrumentations/src/redis.js +27 -13
  73. package/packages/datadog-instrumentations/src/router.js +30 -0
  74. package/packages/datadog-instrumentations/src/rum-browser-scripts.js +2 -6
  75. package/packages/datadog-instrumentations/src/stripe.js +23 -12
  76. package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +8 -5
  77. package/packages/datadog-instrumentations/src/vitest-main.js +16 -18
  78. package/packages/datadog-instrumentations/src/vitest-util.js +7 -4
  79. package/packages/datadog-instrumentations/src/vitest-worker.js +1 -2
  80. package/packages/datadog-instrumentations/src/vitest.js +9 -1
  81. package/packages/datadog-instrumentations/src/webdriverio.js +5 -8
  82. package/packages/datadog-instrumentations/src/ws.js +1 -4
  83. package/packages/datadog-plugin-amqplib/src/client.js +1 -2
  84. package/packages/datadog-plugin-avsc/src/schema_iterator.js +1 -5
  85. package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/handler.js +1 -2
  86. package/packages/datadog-plugin-aws-sdk/src/base.js +5 -8
  87. package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/index.js +18 -0
  88. package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/sonic.js +45 -0
  89. package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +9 -3
  90. package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +2 -5
  91. package/packages/datadog-plugin-azure-durable-functions/src/index.js +5 -4
  92. package/packages/datadog-plugin-azure-functions/src/index.js +5 -3
  93. package/packages/datadog-plugin-claude-agent-sdk/src/index.js +0 -2
  94. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +4 -5
  95. package/packages/datadog-plugin-cypress/src/index.js +6 -6
  96. package/packages/datadog-plugin-cypress/src/source-map-utils.js +1 -2
  97. package/packages/datadog-plugin-cypress/src/support.js +3 -4
  98. package/packages/datadog-plugin-express/src/code_origin.js +1 -2
  99. package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +2 -2
  100. package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +1 -2
  101. package/packages/datadog-plugin-graphql/src/execute.js +5 -5
  102. package/packages/datadog-plugin-grpc/src/util.js +1 -2
  103. package/packages/datadog-plugin-kafkajs/src/producer.js +1 -2
  104. package/packages/datadog-plugin-mocha/src/index.js +7 -10
  105. package/packages/datadog-plugin-mocha/src/webdriverio-video.js +8 -4
  106. package/packages/datadog-plugin-mongodb-core/src/query.js +8 -5
  107. package/packages/datadog-plugin-next/src/index.js +1 -2
  108. package/packages/datadog-plugin-openai/src/tracing.js +5 -2
  109. package/packages/datadog-plugin-openai-agents/src/integration.js +6 -2
  110. package/packages/datadog-plugin-openai-agents/src/processor.js +2 -4
  111. package/packages/datadog-plugin-postgres/src/index.js +24 -0
  112. package/packages/datadog-plugin-protobufjs/src/schema_iterator.js +1 -5
  113. package/packages/datadog-plugin-rhea/src/consumer.js +1 -4
  114. package/packages/datadog-plugin-vitest/src/index.js +5 -2
  115. package/packages/datadog-shimmer/src/shimmer.js +5 -4
  116. package/packages/datadog-webpack/index.js +55 -43
  117. package/packages/datadog-webpack/src/loader.js +56 -8
  118. package/packages/dd-trace/src/aiguard/evaluation.js +143 -1
  119. package/packages/dd-trace/src/aiguard/integrations/vercel-ai.js +2 -4
  120. package/packages/dd-trace/src/aiguard/messages/utils.js +1 -2
  121. package/packages/dd-trace/src/aiguard/redaction.js +8 -2
  122. package/packages/dd-trace/src/appsec/api_security/normalized-route.js +3 -2
  123. package/packages/dd-trace/src/appsec/api_security/sampler.js +2 -6
  124. package/packages/dd-trace/src/appsec/downstream_requests.js +1 -9
  125. package/packages/dd-trace/src/appsec/handlers/http-request.js +3 -9
  126. package/packages/dd-trace/src/appsec/handlers/http-response.js +7 -2
  127. package/packages/dd-trace/src/appsec/iast/analyzers/path-traversal-analyzer.js +4 -3
  128. package/packages/dd-trace/src/appsec/iast/analyzers/set-cookies-header-interceptor.js +1 -4
  129. package/packages/dd-trace/src/appsec/iast/path-line.js +2 -1
  130. package/packages/dd-trace/src/appsec/iast/taint-tracking/operations-taint-object.js +7 -1
  131. package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +1 -3
  132. package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter-esm.mjs +1 -3
  133. package/packages/dd-trace/src/appsec/iast/telemetry/iast-metric.js +1 -6
  134. package/packages/dd-trace/src/appsec/lambda.js +1 -3
  135. package/packages/dd-trace/src/appsec/rasp/fs-plugin.js +37 -27
  136. package/packages/dd-trace/src/appsec/rasp/lfi.js +9 -5
  137. package/packages/dd-trace/src/appsec/reporter.js +21 -1
  138. package/packages/dd-trace/src/appsec/stack_trace.js +4 -4
  139. package/packages/dd-trace/src/ci-visibility/dynamic-atr-retries.js +3 -6
  140. package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +3 -2
  141. package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/msgpack-to-json.js +1 -1
  142. package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +13 -7
  143. package/packages/dd-trace/src/ci-visibility/exporters/settings-cache-key.js +1 -2
  144. package/packages/dd-trace/src/ci-visibility/exporters/test-worker/index.js +2 -8
  145. package/packages/dd-trace/src/ci-visibility/resolve-runfile-path.js +54 -0
  146. package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache-schema.js +5 -8
  147. package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache.js +2 -53
  148. package/packages/dd-trace/src/config/config-types.d.ts +2 -2
  149. package/packages/dd-trace/src/config/defaults.js +5 -5
  150. package/packages/dd-trace/src/config/generated-config-types.d.ts +10 -0
  151. package/packages/dd-trace/src/config/helper.js +34 -3
  152. package/packages/dd-trace/src/config/index.js +55 -9
  153. package/packages/dd-trace/src/config/normalize-service.js +1 -1
  154. package/packages/dd-trace/src/config/parsers.js +2 -2
  155. package/packages/dd-trace/src/config/supported-configurations.json +44 -0
  156. package/packages/dd-trace/src/datastreams/processor.js +3 -2
  157. package/packages/dd-trace/src/datastreams/schemas/schema_builder.js +1 -4
  158. package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +6 -5
  159. package/packages/dd-trace/src/debugger/devtools_client/condition.js +5 -5
  160. package/packages/dd-trace/src/debugger/devtools_client/send.js +1 -0
  161. package/packages/dd-trace/src/debugger/devtools_client/snapshot/collector.js +4 -6
  162. package/packages/dd-trace/src/debugger/devtools_client/status.js +1 -0
  163. package/packages/dd-trace/src/debugger/guardrail-metrics.js +2 -2
  164. package/packages/dd-trace/src/debugger/unsupported-runtime.js +16 -0
  165. package/packages/dd-trace/src/dogstatsd.js +1 -1
  166. package/packages/dd-trace/src/encode/tags-processors.js +2 -2
  167. package/packages/dd-trace/src/exporters/common/request.js +1 -5
  168. package/packages/dd-trace/src/id.js +14 -1
  169. package/packages/dd-trace/src/lambda/handler.js +179 -19
  170. package/packages/dd-trace/src/lambda/index.js +15 -1
  171. package/packages/dd-trace/src/lambda/runtime/patch.js +34 -7
  172. package/packages/dd-trace/src/llmobs/agent-manifest.js +19 -2
  173. package/packages/dd-trace/src/llmobs/audio-utils.js +3 -2
  174. package/packages/dd-trace/src/llmobs/constants/tags.js +15 -0
  175. package/packages/dd-trace/src/llmobs/experiments/experiment.js +1 -1
  176. package/packages/dd-trace/src/llmobs/plugins/anthropic/index.js +15 -0
  177. package/packages/dd-trace/src/llmobs/plugins/genai/util.js +1 -2
  178. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chat_model.js +1 -3
  179. package/packages/dd-trace/src/llmobs/plugins/langgraph/index.js +1 -1
  180. package/packages/dd-trace/src/llmobs/plugins/nova-sonic.js +92 -0
  181. package/packages/dd-trace/src/llmobs/plugins/openai/constants.js +5 -0
  182. package/packages/dd-trace/src/llmobs/plugins/openai/index.js +64 -2
  183. package/packages/dd-trace/src/llmobs/plugins/openai/utils.js +38 -0
  184. package/packages/dd-trace/src/llmobs/prompts/manager.js +5 -7
  185. package/packages/dd-trace/src/llmobs/prompts/prompt.js +1 -1
  186. package/packages/dd-trace/src/llmobs/sdk.js +15 -4
  187. package/packages/dd-trace/src/llmobs/span_processor.js +13 -2
  188. package/packages/dd-trace/src/llmobs/tagger.js +20 -10
  189. package/packages/dd-trace/src/llmobs/util.js +11 -6
  190. package/packages/dd-trace/src/llmobs/writers/base.js +4 -5
  191. package/packages/dd-trace/src/log/log.js +1 -5
  192. package/packages/dd-trace/src/openfeature/evaluation-telemetry-opt-out-hook.js +51 -0
  193. package/packages/dd-trace/src/openfeature/flagging_provider.js +48 -21
  194. package/packages/dd-trace/src/openfeature/index.js +6 -0
  195. package/packages/dd-trace/src/openfeature/writers/util.js +4 -4
  196. package/packages/dd-trace/src/opentelemetry/logs/otlp_transformer.js +1 -1
  197. package/packages/dd-trace/src/opentelemetry/metrics/otlp_transformer.js +1 -1
  198. package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +1 -2
  199. package/packages/dd-trace/src/opentelemetry/otlp/common.proto +1 -1
  200. package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +24 -24
  201. package/packages/dd-trace/src/opentracing/propagation/text_map.js +53 -13
  202. package/packages/dd-trace/src/otel-sampling.js +4 -5
  203. package/packages/dd-trace/src/otel-thread-ctx.js +79 -13
  204. package/packages/dd-trace/src/plugin_manager.js +1 -2
  205. package/packages/dd-trace/src/plugins/database.js +7 -16
  206. package/packages/dd-trace/src/plugins/tracing.js +0 -1
  207. package/packages/dd-trace/src/plugins/util/git.js +99 -59
  208. package/packages/dd-trace/src/plugins/util/inferred_proxy.js +1 -5
  209. package/packages/dd-trace/src/plugins/util/stacktrace.js +2 -1
  210. package/packages/dd-trace/src/plugins/util/test.js +50 -4
  211. package/packages/dd-trace/src/plugins/util/web.js +90 -20
  212. package/packages/dd-trace/src/priority_sampler.js +1 -2
  213. package/packages/dd-trace/src/profiling/profiler.js +4 -6
  214. package/packages/dd-trace/src/proxy.js +1 -2
  215. package/packages/dd-trace/src/ritm.js +4 -2
  216. package/packages/dd-trace/src/serverless.js +5 -0
  217. package/packages/dd-trace/src/span_processor.js +13 -17
  218. package/packages/dd-trace/src/span_stats.js +4 -1
  219. package/packages/dd-trace/src/telemetry/endpoints.js +1 -3
  220. package/packages/dd-trace/src/telemetry/logs/log-collector.js +1 -1
  221. package/packages/dd-trace/src/util.js +37 -4
  222. package/packages/dd-trace/src/web-tags-cache.js +6 -2
  223. package/vendor/dist/@apm-js-collab/code-transformer/index.js +8 -8
  224. package/vendor/dist/@datadog/openfeature-node-server/index.js +1 -1
  225. package/vendor/dist/@datadog/openfeature-node-server/rules-based/LICENSE +201 -0
  226. package/vendor/dist/@datadog/openfeature-node-server/rules-based/index.d.ts +925 -0
  227. package/vendor/dist/@datadog/openfeature-node-server/rules-based/index.js +1 -0
  228. package/vendor/dist/@datadog/sketches-js/index.js +1 -1
  229. package/vendor/dist/protobufjs/index.js +1 -1
  230. package/vendor/dist/protobufjs/minimal/index.js +1 -1
  231. package/vendor/dist/shell-quote/index.js +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dd-trace",
3
- "version": "5.132.0",
3
+ "version": "5.134.0",
4
4
  "description": "Datadog APM tracing client for JavaScript",
5
5
  "main": "index.js",
6
6
  "typings": "index.d.ts",
@@ -84,8 +84,8 @@
84
84
  "test:integration:appsec:coverage": "node ./integration-tests/coverage/run-suite.js --timeout 60000 \"integration-tests/appsec/*.spec.js\"",
85
85
  "test:integration:crashtracking": "mocha --timeout 60000 \"integration-tests/crashtracking/*.spec.js\"",
86
86
  "test:integration:bun": "mocha --timeout 60000 \"integration-tests/bun/*.spec.js\"",
87
- "test:integration:cucumber": "mocha --timeout 60000 \"integration-tests/cucumber/*.spec.js\"",
88
- "test:integration:cucumber:coverage": "node ./integration-tests/coverage/run-suite.js --timeout 60000 \"integration-tests/cucumber/*.spec.js\"",
87
+ "test:integration:cucumber": "mocha --timeout 60000 \"integration-tests/cucumber/${SPEC:-cucumber*}.spec.js\"",
88
+ "test:integration:cucumber:coverage": "node ./integration-tests/coverage/run-suite.js --timeout 60000 \"integration-tests/cucumber/${SPEC:-cucumber*}.spec.js\"",
89
89
  "test:integration:cypress": "mocha --timeout 60000 \"integration-tests/cypress/${SPEC:-cypress-*}.spec.js\"",
90
90
  "test:integration:cypress:coverage": "node ./integration-tests/coverage/run-suite.js --timeout 60000 \"integration-tests/cypress/${SPEC:-cypress-*}.spec.js\"",
91
91
  "test:integration:debugger": "mocha --timeout 60000 \"integration-tests/debugger/*.spec.js\"",
@@ -94,24 +94,25 @@
94
94
  "test:integration:esbuild": "mocha --timeout 60000 \"integration-tests/esbuild/*.spec.js\"",
95
95
  "test:integration:esbuild:coverage": "node ./integration-tests/coverage/run-suite.js --timeout 60000 \"integration-tests/esbuild/*.spec.js\"",
96
96
  "test:integration:turbopack": "mocha --timeout 60000 \"integration-tests/turbopack/*.spec.js\"",
97
+ "test:integration:vite": "mocha --timeout 60000 \"integration-tests/vite/*.spec.js\"",
97
98
  "test:integration:webpack": "mocha --timeout 60000 \"integration-tests/webpack/*.spec.js\"",
98
99
  "test:integration:openfeature": "mocha --timeout 60000 \"integration-tests/openfeature/*.spec.js\"",
99
100
  "test:integration:openfeature:coverage": "node ./integration-tests/coverage/run-suite.js --timeout 60000 \"integration-tests/openfeature/*.spec.js\"",
100
101
  "test:integration:jest": "mocha --timeout 60000 \"integration-tests/jest/${SPEC:-jest*}.spec.js\"",
101
102
  "test:integration:jest:coverage": "node ./integration-tests/coverage/run-suite.js --timeout 60000 \"integration-tests/jest/${SPEC:-jest*}.spec.js\"",
102
- "test:integration:mocha": "mocha --timeout 60000 \"integration-tests/mocha/*.spec.js\"",
103
- "test:integration:mocha:coverage": "node ./integration-tests/coverage/run-suite.js --timeout 60000 \"integration-tests/mocha/*.spec.js\"",
103
+ "test:integration:mocha": "mocha --timeout 60000 \"integration-tests/mocha/${SPEC:-mocha*}.spec.js\"",
104
+ "test:integration:mocha:coverage": "node ./integration-tests/coverage/run-suite.js --timeout 60000 \"integration-tests/mocha/${SPEC:-mocha*}.spec.js\"",
104
105
  "test:integration:playwright": "mocha --timeout 60000 \"integration-tests/playwright/${SPEC:-playwright-*}.spec.js\"",
105
106
  "test:integration:playwright:coverage": "node ./integration-tests/coverage/run-suite.js --timeout 60000 \"integration-tests/playwright/${SPEC:-playwright-*}.spec.js\"",
106
107
  "test:integration:selenium": "mocha --timeout 60000 \"integration-tests/selenium/*.spec.js\"",
107
108
  "test:integration:selenium:coverage": "node ./integration-tests/coverage/run-suite.js --timeout 60000 \"integration-tests/selenium/*.spec.js\"",
108
- "test:integration:test-optimization:helpers": "mocha \"integration-tests/cypress/*dependencies.spec.js\" \"integration-tests/jest/*dependencies.spec.js\" \"integration-tests/playwright/version*.spec.js\"",
109
+ "test:integration:test-optimization:helpers": "mocha \"integration-tests/cypress/*dependencies.spec.js\" \"integration-tests/jest/*dependencies.spec.js\" \"integration-tests/playwright/version*.spec.js\" \"integration-tests/mocha/version*.spec.js\"",
109
110
  "test:integration:webdriverio": "mocha --timeout 60000 \"integration-tests/webdriverio/${SPEC:-*}.spec.js\"",
110
111
  "test:integration:webdriverio:coverage": "node ./integration-tests/coverage/run-suite.js --timeout 60000 \"integration-tests/webdriverio/${SPEC:-*}.spec.js\"",
111
112
  "test:integration:vitest": "mocha --timeout 60000 \"integration-tests/vitest/${SPEC:-vitest*}.spec.js\"",
112
- "test:integration:vitest:coverage": "node ./integration-tests/coverage/run-suite.js --timeout 60000 \"integration-tests/vitest/${SPEC:-vitest*}.spec.js\"",
113
- "test:integration:testopt": "mocha --timeout 120000 \"integration-tests/ci-visibility/*.spec.js\"",
114
- "test:integration:testopt:coverage": "node ./integration-tests/coverage/run-suite.js --timeout 120000 \"integration-tests/ci-visibility/*.spec.js\"",
113
+ "test:integration:vitest:coverage": "node ./integration-tests/vitest/run-with-coverage.js --timeout 60000 \"integration-tests/vitest/${SPEC:-vitest*}.spec.js\"",
114
+ "test:integration:testopt": "mocha --timeout 120000 \"integration-tests/ci-visibility/${SPEC:-*}.spec.js\"",
115
+ "test:integration:testopt:coverage": "node ./integration-tests/coverage/run-suite.js --timeout 120000 \"integration-tests/ci-visibility/${SPEC:-*}.spec.js\"",
115
116
  "test:integration:profiler": "mocha --timeout 180000 \"integration-tests/profiler/*.spec.js\"",
116
117
  "test:integration:profiler:coverage": "node ./integration-tests/coverage/run-suite.js --timeout 180000 \"integration-tests/profiler/*.spec.js\"",
117
118
  "test:integration:plugins": "yarn services && mocha \"packages/datadog-plugin-@(${PLUGINS})/test/integration-test/**/${SPEC:-*}*.spec.js\"",
@@ -143,7 +144,7 @@
143
144
  "bugs": {
144
145
  "url": "https://github.com/DataDog/dd-trace-js/issues"
145
146
  },
146
- "homepage": "https://github.com/DataDog/dd-trace-js#readme",
147
+ "homepage": "https://github.com/DataDog/dd-trace-js",
147
148
  "engines": {
148
149
  "node": ">=18"
149
150
  },
@@ -169,6 +170,8 @@
169
170
  "loader-hook.mjs",
170
171
  "openfeature.d.ts",
171
172
  "openfeature.js",
173
+ "openfeature/rules-based.js",
174
+ "openfeature/rules-based.d.ts",
172
175
  "packages/*/index.js",
173
176
  "packages/*/index.electron.js",
174
177
  "packages/*/lib/**/*",
@@ -184,7 +187,7 @@
184
187
  ],
185
188
  "dependencies": {
186
189
  "dc-polyfill": "^0.1.11",
187
- "import-in-the-middle": "3.5.1",
190
+ "import-in-the-middle": "3.5.3",
188
191
  "opentracing": ">=0.14.7"
189
192
  },
190
193
  "optionalDependencies": {
@@ -202,36 +205,36 @@
202
205
  "devDependencies": {
203
206
  "@actions/core": "^3.0.1",
204
207
  "@actions/github": "^9.1.1",
205
- "@babel/helpers": "^8.0.5",
208
+ "@babel/helpers": "^8.0.8",
206
209
  "@eslint/eslintrc": "^3.3.7",
207
210
  "@eslint/js": "^10.0.1",
208
211
  "@eslint/plugin-kit": "^0.7.3",
209
- "@datadog/openfeature-node-server": "2.4.0",
212
+ "@datadog/openfeature-node-server": "2.5.0",
210
213
  "@msgpack/msgpack": "^3.1.3",
211
214
  "@openfeature/core": "^1.12.0",
212
215
  "@openfeature/server-sdk": "~1.23.0",
213
216
  "@stylistic/eslint-plugin": "^5.10.0",
214
217
  "@types/mocha": "^10.0.10",
215
218
  "@types/node": "^18.19.106",
216
- "@types/sinon": "^22.0.0",
219
+ "@types/sinon": "^22.0.1",
217
220
  "@vercel/nft": "^1.11.0",
218
221
  "@yarnpkg/lockfile": "^1.1.0",
219
222
  "benchmark": "^2.1.4",
220
- "body-parser": "^2.3.0",
221
- "bun": "1.4.2",
223
+ "body-parser": "^2.4.0",
224
+ "bun": "1.4.4",
222
225
  "c8": "^12.0.0",
223
226
  "codeowners-audit": "^2.9.0",
224
- "eslint": "^10.11.0",
227
+ "eslint": "^10.13.0",
225
228
  "eslint-plugin-cypress": "^7.0.2",
226
229
  "eslint-plugin-import-x": "^4.16.2",
227
- "eslint-plugin-jsdoc": "^64.5.4",
230
+ "eslint-plugin-jsdoc": "^65.4.2",
228
231
  "eslint-plugin-mocha": "^12.0.2",
229
- "eslint-plugin-n": "^18.4.0",
232
+ "eslint-plugin-n": "^18.5.0",
230
233
  "eslint-plugin-promise": "^7.3.0",
231
234
  "eslint-plugin-regexp": "^3.3.1",
232
235
  "eslint-plugin-sonarjs": "^4.2.2",
233
- "eslint-plugin-unicorn": "^74.0.0",
234
- "express": "^5.1.0",
236
+ "eslint-plugin-unicorn": "^78.0.0",
237
+ "express": "^5.3.0",
235
238
  "glob": "^10.4.5",
236
239
  "globals": "^17.13.0",
237
240
  "graphql": "*",
@@ -245,7 +248,7 @@
245
248
  "mocha": "^11.8.0",
246
249
  "mocha-junit-reporter": "^2.2.1",
247
250
  "mocha-multi-reporters": "^1.5.2",
248
- "multer": "^2.4.0",
251
+ "multer": "^2.5.0",
249
252
  "nock": "^14.0.17",
250
253
  "node-preload": "^0.2.1",
251
254
  "nyc": "^18.0.0",
@@ -56,12 +56,28 @@ const isACFActive = (() => {
56
56
  if (!isACFActive) {
57
57
  const superGetStore = AsyncLocalStorage.prototype.getStore
58
58
  const superEnterWith = AsyncLocalStorage.prototype.enterWith
59
+ // @ts-expect-error Node calls this undocumented AsyncLocalStorage hook.
60
+ const superPropagate = AsyncLocalStorage.prototype._propagate
59
61
 
60
62
  // Without ACF, ALS writes the entered value onto the async resource. Keep the
61
63
  // real store off the resource by entering a small handle and mapping it to
62
64
  // the store through a WeakMap, then reversing the lookup on read.
63
65
  const stores = new WeakMap()
64
66
 
67
+ /**
68
+ * Node can omit the trigger resource while the inspector is paused. Guard
69
+ * the shared hook because every enabled AsyncLocalStorage receives the call.
70
+ *
71
+ * @param {object} resource
72
+ * @param {object | undefined} triggerResource
73
+ * @param {string} type
74
+ */
75
+ AsyncLocalStorage.prototype._propagate = function _propagate (resource, triggerResource, type) {
76
+ if (triggerResource) {
77
+ superPropagate.call(this, resource, triggerResource, type)
78
+ }
79
+ }
80
+
65
81
  /**
66
82
  * @param {Store<unknown>} [store]
67
83
  */
@@ -8,6 +8,7 @@ const { pathToFileURL, fileURLToPath } = require('node:url')
8
8
  const instrumentations = require('../datadog-instrumentations/src/helpers/instrumentations')
9
9
  const extractPackageAndModulePath = require('../datadog-instrumentations/src/helpers/extract-package-and-module-path')
10
10
  const hooks = require('../datadog-instrumentations/src/helpers/hooks')
11
+ const { getValueFromEnvSources } = require('../dd-trace/src/config/helper')
11
12
  const log = require('./src/log')
12
13
  const { createEsmResolver } = require('./src/resolver')
13
14
  const { isESMFile, processModule } = require('./src/utils')
@@ -60,6 +61,7 @@ for (const builtin of builtinModules) {
60
61
 
61
62
  // eslint-disable-next-line eslint-rules/eslint-process-env
62
63
  const DD_IAST_ENABLED = process.env.DD_IAST_ENABLED?.toLowerCase() === 'true' || process.env.DD_IAST_ENABLED === '1'
64
+ const DD_BUNDLER_INJECT_GIT_METADATA = getValueFromEnvSources('DD_BUNDLER_INJECT_GIT_METADATA') !== false
63
65
 
64
66
  module.exports.name = 'datadog-esbuild'
65
67
 
@@ -143,26 +145,30 @@ globalThis.__dirname ??= $dd_dirname(globalThis.__filename);
143
145
  ${build.initialOptions.banner.js}`
144
146
  }
145
147
 
146
- // Get git metadata at build time and add it to the banner for both ESM and CommonJS builds
147
- const gitMetadata = getGitMetadata()
148
- if (gitMetadata.repositoryURL || gitMetadata.commitSHA) {
149
- build.initialOptions.banner ??= {}
150
- build.initialOptions.banner.js ??= ''
148
+ // Bake DD_GIT_* into the banner unless DD_BUNDLER_INJECT_GIT_METADATA=false (stable artifact hashes).
149
+ if (DD_BUNDLER_INJECT_GIT_METADATA) {
150
+ const gitMetadata = getGitMetadata()
151
+ if (gitMetadata.repositoryURL || gitMetadata.commitSHA) {
152
+ build.initialOptions.banner ??= {}
153
+ build.initialOptions.banner.js ??= ''
151
154
 
152
- build.initialOptions.banner.js = `if (typeof process === 'object' && process !== null &&
155
+ build.initialOptions.banner.js = `if (typeof process === 'object' && process !== null &&
153
156
  process.env !== null && typeof process.env === 'object') {
154
157
  ${gitMetadata.repositoryURL ? `process.env.DD_GIT_REPOSITORY_URL = '${gitMetadata.repositoryURL}';` : ''}
155
158
  ${gitMetadata.commitSHA ? `process.env.DD_GIT_COMMIT_SHA = '${gitMetadata.commitSHA}';` : ''}
156
159
  }
157
160
  ${build.initialOptions.banner.js}`
158
161
 
159
- log.debug(
160
- 'Automatically injected git metadata (DD_GIT_REPOSITORY_URL: %s, DD_GIT_COMMIT_SHA: %s)',
161
- gitMetadata.repositoryURL || 'not available',
162
- gitMetadata.commitSHA || 'not available'
163
- )
162
+ log.debug(
163
+ 'Automatically injected git metadata (DD_GIT_REPOSITORY_URL: %s, DD_GIT_COMMIT_SHA: %s)',
164
+ gitMetadata.repositoryURL || 'not available',
165
+ gitMetadata.commitSHA || 'not available'
166
+ )
167
+ } else {
168
+ log.warn('No git metadata available - skipping injection')
169
+ }
164
170
  } else {
165
- log.warn('No git metadata available - skipping injection')
171
+ log.debug('Skipping git metadata injection (DD_BUNDLER_INJECT_GIT_METADATA=false)')
166
172
  }
167
173
 
168
174
  let resolver
@@ -2,4 +2,5 @@
2
2
 
3
3
  require('./src/helpers/bundler-register')
4
4
  require('./src/helpers/register')
5
- require('./src/helpers/rewriter/loader')
5
+ // The extension is required: bundlers that prefer `.mjs` (e.g. Vite) would otherwise pick the ESM loader hook.
6
+ require('./src/helpers/rewriter/loader.js')
@@ -42,9 +42,9 @@ function wrapExecuteWithCallback (executeWithCallback) {
42
42
  function wrapProcess (process) {
43
43
  return function (...args) {
44
44
  const cb = args[0]
45
- if (!ch.start.hasSubscribers || typeof cb !== 'function') return process.apply(this, args)
46
-
47
- if (this[kTracingCallbackCommand]) return process.apply(this, args)
45
+ if (!ch.start.hasSubscribers || typeof cb !== 'function' || this[kTracingCallbackCommand]) {
46
+ return process.apply(this, args)
47
+ }
48
48
 
49
49
  const ctx = getContext(this)
50
50
 
@@ -228,11 +228,11 @@ for (const hook of getHooks('ai').values()) {
228
228
 
229
229
  // The SDK builds a model from a string id, in which case only the resolved instance is
230
230
  // worth wrapping; when the caller passed an instance, that is the one the SDK calls.
231
- if (typeof model !== 'string' && model !== ctx.result) {
231
+ if (typeof model === 'string' || model === ctx.result) {
232
+ wrapModel(ctx.result)
233
+ } else {
232
234
  wrapModel(model)
233
235
  wrappedModels.add(ctx.result)
234
- } else {
235
- wrapModel(ctx.result)
236
236
  }
237
237
  },
238
238
  })
@@ -2,7 +2,6 @@
2
2
 
3
3
  const { channel, tracingChannel } = require('dc-polyfill')
4
4
  const shimmer = require('../../datadog-shimmer')
5
- const { addHook, getHooks } = require('./helpers/instrument')
6
5
  const LAZY_DURABLE_PROMISE_METHODS = require('./aws-durable-execution-sdk-js-context-methods')
7
6
 
8
7
  for (const method of LAZY_DURABLE_PROMISE_METHODS) {
@@ -102,8 +101,3 @@ function observeDurablePromise (dp, onSettle) {
102
101
  instrumentDurablePromiseProto(Object.getPrototypeOf(dp))
103
102
  dp[ON_SETTLE] = onSettle
104
103
  }
105
-
106
- for (const hook of getHooks('@aws/durable-execution-sdk-js').values()) {
107
- hook.file = null
108
- addHook(hook, exports => exports)
109
- }
@@ -2,12 +2,14 @@
2
2
 
3
3
  const shimmer = require('../../datadog-shimmer')
4
4
  const { channel, addHook } = require('./helpers/instrument')
5
+ const sendSonic = require('./nova-sonic')
5
6
 
6
7
  const patchedClientConfigProtocols = new WeakSet()
7
8
  const patchedCommandPrototypes = new WeakSet()
9
+ const patchedSmithyClients = new WeakSet()
8
10
 
9
11
  // Resource identifiers that already match the channel-suffix slug. Anything
10
- // else falls back to `'default'`. Hoisted out of the per-call hot path so we
12
+ // else falls back to `'aws'`. Hoisted out of the per-call hot path so we
11
13
  // don't allocate a fresh Array literal + run `.includes` on every AWS send.
12
14
  const KNOWN_CHANNEL_SUFFIXES = new Set([
13
15
  'cloudwatchlogs',
@@ -161,6 +163,9 @@ function wrapSmithySend (send) {
161
163
  const channels = getChannelBag(channelSuffix)
162
164
  const clientName = getClientName(this.constructor)
163
165
  const operation = getOperationName(command.constructor)
166
+ if (channelSuffix === 'bedrockruntime' && operation === 'invokeModelWithBidirectionalStream') {
167
+ return sendSonic(send, this, command, args)
168
+ }
164
169
  const request = {
165
170
  operation,
166
171
  params: command.input,
@@ -320,18 +325,24 @@ function getChannelSuffix (name) {
320
325
  // some resource identifiers have spaces between ex: bedrock runtime
321
326
  name = String(name).replaceAll(' ', '')
322
327
  if (KNOWN_CHANNEL_SUFFIXES.has(name)) return name
323
- return CHANNEL_SUFFIX_ALIASES.get(name) ?? 'default'
328
+ return CHANNEL_SUFFIX_ALIASES.get(name) ?? 'aws'
324
329
  }
325
330
 
326
- addHook({ name: '@smithy/smithy-client', versions: ['>=1.0.3'] }, smithy => {
327
- shimmer.wrap(smithy.Client.prototype, 'send', wrapSmithySend)
331
+ /** @param {{ Client: Function }} smithy */
332
+ function patchSmithyClient (smithy) {
333
+ const prototype = smithy.Client.prototype
334
+ // Recent smithy-client releases re-export core/client. Loading both entry points must not
335
+ // install two observers on the same send (and consume/charge every duplex event twice).
336
+ if (!patchedSmithyClients.has(prototype)) {
337
+ shimmer.wrap(prototype, 'send', wrapSmithySend)
338
+ patchedSmithyClients.add(prototype)
339
+ }
328
340
  return smithy
329
- })
341
+ }
330
342
 
331
- addHook({ name: '@aws-sdk/smithy-client', versions: ['>=3'] }, smithy => {
332
- shimmer.wrap(smithy.Client.prototype, 'send', wrapSmithySend)
333
- return smithy
334
- })
343
+ addHook({ name: '@smithy/smithy-client', versions: ['>=1.0.3'] }, patchSmithyClient)
344
+
345
+ addHook({ name: '@aws-sdk/smithy-client', versions: ['>=3'] }, patchSmithyClient)
335
346
 
336
347
  // `@aws-sdk/client-*` >= 3.1046.0 dropped `@smithy/smithy-client` and now
337
348
  // extends from `@smithy/core/client` directly. The `Client.send` contract is
@@ -341,10 +352,7 @@ addHook({
341
352
  name: '@smithy/core',
342
353
  file: 'dist-cjs/submodules/client/index.js',
343
354
  versions: ['>=3.24.0'],
344
- }, smithyCoreClient => {
345
- shimmer.wrap(smithyCoreClient.Client.prototype, 'send', wrapSmithySend)
346
- return smithyCoreClient
347
- })
355
+ }, patchSmithyClient)
348
356
 
349
357
  addHook({ name: 'aws-sdk', versions: ['>=2.3.0'] }, AWS => {
350
358
  shimmer.wrap(AWS.config, 'setPromisesDependency', setPromisesDependency => {
@@ -11,6 +11,7 @@ const finishCh = channel('apm:cassandra-driver:query:finish')
11
11
  const errorCh = channel('apm:cassandra-driver:query:error')
12
12
  const connectCh = channel('apm:cassandra-driver:query:connect')
13
13
 
14
+ /** @type {Record<string, unknown> & { error?: Error }} */
14
15
  let startCtx = {}
15
16
 
16
17
  addHook({ name: 'cassandra-driver', versions: ['>=3.0.0'] }, cassandra => {
@@ -24,23 +25,23 @@ addHook({ name: 'cassandra-driver', versions: ['>=3.0.0'] }, cassandra => {
24
25
  startCtx = { keyspace: this.keyspace, query: queries, contactPoints: this.options && this.options.contactPoints }
25
26
  return startCh.runStores(startCtx, () => {
26
27
  if (typeof cb === 'function') {
27
- arguments[lastIndex] = wrapCallback(finishCh, errorCh, startCtx, cb)
28
+ arguments[lastIndex] = wrapCallback(startCtx, cb)
28
29
  }
29
30
 
30
31
  try {
31
32
  const res = batch.apply(this, arguments)
32
33
  if (typeof res === 'function') {
33
- return wrapCallback(finishCh, errorCh, startCtx, res)
34
+ return wrapCallback(startCtx, res)
34
35
  }
35
36
  if (!res) {
36
37
  return res
37
38
  }
38
39
  return res.then(
39
- () => finish(finishCh, errorCh, startCtx),
40
- err => finish(finishCh, errorCh, startCtx, err)
40
+ () => finish(startCtx),
41
+ err => finish(startCtx, err)
41
42
  )
42
43
  } catch (e) {
43
- finish(finishCh, errorCh, startCtx, e)
44
+ finish(startCtx, e)
44
45
  throw e
45
46
  }
46
47
  })
@@ -58,8 +59,8 @@ addHook({ name: 'cassandra-driver', versions: ['>=4.4'], patchDefault: false },
58
59
  const promise = _execute.apply(this, arguments)
59
60
 
60
61
  promise.then(
61
- () => finish(finishCh, errorCh, startCtx),
62
- err => finish(finishCh, errorCh, startCtx, err)
62
+ () => finish(startCtx),
63
+ err => finish(startCtx, err)
63
64
  )
64
65
  return promise
65
66
  })
@@ -74,10 +75,7 @@ const isValid = (args) => {
74
75
  addHook({ name: 'cassandra-driver', versions: ['3 - 4.3'], patchDefault: false }, (cassandra) => {
75
76
  shimmer.wrap(cassandra.Client.prototype, '_innerExecute', _innerExecute =>
76
77
  function (query, params, execOptions, callback) {
77
- if (!startCh.hasSubscribers) {
78
- return _innerExecute.apply(this, arguments)
79
- }
80
- if (!isValid(arguments)) {
78
+ if (!startCh.hasSubscribers || !isValid(arguments)) {
81
79
  return _innerExecute.apply(this, arguments)
82
80
  }
83
81
 
@@ -87,13 +85,13 @@ addHook({ name: 'cassandra-driver', versions: ['3 - 4.3'], patchDefault: false }
87
85
  const cb = arguments[lastIndex]
88
86
 
89
87
  if (typeof cb === 'function') {
90
- arguments[lastIndex] = wrapCallback(finishCh, errorCh, startCtx, cb)
88
+ arguments[lastIndex] = wrapCallback(startCtx, cb)
91
89
  }
92
90
 
93
91
  try {
94
92
  return _innerExecute.apply(this, arguments)
95
93
  } catch (e) {
96
- finish(finishCh, errorCh, startCtx, e)
94
+ finish(startCtx, e)
97
95
  throw e
98
96
  }
99
97
  })
@@ -156,7 +154,11 @@ addHook({ name: 'cassandra-driver', versions: ['3 - 3.2'], file: 'lib/request-ha
156
154
  return RequestHandler
157
155
  })
158
156
 
159
- function finish (finishCh, errorCh, ctx, error) {
157
+ /**
158
+ * @param {Record<string, unknown> & { error?: Error }} ctx
159
+ * @param {Error} [error]
160
+ */
161
+ function finish (ctx, error) {
160
162
  if (error) {
161
163
  ctx.error = error
162
164
  errorCh.publish(ctx)
@@ -164,19 +166,22 @@ function finish (finishCh, errorCh, ctx, error) {
164
166
  finishCh.runStores(ctx, () => {})
165
167
  }
166
168
 
167
- function wrapCallback (finishCh, errorCh, ctx, callback) {
169
+ /**
170
+ * @param {Record<string, unknown> & { error?: Error }} ctx
171
+ * @param {Parameters<typeof finishCh.runStores>[1]} callback
172
+ */
173
+ function wrapCallback (ctx, callback) {
168
174
  return shimmer.wrapCallback(callback, callback => function (err) {
169
175
  if (err) {
170
176
  ctx.error = err
171
177
  errorCh.publish(ctx)
172
178
  }
173
- return finishCh.runStores(ctx, callback, this, ...arguments)
179
+ return finishCh.runStores(
180
+ ctx, /** @type {Parameters<typeof finishCh.runStores>[1]} */ (callback), this, ...arguments
181
+ )
174
182
  })
175
183
  }
176
184
 
177
185
  function isRequestValid (exec, args, length) {
178
- if (!exec) return false
179
- if (args.length !== length || typeof args[length - 1] !== 'function') return false
180
-
181
- return true
186
+ return !!exec && args.length === length && typeof args[length - 1] === 'function'
182
187
  }
@@ -2,7 +2,6 @@
2
2
 
3
3
  const { tracingChannel } = require('dc-polyfill')
4
4
  const shimmer = require('../../datadog-shimmer')
5
- const { addHook, getHooks } = require('./helpers/instrument')
6
5
  const queryChannel = tracingChannel('orchestrion:@anthropic-ai/claude-agent-sdk:query')
7
6
 
8
7
  const stepCh = tracingChannel('apm:claude-agent-sdk:step')
@@ -638,28 +637,15 @@ function wrapQueryAsyncIterator (asyncIterator, ctx) {
638
637
  }
639
638
  }
640
639
 
641
- let querySubscribed = false
640
+ queryChannel.subscribe({
641
+ start: onQueryStart,
642
+ end (ctx) {
643
+ if (!ctx.claudeAgentSdkTracing) return
642
644
 
643
- for (const hook of getHooks('@anthropic-ai/claude-agent-sdk').values()) {
644
- hook.file = null
645
+ const { result } = ctx
645
646
 
646
- addHook(hook, exports => {
647
- if (!querySubscribed) {
648
- querySubscribed = true
649
- queryChannel.subscribe({
650
- start: onQueryStart,
651
- end (ctx) {
652
- if (!ctx.claudeAgentSdkTracing) return
647
+ ctx.streamResolved = false
653
648
 
654
- const { result } = ctx
655
-
656
- ctx.streamResolved = false
657
-
658
- shimmer.wrap(result, Symbol.asyncIterator, asyncIterator => wrapQueryAsyncIterator(asyncIterator, ctx))
659
- },
660
- })
661
- }
662
-
663
- return exports
664
- })
665
- }
649
+ shimmer.wrap(result, Symbol.asyncIterator, asyncIterator => wrapQueryAsyncIterator(asyncIterator, ctx))
650
+ },
651
+ })