dd-trace 5.134.0 → 5.136.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 (353) hide show
  1. package/LICENSE-3rdparty.csv +0 -1
  2. package/ci/cypress/support.js +15 -1
  3. package/ci/init.js +2 -22
  4. package/ci/test-annotations.d.ts +5 -0
  5. package/ci/test-annotations.js +5 -0
  6. package/ci/vitest-no-worker-init-annotations.mjs +4 -0
  7. package/ci/vitest-no-worker-init-node-setup.mjs +22 -0
  8. package/ci/vitest-no-worker-init-runner-setup.mjs +7 -32
  9. package/ci/vitest-no-worker-init-setup.mjs +34 -12
  10. package/ci/vitest-no-worker-init-v5-setup.mjs +6 -0
  11. package/ext/exporters.js +1 -1
  12. package/index.d.ts +124 -5
  13. package/initialize.mjs +5 -2
  14. package/lambda.d.ts +39 -0
  15. package/lambda.js +3 -0
  16. package/loader-hook.mjs +53 -0
  17. package/openfeature/exposure-hook.d.ts +66 -0
  18. package/openfeature/exposure-hook.js +5 -0
  19. package/package.json +19 -15
  20. package/packages/datadog-core/src/storage.js +1 -1
  21. package/packages/datadog-esbuild/index.js +78 -62
  22. package/packages/datadog-instrumentations/src/aws-lambda.js +88 -0
  23. package/packages/datadog-instrumentations/src/cucumber.js +56 -19
  24. package/packages/datadog-instrumentations/src/cypress-config.js +163 -15
  25. package/packages/datadog-instrumentations/src/elevenlabs/activity.js +114 -0
  26. package/packages/datadog-instrumentations/src/elevenlabs/audio.js +104 -0
  27. package/packages/datadog-instrumentations/src/elevenlabs/index.js +288 -0
  28. package/packages/datadog-instrumentations/src/elevenlabs/session.js +444 -0
  29. package/packages/datadog-instrumentations/src/graphql.js +29 -20
  30. package/packages/datadog-instrumentations/src/grpc/server.js +23 -6
  31. package/packages/{datadog-esbuild/src/utils.js → datadog-instrumentations/src/helpers/bundler-esm-exports.js} +282 -40
  32. package/packages/datadog-instrumentations/src/helpers/bundler-transform.js +573 -0
  33. package/packages/datadog-instrumentations/src/helpers/bundler-utils.js +104 -0
  34. package/packages/datadog-instrumentations/src/helpers/fetch.js +5 -1
  35. package/packages/datadog-instrumentations/src/helpers/graphql-jit-runtime.js +30 -8
  36. package/packages/datadog-instrumentations/src/helpers/hook.js +29 -1
  37. package/packages/datadog-instrumentations/src/helpers/hooks.js +4 -8
  38. package/packages/datadog-instrumentations/src/helpers/lambda-handler.js +189 -0
  39. package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +18 -6
  40. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +26 -1
  41. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/async-mutex.js +41 -0
  42. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/elevenlabs.js +25 -0
  43. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql-jit.js +3 -1
  44. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql.js +0 -36
  45. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/next.js +40 -0
  46. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/openai-agents-realtime.js +23 -0
  47. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/react-router.js +49 -0
  48. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/trpc.js +148 -0
  49. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/typesafe.js +23 -0
  50. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/webdriverio.js +12 -0
  51. package/packages/datadog-instrumentations/src/helpers/rewriter/target-patterns.json +58 -0
  52. package/packages/datadog-instrumentations/src/helpers/rewriter/targets.js +19 -2
  53. package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +25 -3
  54. package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +59 -2
  55. package/packages/datadog-instrumentations/src/ioredis.js +101 -3
  56. package/packages/datadog-instrumentations/src/jest.js +265 -82
  57. package/packages/datadog-instrumentations/src/mariadb-bundle.js +69 -11
  58. package/packages/datadog-instrumentations/src/mariadb.js +13 -6
  59. package/packages/datadog-instrumentations/src/mocha/common.js +89 -8
  60. package/packages/datadog-instrumentations/src/mocha/main.js +11 -2
  61. package/packages/datadog-instrumentations/src/mocha/utils.js +58 -12
  62. package/packages/datadog-instrumentations/src/mocha/worker.js +1 -1
  63. package/packages/datadog-instrumentations/src/next.js +19 -6
  64. package/packages/datadog-instrumentations/src/openai-agents-realtime.js +149 -0
  65. package/packages/datadog-instrumentations/src/openai-realtime/audio-accumulator.js +27 -0
  66. package/packages/datadog-instrumentations/src/openai-realtime/index.js +17 -6
  67. package/packages/datadog-instrumentations/src/openai-realtime/server-playback.js +887 -0
  68. package/packages/datadog-instrumentations/src/openai-realtime/session.js +150 -25
  69. package/packages/datadog-instrumentations/src/openai-realtime/turns.js +29 -2
  70. package/packages/datadog-instrumentations/src/oracledb.js +33 -0
  71. package/packages/datadog-instrumentations/src/otel-sdk-trace.js +11 -9
  72. package/packages/datadog-instrumentations/src/pg.js +2 -1
  73. package/packages/datadog-instrumentations/src/playwright.js +81 -28
  74. package/packages/datadog-instrumentations/src/react-router.js +106 -0
  75. package/packages/datadog-instrumentations/src/typesafe.js +89 -0
  76. package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +84 -48
  77. package/packages/datadog-instrumentations/src/vitest-main.js +26 -0
  78. package/packages/datadog-instrumentations/src/vitest-test-annotations.js +20 -0
  79. package/packages/datadog-instrumentations/src/vitest-worker.js +39 -17
  80. package/packages/datadog-instrumentations/src/vitest.js +10 -8
  81. package/packages/datadog-instrumentations/src/webdriverio.js +12 -12
  82. package/packages/datadog-plugin-async-mutex/src/index.js +50 -0
  83. package/packages/datadog-plugin-aws-lambda/src/index.js +106 -0
  84. package/packages/datadog-plugin-cucumber/src/index.js +5 -0
  85. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +296 -55
  86. package/packages/datadog-plugin-cypress/src/index.js +1 -1
  87. package/packages/datadog-plugin-cypress/src/lifecycle-owner.js +20 -0
  88. package/packages/datadog-plugin-cypress/src/plugin.js +10 -0
  89. package/packages/datadog-plugin-cypress/src/retry-config-observer.js +281 -0
  90. package/packages/datadog-plugin-cypress/src/setup-handoff.js +125 -0
  91. package/packages/datadog-plugin-cypress/src/support.js +1217 -439
  92. package/packages/datadog-plugin-elevenlabs/src/index.js +69 -0
  93. package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +10 -7
  94. package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +19 -52
  95. package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +4 -2
  96. package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-request-context.js +25 -4
  97. package/packages/datadog-plugin-graphql/src/execute.js +2 -2
  98. package/packages/datadog-plugin-graphql/src/utils.js +5 -5
  99. package/packages/datadog-plugin-http/src/client.js +32 -9
  100. package/packages/datadog-plugin-http2/src/client.js +38 -13
  101. package/packages/datadog-plugin-jest/src/index.js +25 -3
  102. package/packages/datadog-plugin-mocha/src/index.js +47 -6
  103. package/packages/datadog-plugin-next/src/index.js +112 -14
  104. package/packages/datadog-plugin-oracledb/src/connection-parser.js +21 -11
  105. package/packages/datadog-plugin-playwright/src/index.js +4 -0
  106. package/packages/datadog-plugin-prisma/src/datadog-tracing-helper.js +5 -3
  107. package/packages/datadog-plugin-react-router/src/index.js +118 -0
  108. package/packages/datadog-plugin-trpc/src/index.js +15 -0
  109. package/packages/datadog-plugin-trpc/src/procedure.js +48 -0
  110. package/packages/datadog-plugin-trpc/src/request.js +81 -0
  111. package/packages/datadog-plugin-typesafe/src/index.js +17 -0
  112. package/packages/datadog-plugin-typesafe/src/tracing.js +31 -0
  113. package/packages/datadog-plugin-undici/src/index.js +22 -7
  114. package/packages/datadog-plugin-vitest/src/index.js +8 -0
  115. package/packages/datadog-turbopack/index.js +4 -28
  116. package/packages/datadog-turbopack/src/loader.js +14 -452
  117. package/packages/datadog-webpack/index.js +3 -55
  118. package/packages/dd-trace/src/agent/info.js +2 -1
  119. package/packages/dd-trace/src/aiguard/evaluation.js +62 -1
  120. package/packages/dd-trace/src/aiguard/sdk.js +8 -13
  121. package/packages/dd-trace/src/aiguard/tags.js +2 -0
  122. package/packages/dd-trace/src/appsec/blocking/index.js +4 -0
  123. package/packages/dd-trace/src/appsec/graphql.js +91 -6
  124. package/packages/dd-trace/src/appsec/recommended.json +1287 -90
  125. package/packages/dd-trace/src/before-exit.js +32 -0
  126. package/packages/dd-trace/src/bootstrap.js +5 -3
  127. package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +24 -18
  128. package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +16 -36
  129. package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +41 -13
  130. package/packages/dd-trace/src/ci-visibility/exporters/request.js +2 -3
  131. package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +10 -18
  132. package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +10 -15
  133. package/packages/dd-trace/src/ci-visibility/requests/route.js +44 -0
  134. package/packages/dd-trace/src/ci-visibility/telemetry-logs.js +5 -0
  135. package/packages/dd-trace/src/ci-visibility/telemetry.js +6 -0
  136. package/packages/dd-trace/src/ci-visibility/test-annotations.js +72 -0
  137. package/packages/dd-trace/src/ci-visibility/test-declaration-annotations.js +170 -0
  138. package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +10 -17
  139. package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache-schema.js +9 -134
  140. package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache.js +11 -156
  141. package/packages/dd-trace/src/config/config-types.d.ts +3 -0
  142. package/packages/dd-trace/src/config/defaults.js +9 -3
  143. package/packages/dd-trace/src/config/generated-config-types.d.ts +46 -2
  144. package/packages/dd-trace/src/config/index.js +111 -43
  145. package/packages/dd-trace/src/config/parsers.js +18 -1
  146. package/packages/dd-trace/src/config/supported-configurations.json +174 -4
  147. package/packages/dd-trace/src/constants.js +1 -0
  148. package/packages/dd-trace/src/debugger/pause-duration-histogram.js +2 -1
  149. package/packages/dd-trace/src/debugger/probe_sampler.js +6 -6
  150. package/packages/dd-trace/src/encode/0.4.js +2 -2
  151. package/packages/dd-trace/src/esm-module-load.js +58 -0
  152. package/packages/dd-trace/src/exporter.js +23 -15
  153. package/packages/dd-trace/src/exporters/agent/index.js +3 -1
  154. package/packages/dd-trace/src/exporters/agentless/index.js +3 -1
  155. package/packages/dd-trace/src/exporters/common/request.js +83 -50
  156. package/packages/dd-trace/src/exporters/common/retry.js +12 -7
  157. package/packages/dd-trace/src/exporters/common/url.js +1 -1
  158. package/packages/dd-trace/src/exporters/llmobs/index.js +135 -0
  159. package/packages/dd-trace/src/exporters/log/index.js +4 -3
  160. package/packages/dd-trace/src/id.js +1 -1
  161. package/packages/dd-trace/src/lambda/facade.js +74 -0
  162. package/packages/dd-trace/src/lambda/handler.js +3 -41
  163. package/packages/dd-trace/src/lambda/index.js +38 -15
  164. package/packages/dd-trace/src/lambda/runtime/patch.js +19 -3
  165. package/packages/dd-trace/src/lambda/wrap.js +44 -0
  166. package/packages/dd-trace/src/llmobs/constants/tags.js +3 -0
  167. package/packages/dd-trace/src/llmobs/experiments/experiment.js +10 -5
  168. package/packages/dd-trace/src/llmobs/experiments/index.js +2 -3
  169. package/packages/dd-trace/src/llmobs/experiments/noop.js +5 -2
  170. package/packages/dd-trace/src/llmobs/index.js +13 -2
  171. package/packages/dd-trace/src/llmobs/plugins/claude-agent-sdk/index.js +1 -1
  172. package/packages/dd-trace/src/llmobs/plugins/elevenlabs.js +96 -0
  173. package/packages/dd-trace/src/llmobs/plugins/genai/index.js +1 -1
  174. package/packages/dd-trace/src/llmobs/plugins/genai/util.js +27 -10
  175. package/packages/dd-trace/src/llmobs/plugins/openai/realtime.js +38 -11
  176. package/packages/dd-trace/src/llmobs/plugins/typesafe/index.js +102 -0
  177. package/packages/dd-trace/src/llmobs/plugins/vertexai.js +10 -2
  178. package/packages/dd-trace/src/llmobs/prompts/cache.js +3 -1
  179. package/packages/dd-trace/src/llmobs/sdk.js +21 -1
  180. package/packages/dd-trace/src/llmobs/span_processor.js +219 -12
  181. package/packages/dd-trace/src/llmobs/tagger.js +25 -0
  182. package/packages/dd-trace/src/llmobs/writers/util.js +3 -3
  183. package/packages/dd-trace/src/log/channels.js +4 -0
  184. package/packages/dd-trace/src/log/writer.js +13 -2
  185. package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +68 -6
  186. package/packages/dd-trace/src/openfeature/configuration_source.js +41 -17
  187. package/packages/dd-trace/src/openfeature/debug-logging-hook.js +66 -3
  188. package/packages/dd-trace/src/openfeature/exposure-hook.js +185 -0
  189. package/packages/dd-trace/src/openfeature/flag-selection.js +152 -0
  190. package/packages/dd-trace/src/openfeature/flagging_provider.js +58 -14
  191. package/packages/dd-trace/src/openfeature/remote_config.js +16 -3
  192. package/packages/dd-trace/src/openfeature/writers/base.js +63 -30
  193. package/packages/dd-trace/src/openfeature/writers/exposures.js +161 -1
  194. package/packages/dd-trace/src/openfeature/writers/flag-eval-evp-hook.js +5 -0
  195. package/packages/dd-trace/src/openfeature/writers/flag-evaluation-aggregation.js +9 -4
  196. package/packages/dd-trace/src/openfeature/writers/flag-evaluation-payload.js +2 -0
  197. package/packages/dd-trace/src/openfeature/writers/flag-evaluation-pii.js +2 -0
  198. package/packages/dd-trace/src/openfeature/writers/split-features.js +25 -0
  199. package/packages/dd-trace/src/opentelemetry/logs/index.js +11 -0
  200. package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +1 -1
  201. package/packages/dd-trace/src/opentelemetry/metrics/index.js +7 -1
  202. package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +1 -1
  203. package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_exporter.js +4 -1
  204. package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +2 -2
  205. package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +19 -1
  206. package/packages/dd-trace/src/opentelemetry/span-ending-hook.js +5 -1
  207. package/packages/dd-trace/src/opentelemetry/span-helpers.js +6 -1
  208. package/packages/dd-trace/src/opentelemetry/span.js +2 -2
  209. package/packages/dd-trace/src/opentelemetry/startup-config.js +174 -0
  210. package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +1 -1
  211. package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +7 -1
  212. package/packages/dd-trace/src/opentelemetry/tracer_provider.js +5 -1
  213. package/packages/dd-trace/src/opentracing/propagation/tracestate.js +77 -23
  214. package/packages/dd-trace/src/opentracing/tracer.js +33 -13
  215. package/packages/dd-trace/src/otel-thread-ctx.js +72 -49
  216. package/packages/dd-trace/src/plugin_manager.js +34 -7
  217. package/packages/dd-trace/src/plugins/ci_plugin.js +45 -14
  218. package/packages/dd-trace/src/plugins/index.js +9 -0
  219. package/packages/dd-trace/src/plugins/plugin.js +4 -2
  220. package/packages/dd-trace/src/plugins/tracing.js +1 -1
  221. package/packages/dd-trace/src/plugins/util/ci.js +18 -1
  222. package/packages/dd-trace/src/plugins/util/git-cache.js +4 -4
  223. package/packages/dd-trace/src/plugins/util/git.js +273 -86
  224. package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +77 -50
  225. package/packages/dd-trace/src/plugins/util/inferred_proxy.js +12 -4
  226. package/packages/dd-trace/src/plugins/util/status-validator.js +23 -10
  227. package/packages/dd-trace/src/plugins/util/tags.js +6 -0
  228. package/packages/dd-trace/src/plugins/util/test.js +90 -45
  229. package/packages/dd-trace/src/plugins/util/url.js +10 -2
  230. package/packages/dd-trace/src/plugins/util/user-provided-git.js +2 -2
  231. package/packages/dd-trace/src/plugins/util/web.js +81 -10
  232. package/packages/dd-trace/src/process-tags/index.js +1 -1
  233. package/packages/dd-trace/src/profiling/config.js +6 -3
  234. package/packages/dd-trace/src/profiling/webspan-utils.js +6 -5
  235. package/packages/dd-trace/src/proxy.js +48 -57
  236. package/packages/dd-trace/src/serverless.js +3 -2
  237. package/packages/dd-trace/src/span_processor.js +41 -9
  238. package/packages/dd-trace/src/span_stats.js +28 -2
  239. package/packages/dd-trace/src/startup-log.js +8 -5
  240. package/packages/dd-trace/src/tagger.js +7 -5
  241. package/packages/dd-trace/src/telemetry/dependencies.js +4 -0
  242. package/packages/dd-trace/src/telemetry/index.js +3 -0
  243. package/packages/dd-trace/src/telemetry/logs/index.js +21 -2
  244. package/packages/dd-trace/src/telemetry/logs/log-collector.js +1 -0
  245. package/packages/dd-trace/src/telemetry/metrics.js +2 -1
  246. package/packages/dd-trace/src/telemetry/telemetry.js +10 -3
  247. package/packages/dd-trace/src/tracer.js +0 -2
  248. package/packages/dd-trace/src/util.js +1 -1
  249. package/packages/dd-trace/src/web-tags-cache.js +8 -9
  250. package/register.js +4 -2
  251. package/vendor/dist/@apm-js-collab/code-transformer/LICENSE +489 -0
  252. package/vendor/dist/{@opentelemetry/resources → @datadog/flagging-core}/LICENSE +22 -2
  253. package/vendor/dist/@datadog/flagging-core/index.js +1 -0
  254. package/vendor/dist/@datadog/openfeature-node-server/LICENSE +21 -1
  255. package/vendor/dist/@datadog/openfeature-node-server/index.js +1 -1
  256. package/vendor/dist/@datadog/openfeature-node-server/rules-based/LICENSE +3 -1
  257. package/vendor/dist/@datadog/openfeature-node-server/rules-based/index.d.ts +78 -0
  258. package/vendor/dist/@datadog/openfeature-node-server/rules-based/index.js +1 -1
  259. package/vendor/dist/@datadog/sketches-js/LICENSE +263 -0
  260. package/vendor/dist/@datadog/source-map/LICENSE +1 -0
  261. package/vendor/dist/@isaacs/ttlcache/LICENSE +13 -0
  262. package/vendor/dist/@opentelemetry/core/LICENSE +209 -1
  263. package/vendor/dist/@opentelemetry/core/index.js +1 -1
  264. package/vendor/dist/crypto-randomuuid/LICENSE +3 -0
  265. package/vendor/dist/escape-string-regexp/LICENSE +13 -0
  266. package/vendor/dist/esquery/LICENSE +2 -0
  267. package/vendor/dist/https-proxy-agent/LICENSE +80 -1
  268. package/vendor/dist/istanbul-lib-coverage/LICENSE +2 -0
  269. package/vendor/dist/jest-docblock/LICENSE +16 -0
  270. package/vendor/dist/jsonpath-plus/LICENSE +13 -0
  271. package/vendor/dist/limiter/LICENSE +2 -0
  272. package/vendor/dist/lodash.sortby/LICENSE +2 -0
  273. package/vendor/dist/lru-cache/LICENSE +13 -0
  274. package/vendor/dist/meriyah/LICENSE +13 -0
  275. package/vendor/dist/module-details-from-path/LICENSE +2 -0
  276. package/vendor/dist/mutexify/promise/LICENSE +28 -0
  277. package/vendor/dist/pprof-format/LICENSE +13 -0
  278. package/vendor/dist/pprof-format/index.js +1 -1
  279. package/vendor/dist/protobufjs/LICENSE +219 -0
  280. package/vendor/dist/protobufjs/minimal/LICENSE +219 -0
  281. package/vendor/dist/proxy-from-env/LICENSE +13 -0
  282. package/vendor/dist/retry/LICENSE +2 -0
  283. package/vendor/dist/rfdc/LICENSE +2 -0
  284. package/vendor/dist/semifies/LICENSE +3 -1
  285. package/vendor/dist/shell-quote/LICENSE +3 -1
  286. package/vendor/dist/source-map/LICENSE +1 -0
  287. package/vendor/dist/source-map/lib/util/LICENSE +1 -0
  288. package/vendor/dist/tlhunter-sorted-set/LICENSE +2 -0
  289. package/vendor/dist/ttl-set/LICENSE +28 -0
  290. package/ci/diagnose.js +0 -2215
  291. package/ci/runbook.md +0 -299
  292. package/ci/test-optimization-validation/approval-artifacts.js +0 -175
  293. package/ci/test-optimization-validation/approval.js +0 -386
  294. package/ci/test-optimization-validation/artifact-id.js +0 -19
  295. package/ci/test-optimization-validation/blocker-category.js +0 -24
  296. package/ci/test-optimization-validation/bounded-json.js +0 -120
  297. package/ci/test-optimization-validation/ci-command-candidate.js +0 -77
  298. package/ci/test-optimization-validation/ci-discovery.js +0 -192
  299. package/ci/test-optimization-validation/ci-package-scripts.js +0 -169
  300. package/ci/test-optimization-validation/ci-remediation.js +0 -283
  301. package/ci/test-optimization-validation/cli.js +0 -954
  302. package/ci/test-optimization-validation/command-blocker.js +0 -377
  303. package/ci/test-optimization-validation/command-output-policy.js +0 -188
  304. package/ci/test-optimization-validation/command-runner.js +0 -650
  305. package/ci/test-optimization-validation/environment.js +0 -88
  306. package/ci/test-optimization-validation/executable-approval.js +0 -47
  307. package/ci/test-optimization-validation/executable.js +0 -244
  308. package/ci/test-optimization-validation/execution-lock.js +0 -70
  309. package/ci/test-optimization-validation/framework-adapters/cucumber-validation.json +0 -3
  310. package/ci/test-optimization-validation/framework-adapters/cucumber.js +0 -767
  311. package/ci/test-optimization-validation/framework-adapters/cypress.js +0 -99
  312. package/ci/test-optimization-validation/framework-adapters/playwright.js +0 -175
  313. package/ci/test-optimization-validation/framework-adapters/vitest.js +0 -513
  314. package/ci/test-optimization-validation/generated-file-policy.js +0 -63
  315. package/ci/test-optimization-validation/generated-files.js +0 -425
  316. package/ci/test-optimization-validation/generated-test-contract.js +0 -284
  317. package/ci/test-optimization-validation/generated-verifier.js +0 -235
  318. package/ci/test-optimization-validation/literal-environment.js +0 -56
  319. package/ci/test-optimization-validation/literal-glob.js +0 -52
  320. package/ci/test-optimization-validation/manifest-loader.js +0 -116
  321. package/ci/test-optimization-validation/manifest-scaffold.js +0 -1276
  322. package/ci/test-optimization-validation/manifest-schema.js +0 -695
  323. package/ci/test-optimization-validation/offline-fixtures.js +0 -335
  324. package/ci/test-optimization-validation/offline-output.js +0 -406
  325. package/ci/test-optimization-validation/package-check.js +0 -97
  326. package/ci/test-optimization-validation/payload-normalizer.js +0 -72
  327. package/ci/test-optimization-validation/plan-writer.js +0 -541
  328. package/ci/test-optimization-validation/preflight-runner.js +0 -186
  329. package/ci/test-optimization-validation/project-build-artifact.js +0 -31
  330. package/ci/test-optimization-validation/redaction.js +0 -319
  331. package/ci/test-optimization-validation/report-writer.js +0 -666
  332. package/ci/test-optimization-validation/result-semantics.js +0 -103
  333. package/ci/test-optimization-validation/runner-command.js +0 -264
  334. package/ci/test-optimization-validation/runner-contract.js +0 -695
  335. package/ci/test-optimization-validation/safe-files.js +0 -202
  336. package/ci/test-optimization-validation/scenarios/auto-test-retries.js +0 -171
  337. package/ci/test-optimization-validation/scenarios/basic-reporting.js +0 -407
  338. package/ci/test-optimization-validation/scenarios/ci-wiring.js +0 -666
  339. package/ci/test-optimization-validation/scenarios/early-flake-detection.js +0 -142
  340. package/ci/test-optimization-validation/scenarios/helpers.js +0 -621
  341. package/ci/test-optimization-validation/scenarios/test-management.js +0 -219
  342. package/ci/test-optimization-validation/source-text.js +0 -84
  343. package/ci/test-optimization-validation/static-diagnosis.js +0 -166
  344. package/ci/test-optimization-validation/test-output.js +0 -120
  345. package/ci/test-optimization-validation/validation-blocker.js +0 -21
  346. package/ci/validate-test-optimization.js +0 -3
  347. package/packages/datadog-esbuild/src/resolver.js +0 -284
  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
  353. package/vendor/dist/@opentelemetry/resources/index.js +0 -1
@@ -16,6 +16,7 @@ const {
16
16
  getDynamicAtrRetryCount,
17
17
  } = require('../../dd-trace/src/ci-visibility/dynamic-atr-retries')
18
18
  const { FINAL_FLUSH_TIMEOUT } = require('../../dd-trace/src/ci-visibility/final-flush')
19
+ const { getTestAnnotations, copyTestAnnotations } = require('../../dd-trace/src/ci-visibility/test-annotations')
19
20
  const {
20
21
  SCREENSHOT_UPLOAD_RESULT_ERROR,
21
22
  SCREENSHOT_UPLOAD_RESULT_UPLOADED,
@@ -283,6 +284,7 @@ class MochaPlugin extends CiPlugin {
283
284
  static id = 'mocha'
284
285
 
285
286
  #pendingWebdriverioVideos = new Set()
287
+ #webdriverioJasmineAnnotations = new Map()
286
288
  #webdriverioCapture
287
289
  #webdriverioVideoFlushTimer
288
290
 
@@ -402,6 +404,7 @@ class MochaPlugin extends CiPlugin {
402
404
  suiteFiles: new Map(),
403
405
  suiteStatuses: new Map(),
404
406
  tests: new Map(),
407
+ testAnnotations: this.#webdriverioJasmineAnnotations,
405
408
  }
406
409
  }
407
410
  })
@@ -414,6 +417,29 @@ class MochaPlugin extends CiPlugin {
414
417
  setWebdriverioRumTestCorrelation(ctx, activeSpan)
415
418
  })
416
419
 
420
+ this.addSub('tracing:orchestrion:@wdio/jasmine-framework:JasmineAdapter_init:start', () => {
421
+ // Declarations run during adapter initialization, before coordinator settings arrive.
422
+ this.#webdriverioJasmineAnnotations = new Map()
423
+ })
424
+
425
+ this.addSub('tracing:orchestrion:@wdio/utils:runSpec:end', (ctx) => {
426
+ if (!ctx.result?.id) return
427
+ const annotations = getTestAnnotations(ctx.arguments?.[1])
428
+ if (annotations.mustFail || annotations.noAutoRetry) {
429
+ if (ctx.result.type === 'test') {
430
+ if (ctx.result.fn) {
431
+ // Mocha's runnable holds WebdriverIO's wrapper rather than the annotated callback.
432
+ copyTestAnnotations(ctx.arguments[1], ctx.result.fn)
433
+ } else {
434
+ // Mocha discards callbacks inherited from a pending suite.
435
+ ctx.result._ddDeclaredAnnotations = annotations
436
+ }
437
+ } else {
438
+ this.#webdriverioJasmineAnnotations.set(ctx.result.id, annotations)
439
+ }
440
+ }
441
+ })
442
+
417
443
  this.addBind(jasmineTestFunctionStartCh, (ctx) => {
418
444
  if (this.testFrameworkAdapter !== WEBDRIVERIO_JASMINE_ADAPTER) {
419
445
  return storage('legacy').getStore()
@@ -853,7 +879,7 @@ class MochaPlugin extends CiPlugin {
853
879
  const store = storage('legacy').getStore()
854
880
  // skipped through it.skip, so the span is not created yet
855
881
  // for this test
856
- if (!store) {
882
+ if (!ctx.currentStore) {
857
883
  const span = this.startTestSpan(ctx)
858
884
 
859
885
  ctx.parentStore = store
@@ -1139,9 +1165,14 @@ class MochaPlugin extends CiPlugin {
1139
1165
  const testSuite = getTestSuitePath(testSuiteAbsolutePath, this.sourceRoot)
1140
1166
  const properties = this.libraryConfig?.testManagementTests?.mocha
1141
1167
  ?.suites?.[testSuite]?.tests?.[testName]?.properties || {}
1142
- const isAttemptToFix = this.libraryConfig?.isTestManagementTestsEnabled && properties.attempt_to_fix
1143
- const isDisabled = this.libraryConfig?.isTestManagementTestsEnabled && properties.disabled
1144
- const isQuarantined = this.libraryConfig?.isTestManagementTestsEnabled && properties.quarantined
1168
+ const testAnnotations = state.testAnnotations.get(result.id) || getTestAnnotations()
1169
+ const assignedProperties = this.libraryConfig?.isTestManagementTestsEnabled ? properties : undefined
1170
+ const isAttemptToFix = this.libraryConfig?.isTestManagementTestsEnabled &&
1171
+ !testAnnotations.noAutoRetry && properties.attempt_to_fix
1172
+ const isDisabled = this.libraryConfig?.isTestManagementTestsEnabled &&
1173
+ !testAnnotations.mustFail && properties.disabled
1174
+ const isQuarantined = this.libraryConfig?.isTestManagementTestsEnabled &&
1175
+ !testAnnotations.mustFail && properties.quarantined
1145
1176
  const isModified = this.libraryConfig?.isImpactedTestsEnabled && isModifiedTest(
1146
1177
  getTestSuitePath(testSuiteAbsolutePath, this.repositoryRoot || this.sourceRoot),
1147
1178
  null,
@@ -1152,10 +1183,10 @@ class MochaPlugin extends CiPlugin {
1152
1183
  const knownTests = this.libraryConfig?.knownTests?.mocha
1153
1184
  const isNew = this.libraryConfig?.isKnownTestsEnabled && knownTests &&
1154
1185
  !(knownTests[testSuite] || []).includes(testName)
1155
- const isEarlyFlakeDetection = this.libraryConfig?.isEarlyFlakeDetectionEnabled &&
1186
+ const isEarlyFlakeDetection = !testAnnotations.noAutoRetry && this.libraryConfig?.isEarlyFlakeDetectionEnabled &&
1156
1187
  hasEfdRetries(this.libraryConfig.earlyFlakeDetectionRetryPolicy) &&
1157
1188
  !isAttemptToFix && !isDisabled && (isNew || isModified)
1158
- const isAtr = this.libraryConfig?.isFlakyTestRetriesEnabled &&
1189
+ const isAtr = !testAnnotations.noAutoRetry && this.libraryConfig?.isFlakyTestRetriesEnabled &&
1159
1190
  !isAttemptToFix && !isEarlyFlakeDetection
1160
1191
  let retryCount = 0
1161
1192
  if (isAttemptToFix) {
@@ -1177,6 +1208,8 @@ class MochaPlugin extends CiPlugin {
1177
1208
  }
1178
1209
 
1179
1210
  const test = {
1211
+ assignedProperties,
1212
+ testAnnotations,
1180
1213
  attempt: 0,
1181
1214
  attemptStart: undefined,
1182
1215
  currentStore: undefined,
@@ -1242,6 +1275,8 @@ class MochaPlugin extends CiPlugin {
1242
1275
  test.attemptStart = performance.now()
1243
1276
  test.hasFinalHookFailure = false
1244
1277
  const span = this.startTestSpan({
1278
+ assignedProperties: test.assignedProperties,
1279
+ testAnnotations: test.testAnnotations,
1245
1280
  hasDynamicName: test.hasDynamicName,
1246
1281
  isAttemptToFix: test.isAttemptToFix,
1247
1282
  isDisabled: test.isDisabled,
@@ -1923,6 +1958,12 @@ class MochaPlugin extends CiPlugin {
1923
1958
  } = testInfo
1924
1959
 
1925
1960
  const extraTags = {}
1961
+ const { testAnnotations, assignedProperties } = testInfo
1962
+ if (testAnnotations?.mustFail) extraTags['test.test_management.prevent_failure_suppression'] = 'true'
1963
+ if (testAnnotations?.noAutoRetry) extraTags['test.test_management.no_auto_retry'] = 'true'
1964
+ if (assignedProperties?.attempt_to_fix) extraTags[TEST_MANAGEMENT_IS_ATTEMPT_TO_FIX] = 'true'
1965
+ if (assignedProperties?.disabled) extraTags[TEST_MANAGEMENT_IS_DISABLED] = 'true'
1966
+ if (assignedProperties?.quarantined) extraTags[TEST_MANAGEMENT_IS_QUARANTINED] = 'true'
1926
1967
  const testParametersString = getTestParametersString(this._testTitleToParams, title)
1927
1968
  if (testParametersString) {
1928
1969
  extraTags[TEST_PARAMETERS] = testParametersString
@@ -1,15 +1,28 @@
1
1
  'use strict'
2
2
 
3
+ const { channel } = require('dc-polyfill')
4
+
3
5
  const ServerPlugin = require('../../dd-trace/src/plugins/server')
4
6
  const { storage } = require('../../datadog-core')
5
7
  const analyticsSampler = require('../../dd-trace/src/analytics_sampler')
6
8
  const { COMPONENT, SVC_SRC_KEY } = require('../../dd-trace/src/constants')
9
+ const {
10
+ HTTP_STATUS_ERROR,
11
+ INSTRUMENTATION_HTTP_RESOURCE,
12
+ isInstrumentationOwnedResource,
13
+ NETWORK_PEER_ADDRESS,
14
+ otelHttpResourceName,
15
+ setInstrumentationHttpResource,
16
+ } = require('../../dd-trace/src/plugins/util/http-otel-semantics')
7
17
  const web = require('../../dd-trace/src/plugins/util/web')
8
18
  const { HTTP_ROUTE, RESOURCE_NAME } = require('../../../ext/tags')
19
+ const { extractURL, obfuscateQs } = require('../../dd-trace/src/plugins/util/url')
9
20
 
10
21
  const errorPages = new Set(['/404', '/500', '/_error', '/_not-found', '/_not-found/page'])
11
22
  const reusedNextRequestStores = new WeakSet()
12
23
  const nextParentRoutes = new WeakMap()
24
+ const requestMeta = Symbol.for('NextInternalRequestMeta')
25
+ const finishChannel = channel('apm:next:request:finish')
13
26
 
14
27
  /**
15
28
  * @typedef {Record<string, unknown> & {
@@ -18,8 +31,7 @@ const nextParentRoutes = new WeakMap()
18
31
  * backgroundRevalidationRequest?: import('node:http').IncomingMessage
19
32
  * }} NextRequestStore
20
33
  *
21
- * @typedef {object} NextRequest
22
- * @property {unknown} [error]
34
+ * @typedef {Request & { error?: unknown }} NextRequest
23
35
  *
24
36
  * @typedef {object} NextRequestContext
25
37
  * @property {import('node:http').IncomingMessage} req
@@ -47,6 +59,33 @@ class NextPlugin extends ServerPlugin {
47
59
  backgroundRevalidationRequest: req,
48
60
  }))
49
61
  this.addSub('apm:next:page:load', message => this.pageLoad(message))
62
+ for (const operation of ['imageRequest', 'imageRequestWithMiddleware']) {
63
+ const prefix = `tracing:orchestrion:next:${operation}`
64
+ this.addBind(`${prefix}:start`, ctx => {
65
+ const args = ctx.arguments
66
+ const pathname = (args[3] || args[2])?.pathname
67
+ if (!pathname?.startsWith('/_next/image')) return storage('legacy').getStore()
68
+ if (operation === 'imageRequestWithMiddleware' && args[0][requestMeta]?.middlewareInvoke) {
69
+ return storage('legacy').getStore()
70
+ }
71
+
72
+ ctx.req = args[0].originalRequest || args[0]
73
+ ctx.res = args[1].originalResponse || args[1]
74
+ ctx.currentStore = this.bindStart(ctx)
75
+ return ctx.currentStore
76
+ })
77
+ this.addSub(`${prefix}:start`, ctx => {
78
+ if (ctx.currentStore) this.pageLoad({ page: '/_next/image' })
79
+ })
80
+ this.addSub(`${prefix}:asyncEnd`, ctx => {
81
+ if (!ctx.currentStore) return
82
+ if (ctx.error && !ctx.res.destroyed && !reusedNextRequestStores.has(ctx.currentStore)) {
83
+ ctx.res.once('close', () => finishChannel.publish(ctx))
84
+ } else {
85
+ this.finish(ctx)
86
+ }
87
+ })
88
+ }
50
89
  }
51
90
 
52
91
  /** @param {NextRequestContext} ctx */
@@ -76,6 +115,11 @@ class NextPlugin extends ServerPlugin {
76
115
  'http.method': req.method,
77
116
  }
78
117
  if (serviceSource !== undefined) tags[SVC_SRC_KEY] = serviceSource
118
+ if (this.config.DD_TRACE_OTEL_SEMANTICS_ENABLED) {
119
+ const resource = otelHttpResourceName(req.method)
120
+ tags['resource.name'] = resource
121
+ tags[INSTRUMENTATION_HTTP_RESOURCE] = resource
122
+ }
79
123
 
80
124
  const span = this.tracer.startSpan(this.operationName(), {
81
125
  childOf,
@@ -83,6 +127,8 @@ class NextPlugin extends ServerPlugin {
83
127
  integrationName: this.constructor.id,
84
128
  })
85
129
 
130
+ if (this.config.DD_TRACE_OTEL_SEMANTICS_ENABLED) addOtelRequestTags(span, this.config, req)
131
+
86
132
  this.stampIntegrationService(span, serviceName)
87
133
 
88
134
  analyticsSampler.sample(span, this.config.measured, true)
@@ -104,14 +150,14 @@ class NextPlugin extends ServerPlugin {
104
150
 
105
151
  /** @param {NextRequestContext} ctx */
106
152
  finish (ctx) {
107
- const { req, res, nextRequest = {} } = ctx
153
+ const { req, res, nextRequest } = ctx
108
154
  const store = ctx.currentStore ?? storage('legacy').getStore()
109
155
 
110
156
  if (!store || reusedNextRequestStores.has(store)) return
111
157
 
112
158
  const span = store.span
113
159
  const error = ctx.error ?? span.context().getTag('error')
114
- const requestError = req.error || nextRequest.error
160
+ const requestError = req.error || nextRequest?.error
115
161
 
116
162
  if (requestError) {
117
163
  // prioritize user-set errors from API routes
@@ -124,6 +170,9 @@ class NextPlugin extends ServerPlugin {
124
170
  } else if (!this.config.validateStatus(res.statusCode)) {
125
171
  // where there's no error, we still need to validate status
126
172
  span.setTag('error', true)
173
+ if (this.config.DD_TRACE_OTEL_SEMANTICS_ENABLED) {
174
+ span.setTag(HTTP_STATUS_ERROR, String(res.statusCode))
175
+ }
127
176
  web.addError(req, true)
128
177
  }
129
178
 
@@ -146,11 +195,11 @@ class NextPlugin extends ServerPlugin {
146
195
  // safeguard against missing req in complicated timeout scenarios
147
196
  if (!req) return
148
197
 
149
- // Only use error page names if there's not already a name
198
+ // Nested requests, static loads, and error pages must preserve the matched route.
150
199
  const current = span.context().getTag('next.page')
151
200
  const isErrorPage = errorPages.has(page)
152
201
 
153
- if (current && isErrorPage) {
202
+ if (current && (isErrorPage || isStatic || reusedNextRequestStores.has(store))) {
154
203
  return
155
204
  }
156
205
 
@@ -167,13 +216,24 @@ class NextPlugin extends ServerPlugin {
167
216
  : '/public/*'
168
217
  }
169
218
 
170
- span.addTags({
171
- [COMPONENT]: this.constructor.id,
172
- 'resource.name': `${req.method} ${page}`.trim(),
173
- 'next.page': page,
174
- })
219
+ let resource = `${req.method} ${page}`.trim()
220
+ span.setTag(COMPONENT, this.constructor.id)
221
+ span.setTag('next.page', page)
222
+ if (this.config.DD_TRACE_OTEL_SEMANTICS_ENABLED) {
223
+ resource = otelHttpResourceName(req.method, page)
224
+ span.setTag(HTTP_ROUTE, page)
225
+ setInstrumentationHttpResourceIfOwned(span, resource)
226
+ } else {
227
+ span.setTag(RESOURCE_NAME, resource)
228
+ }
175
229
  web.setRouteOrEndpointTag(req)
176
- setHttpParentRoute(httpParentSpan, req.method, page, isStatic)
230
+ setHttpParentRoute(
231
+ httpParentSpan,
232
+ page,
233
+ isStatic,
234
+ this.config.DD_TRACE_OTEL_SEMANTICS_ENABLED,
235
+ resource
236
+ )
177
237
  web.setRoute(req, page)
178
238
  }
179
239
 
@@ -200,7 +260,14 @@ function normalizeAppPath (page) {
200
260
  return page
201
261
  }
202
262
 
203
- function setHttpParentRoute (span, method, page, isStatic) {
263
+ /**
264
+ * @param {import('../../dd-trace/src/opentracing/span') | undefined} span
265
+ * @param {string | undefined} page
266
+ * @param {boolean} isStatic
267
+ * @param {boolean} otelSemanticsEnabled
268
+ * @param {string} resource
269
+ */
270
+ function setHttpParentRoute (span, page, isStatic, otelSemanticsEnabled, resource) {
204
271
  if (!span) return
205
272
  const currentRoute = span.context().getTag(HTTP_ROUTE)
206
273
 
@@ -208,7 +275,38 @@ function setHttpParentRoute (span, method, page, isStatic) {
208
275
  if (currentRoute && (nextParentRoutes.get(span) !== currentRoute || isStatic)) return
209
276
 
210
277
  span.setTag(HTTP_ROUTE, page)
211
- span.setTag(RESOURCE_NAME, `${method} ${page}`.trim())
278
+ if (otelSemanticsEnabled) {
279
+ setInstrumentationHttpResourceIfOwned(span, resource)
280
+ } else {
281
+ span.setTag(RESOURCE_NAME, resource)
282
+ }
212
283
  nextParentRoutes.set(span, page)
213
284
  }
285
+
286
+ /**
287
+ * @param {import('../../dd-trace/src/opentracing/span')} span
288
+ * @param {string} resource
289
+ */
290
+ function setInstrumentationHttpResourceIfOwned (span, resource) {
291
+ const context = span.context()
292
+ if (isInstrumentationOwnedResource(
293
+ context.getTag(RESOURCE_NAME),
294
+ context.getTag(INSTRUMENTATION_HTTP_RESOURCE)
295
+ )) {
296
+ setInstrumentationHttpResource(span, resource)
297
+ }
298
+ }
299
+ /**
300
+ * @param {import('../../dd-trace/src/opentracing/span')} span
301
+ * @param {Record<string, unknown>} config
302
+ * @param {import('node:http').IncomingMessage} req
303
+ */
304
+ function addOtelRequestTags (span, config, req) {
305
+ const userAgent = req.headers['user-agent']
306
+ const peerAddress = req.socket?.remoteAddress
307
+ span.setTag('http.url', obfuscateQs(config, extractURL(req)))
308
+ if (userAgent !== undefined) span.setTag('http.useragent', userAgent)
309
+ if (peerAddress) span.setTag(NETWORK_PEER_ADDRESS, peerAddress)
310
+ }
311
+
214
312
  module.exports = NextPlugin
@@ -4,6 +4,8 @@ const { URL } = require('url')
4
4
  const log = require('../../dd-trace/src/log')
5
5
 
6
6
  const easyConnectProtocol = /^tcps?:\/\//i
7
+ let cachedConnectString
8
+ let cachedInfo
7
9
 
8
10
  function parseOracleDescriptor (descriptor) {
9
11
  const hostnameMatch = descriptor.match(/HOST\s*=\s*([^)]+)/i)
@@ -22,18 +24,26 @@ function parseOracleDescriptor (descriptor) {
22
24
  module.exports = function getDBInformation (connAttrs) {
23
25
  // Users can pass either connectString or connectionString
24
26
  const connectString = ((connAttrs.connectString || connAttrs.connectionString) ?? '').trim()
27
+ if (connectString === cachedConnectString) return cachedInfo
28
+
29
+ let dbInfo
25
30
  if (connectString.startsWith('(')) {
26
- return parseOracleDescriptor(connectString)
27
- }
28
- try {
29
- const url = new URL(easyConnectProtocol.test(connectString) ? connectString : `oracle://${connectString}`)
30
- return {
31
- hostname: url.hostname || 'localhost', // Default Oracle hostname
32
- port: url.port || '1521', // Default Oracle port
33
- dbInstance: url.pathname && url.pathname.slice(1) || 'XEPDB1', // Default Oracle service name
31
+ dbInfo = parseOracleDescriptor(connectString)
32
+ } else {
33
+ try {
34
+ const url = new URL(easyConnectProtocol.test(connectString) ? connectString : `oracle://${connectString}`)
35
+ dbInfo = {
36
+ hostname: url.hostname || 'localhost', // Default Oracle hostname
37
+ port: url.port || '1521', // Default Oracle port
38
+ dbInstance: url.pathname && url.pathname.slice(1) || 'XEPDB1', // Default Oracle service name
39
+ }
40
+ } catch (error) {
41
+ log.error('Invalid oracle connection string', error)
42
+ return {}
34
43
  }
35
- } catch (error) {
36
- log.error('Invalid oracle connection string', error)
37
- return {}
38
44
  }
45
+
46
+ cachedConnectString = connectString
47
+ cachedInfo = dbInfo
48
+ return dbInfo
39
49
  }
@@ -510,6 +510,8 @@ class PlaywrightPlugin extends CiPlugin {
510
510
  testSourceFileAbsolutePath
511
511
  )
512
512
 
513
+ span.addTags(ctx.extraTags)
514
+
513
515
  if (isDisabled) {
514
516
  span.setTag(TEST_MANAGEMENT_IS_DISABLED, 'true')
515
517
  }
@@ -699,6 +701,7 @@ class PlaywrightPlugin extends CiPlugin {
699
701
  })
700
702
 
701
703
  this.addSub('ci:playwright:test:skip', ({
704
+ extraTags,
702
705
  testName,
703
706
  testSuiteAbsolutePath,
704
707
  testSourceFileAbsolutePath,
@@ -725,6 +728,7 @@ class PlaywrightPlugin extends CiPlugin {
725
728
  testSourceFileAbsolutePath
726
729
  )
727
730
 
731
+ span.addTags(extraTags)
728
732
  span.setTag(TEST_STATUS, 'skip')
729
733
  span.setTag(TEST_FINAL_STATUS, 'skip')
730
734
 
@@ -56,7 +56,7 @@ class DatadogTracingHelper {
56
56
  * @param {object[]} spans
57
57
  */
58
58
  dispatchEngineSpans (spans) {
59
- if (!spans?.length) {
59
+ if (!spans?.length || this.#prismaClient.config?.engine === false) {
60
60
  return
61
61
  }
62
62
  const childrenByParent = new Map()
@@ -90,8 +90,10 @@ class DatadogTracingHelper {
90
90
  * @returns {unknown}
91
91
  */
92
92
  runInChildSpan (options, callback) {
93
- if (!clientCH.start?.hasSubscribers) {
94
- return callback.apply(this, arguments)
93
+ // Skipping here rather than in the plugin's `bindStart` avoids finishing the parent span, which
94
+ // `finish()` would fall back to when no client span was started.
95
+ if (!clientCH.start?.hasSubscribers || this.#prismaClient.config?.client === false) {
96
+ return callback()
95
97
  }
96
98
  if (typeof options === 'string') {
97
99
  options = {
@@ -0,0 +1,118 @@
1
+ 'use strict'
2
+
3
+ const { storage } = require('../../datadog-core')
4
+ const analyticsSampler = require('../../dd-trace/src/analytics_sampler')
5
+ const { getRequest } = require('../../dd-trace/src/appsec/store')
6
+ const { COMPONENT } = require('../../dd-trace/src/constants')
7
+ const log = require('../../dd-trace/src/log')
8
+ const web = require('../../dd-trace/src/plugins/util/web')
9
+ const WebPlugin = require('../../datadog-plugin-web/src')
10
+ const { HTTP_ROUTE, HTTP_URL, RESOURCE_NAME } = require('../../../ext/tags')
11
+
12
+ /**
13
+ * @typedef {{ arguments: unknown[], result: Array<{ route?: { path?: string } }> | null }} RouteMatchContext
14
+ * @typedef {object} HandlerContext
15
+ * @property {string} routeId
16
+ * @property {string} [pattern]
17
+ * @property {(result: unknown, rejected: boolean) => void} [complete]
18
+ */
19
+
20
+ class ReactRouterPlugin extends WebPlugin {
21
+ static id = 'react-router'
22
+
23
+ /**
24
+ * @param {object} tracer
25
+ * @param {import('../../dd-trace/src/config/config-base')} tracerConfig
26
+ */
27
+ constructor (tracer, tracerConfig) {
28
+ super(tracer, tracerConfig)
29
+
30
+ this.addSub('tracing:orchestrion:react-router:matchServerRoutes:end', ctx => {
31
+ this.#setRouteFromMatches(/** @type {RouteMatchContext} */ (ctx))
32
+ })
33
+ this.addBind('apm:react-router:loader:start', ctx => {
34
+ return this.#startHandlerSpan('loader', /** @type {HandlerContext} */ (ctx))
35
+ })
36
+ this.addBind('apm:react-router:action:start', ctx => {
37
+ return this.#startHandlerSpan('action', /** @type {HandlerContext} */ (ctx))
38
+ })
39
+ }
40
+
41
+ /** @param {RouteMatchContext} ctx */
42
+ #setRouteFromMatches (ctx) {
43
+ const matches = ctx.result
44
+ if (!matches?.length) return
45
+
46
+ const store = storage('legacy').getStore()
47
+ const request = getRequest(store) ?? store?.req
48
+ const span = (request && web.root(request)) || web.rootFromSpan(
49
+ /** @type {import('../../dd-trace/src/opentracing/span') | undefined} */ (store?.span)
50
+ )
51
+ if (!span) return
52
+ const httpUrl = /** @type {string} */ (span.context().getTag(HTTP_URL))
53
+
54
+ let pathname
55
+ try {
56
+ pathname = new URL(httpUrl, 'http://localhost').pathname
57
+ } catch (error) {
58
+ log.debug('Skipping React Router route for invalid HTTP URL: %s', error)
59
+ return
60
+ }
61
+ const args = ctx.arguments
62
+ const matchedPathname = typeof args[1] === 'string' ? args[1] : args[3] ?? args[2]
63
+ if (pathname.endsWith('/_root.data') && typeof matchedPathname === 'string' &&
64
+ pathname.toLowerCase() === ((matchedPathname.endsWith('/')
65
+ ? matchedPathname.slice(0, -1)
66
+ : matchedPathname) + '/_root.data').toLowerCase()) {
67
+ pathname = matchedPathname
68
+ } else if (pathname.endsWith('.data')) {
69
+ pathname = pathname.slice(0, -'.data'.length)
70
+ }
71
+ if (pathname.length > 1 && pathname.endsWith('/')) pathname = pathname.slice(0, -1)
72
+
73
+ if (pathname !== matchedPathname && pathname + '/' !== matchedPathname &&
74
+ !(pathname.endsWith('/_') && pathname.slice(0, -1) === matchedPathname)) return
75
+
76
+ let route = ''
77
+ for (const match of matches) {
78
+ const path = match.route?.path
79
+ if (path) route = path.startsWith('/') ? path : route + '/' + path
80
+ }
81
+ route = route.replaceAll(/\/+/g, '/') || '/'
82
+
83
+ span.setTag(HTTP_ROUTE, route)
84
+ }
85
+
86
+ /**
87
+ * @param {'loader' | 'action'} kind
88
+ * @param {HandlerContext} ctx
89
+ */
90
+ #startHandlerSpan (kind, ctx) {
91
+ const store = storage('legacy').getStore()
92
+ const childOf = store?.span
93
+ if (!childOf) return store
94
+
95
+ const span = this.tracer.startSpan('react-router.' + kind, {
96
+ childOf,
97
+ integrationName: ReactRouterPlugin.id,
98
+ tags: {
99
+ [COMPONENT]: ReactRouterPlugin.id,
100
+ [RESOURCE_NAME]: ctx.pattern,
101
+ 'react-router.route_id': ctx.routeId,
102
+ },
103
+ })
104
+ analyticsSampler.sample(span, this.config.measured, true)
105
+
106
+ ctx.complete = (result, rejected) => {
107
+ const outcome = /** @type {{ status?: string, error?: Error }} */ (result)
108
+ const error = rejected ? result : outcome?.status === 'error' ? outcome.error : undefined
109
+ if (error !== undefined && !span.context().getTag('error')) {
110
+ span.setTag('error', error)
111
+ }
112
+ span.finish()
113
+ }
114
+ return { ...store, span }
115
+ }
116
+ }
117
+
118
+ module.exports = ReactRouterPlugin
@@ -0,0 +1,15 @@
1
+ 'use strict'
2
+
3
+ const CompositePlugin = require('../../dd-trace/src/plugins/composite')
4
+ const TrpcProcedurePlugin = require('./procedure')
5
+ const TrpcRequestPlugin = require('./request')
6
+
7
+ class TrpcPlugin extends CompositePlugin {
8
+ static id = 'trpc'
9
+ static plugins = {
10
+ request: TrpcRequestPlugin,
11
+ procedure: TrpcProcedurePlugin,
12
+ }
13
+ }
14
+
15
+ module.exports = TrpcPlugin
@@ -0,0 +1,48 @@
1
+ 'use strict'
2
+
3
+ const { storage } = require('../../datadog-core')
4
+ const TracingPlugin = require('../../dd-trace/src/plugins/tracing')
5
+
6
+ const legacyStorage = storage('legacy')
7
+
8
+ /**
9
+ * @typedef {{
10
+ * arguments: [{ path?: string, type?: string }],
11
+ * currentStore?: { span: import('../../dd-trace/src/opentracing/span') },
12
+ * error?: unknown
13
+ * }} ProcedureContext
14
+ * @typedef {{ currentStore?: { span: import('../../../').Span }, error?: unknown }}
15
+ * ProcedureCompletionContext
16
+ */
17
+
18
+ class TrpcProcedurePlugin extends TracingPlugin {
19
+ static id = 'trpc'
20
+ static prefix = 'tracing:orchestrion:@trpc/server:procedure'
21
+
22
+ /** @param {ProcedureContext} ctx */
23
+ bindStart (ctx) {
24
+ const { path, type } = ctx.arguments[0]
25
+ if (typeof path !== 'string' || (type !== 'query' && type !== 'mutation')) {
26
+ return legacyStorage.getStore()
27
+ }
28
+
29
+ this.startSpan('trpc.procedure', {
30
+ service: this.config.service,
31
+ resource: `${type} ${path}`,
32
+ kind: 'internal',
33
+ }, ctx)
34
+ return ctx.currentStore
35
+ }
36
+
37
+ /** @param {ProcedureCompletionContext} ctx */
38
+ error (ctx) {
39
+ ctx.currentStore?.span.setTag('error', ctx.error)
40
+ }
41
+
42
+ /** @param {ProcedureCompletionContext} ctx */
43
+ asyncEnd (ctx) {
44
+ ctx.currentStore?.span.finish()
45
+ }
46
+ }
47
+
48
+ module.exports = TrpcProcedurePlugin