dd-trace 6.15.0 → 6.17.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 (378) hide show
  1. package/README.md +15 -0
  2. package/ci/diagnose.js +0 -23
  3. package/ci/test-optimization-validation/approval-artifacts.js +0 -3
  4. package/ci/test-optimization-validation/approval.js +0 -6
  5. package/ci/test-optimization-validation/artifact-id.js +0 -1
  6. package/ci/test-optimization-validation/bounded-json.js +0 -1
  7. package/ci/test-optimization-validation/cli.js +0 -12
  8. package/ci/test-optimization-validation/command-output-policy.js +0 -1
  9. package/ci/test-optimization-validation/command-runner.js +0 -3
  10. package/ci/test-optimization-validation/environment.js +0 -4
  11. package/ci/test-optimization-validation/executable-approval.js +0 -1
  12. package/ci/test-optimization-validation/executable.js +0 -5
  13. package/ci/test-optimization-validation/framework-adapters/cucumber.js +4 -8
  14. package/ci/test-optimization-validation/framework-adapters/cypress.js +0 -3
  15. package/ci/test-optimization-validation/framework-adapters/playwright.js +0 -6
  16. package/ci/test-optimization-validation/framework-adapters/vitest.js +0 -4
  17. package/ci/test-optimization-validation/generated-test-contract.js +0 -5
  18. package/ci/test-optimization-validation/generated-verifier.js +0 -1
  19. package/ci/test-optimization-validation/literal-environment.js +0 -1
  20. package/ci/test-optimization-validation/manifest-scaffold.js +0 -17
  21. package/ci/test-optimization-validation/manifest-schema.js +0 -21
  22. package/ci/test-optimization-validation/offline-fixtures.js +0 -4
  23. package/ci/test-optimization-validation/package-check.js +4 -1
  24. package/ci/test-optimization-validation/plan-writer.js +0 -11
  25. package/ci/test-optimization-validation/preflight-runner.js +0 -1
  26. package/ci/test-optimization-validation/redaction.js +0 -4
  27. package/ci/test-optimization-validation/report-writer.js +0 -16
  28. package/ci/test-optimization-validation/runner-command.js +0 -3
  29. package/ci/test-optimization-validation/runner-contract.js +0 -4
  30. package/ci/test-optimization-validation/safe-files.js +0 -1
  31. package/ci/test-optimization-validation/scenarios/basic-reporting.js +0 -1
  32. package/ci/test-optimization-validation/scenarios/ci-wiring.js +1 -2
  33. package/ci/test-optimization-validation/source-text.js +0 -3
  34. package/ci/vitest-no-worker-init-setup.mjs +41 -16
  35. package/index.d.ts +169 -0
  36. package/next.d.ts +27 -0
  37. package/next.js +3 -0
  38. package/package.json +28 -23
  39. package/packages/datadog-esbuild/index.js +14 -1
  40. package/packages/datadog-esbuild/src/resolver.js +284 -0
  41. package/packages/datadog-esbuild/src/utils.js +162 -120
  42. package/packages/datadog-instrumentations/src/aerospike.js +28 -6
  43. package/packages/datadog-instrumentations/src/ai.js +39 -97
  44. package/packages/datadog-instrumentations/src/anthropic.js +76 -134
  45. package/packages/datadog-instrumentations/src/aws-durable-execution-sdk-js.js +1 -3
  46. package/packages/datadog-instrumentations/src/aws-sdk.js +0 -2
  47. package/packages/datadog-instrumentations/src/azure-cosmos.js +1 -1
  48. package/packages/datadog-instrumentations/src/azure-durable-functions.js +23 -9
  49. package/packages/datadog-instrumentations/src/azure-functions.js +48 -0
  50. package/packages/datadog-instrumentations/src/bullmq.js +1 -1
  51. package/packages/datadog-instrumentations/src/claude-agent-sdk.js +1 -3
  52. package/packages/datadog-instrumentations/src/console.js +97 -0
  53. package/packages/datadog-instrumentations/src/cucumber.js +72 -12
  54. package/packages/datadog-instrumentations/src/cypress-config.js +0 -23
  55. package/packages/datadog-instrumentations/src/dd-trace-api.js +2 -2
  56. package/packages/datadog-instrumentations/src/graphql.js +1 -1
  57. package/packages/datadog-instrumentations/src/helpers/bundler-register.js +39 -14
  58. package/packages/datadog-instrumentations/src/helpers/channel.js +0 -2
  59. package/packages/datadog-instrumentations/src/helpers/graphql-jit-runtime.js +0 -5
  60. package/packages/datadog-instrumentations/src/helpers/hooks.js +8 -0
  61. package/packages/datadog-instrumentations/src/helpers/instrument.js +25 -8
  62. package/packages/datadog-instrumentations/src/helpers/instrumentation-utils.js +69 -0
  63. package/packages/datadog-instrumentations/src/helpers/pool-acquire.js +0 -6
  64. package/packages/datadog-instrumentations/src/helpers/register.js +13 -64
  65. package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +109 -29
  66. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +39 -0
  67. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/azure-durable-functions.js +17 -0
  68. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/index.js +3 -16
  69. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/playwright.js +12 -0
  70. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/postgres.js +36 -0
  71. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/supabase.js +128 -0
  72. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/webdriverio.js +6 -7
  73. package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +17 -0
  74. package/packages/datadog-instrumentations/src/helpers/rewriter/transforms/postgres.js +388 -0
  75. package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +99 -75
  76. package/packages/datadog-instrumentations/src/helpers/router-helper.js +0 -1
  77. package/packages/datadog-instrumentations/src/jest.js +141 -51
  78. package/packages/datadog-instrumentations/src/knex.js +0 -1
  79. package/packages/datadog-instrumentations/src/langchain.js +1 -1
  80. package/packages/datadog-instrumentations/src/langgraph.js +1 -1
  81. package/packages/datadog-instrumentations/src/mariadb-bundle.js +0 -24
  82. package/packages/datadog-instrumentations/src/mariadb.js +0 -2
  83. package/packages/datadog-instrumentations/src/mercurius.js +1 -1
  84. package/packages/datadog-instrumentations/src/mocha/common.js +0 -1
  85. package/packages/datadog-instrumentations/src/mocha/main.js +22 -25
  86. package/packages/datadog-instrumentations/src/mocha/utils.js +119 -49
  87. package/packages/datadog-instrumentations/src/mocha/webdriverio-protocol.js +0 -6
  88. package/packages/datadog-instrumentations/src/mocha/worker.js +14 -17
  89. package/packages/datadog-instrumentations/src/modelcontextprotocol-sdk.js +1 -1
  90. package/packages/datadog-instrumentations/src/mysql2.js +0 -2
  91. package/packages/datadog-instrumentations/src/openai-agents.js +1 -1
  92. package/packages/datadog-instrumentations/src/openai-realtime/audio-accumulator.js +241 -0
  93. package/packages/datadog-instrumentations/src/openai-realtime/events.js +76 -0
  94. package/packages/datadog-instrumentations/src/openai-realtime/index.js +301 -0
  95. package/packages/datadog-instrumentations/src/openai-realtime/session.js +998 -0
  96. package/packages/datadog-instrumentations/src/openai-realtime/turns.js +211 -0
  97. package/packages/datadog-instrumentations/src/openai.js +97 -80
  98. package/packages/datadog-instrumentations/src/oracledb.js +9 -3
  99. package/packages/datadog-instrumentations/src/playwright-reporter.js +3 -16
  100. package/packages/datadog-instrumentations/src/playwright.js +238 -55
  101. package/packages/datadog-instrumentations/src/postgres.js +7 -0
  102. package/packages/datadog-instrumentations/src/router.js +0 -2
  103. package/packages/datadog-instrumentations/src/rum-browser-scripts.js +0 -2
  104. package/packages/datadog-instrumentations/src/sequelize.js +0 -1
  105. package/packages/datadog-instrumentations/src/supabase.js +15 -0
  106. package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +18 -18
  107. package/packages/datadog-instrumentations/src/vitest-main.js +37 -17
  108. package/packages/datadog-instrumentations/src/vitest-util.js +7 -1
  109. package/packages/datadog-instrumentations/src/vitest-worker.js +56 -23
  110. package/packages/datadog-instrumentations/src/webdriverio.js +23 -42
  111. package/packages/datadog-instrumentations/src/ws.js +0 -1
  112. package/packages/datadog-plugin-ai/src/utils.js +0 -2
  113. package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/trace-checkpoint.js +0 -1
  114. package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/util.js +0 -2
  115. package/packages/datadog-plugin-aws-sdk/src/base.js +0 -1
  116. package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/utils.js +7 -2
  117. package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +0 -1
  118. package/packages/datadog-plugin-aws-sdk/src/util.js +0 -1
  119. package/packages/datadog-plugin-azure-cosmos/src/index.js +1 -1
  120. package/packages/datadog-plugin-azure-durable-functions/src/index.js +95 -1
  121. package/packages/datadog-plugin-cucumber/src/index.js +10 -0
  122. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +171 -75
  123. package/packages/datadog-plugin-cypress/src/finalization.js +0 -3
  124. package/packages/datadog-plugin-cypress/src/source-map-utils.js +0 -4
  125. package/packages/datadog-plugin-cypress/src/support.js +52 -7
  126. package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +2 -24
  127. package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +2 -36
  128. package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-request-context.js +31 -0
  129. package/packages/datadog-plugin-graphql/src/resolve-error.js +32 -11
  130. package/packages/datadog-plugin-graphql/src/utils.js +0 -5
  131. package/packages/datadog-plugin-jest/src/index.js +13 -0
  132. package/packages/datadog-plugin-kafkajs/src/producer.js +0 -1
  133. package/packages/datadog-plugin-mocha/src/index.js +39 -11
  134. package/packages/datadog-plugin-mongodb-core/src/query.js +0 -1
  135. package/packages/datadog-plugin-openai/src/index.js +16 -1
  136. package/packages/datadog-plugin-openai/src/realtime.js +144 -0
  137. package/packages/datadog-plugin-openai-agents/src/integration.js +0 -4
  138. package/packages/datadog-plugin-openai-agents/src/util.js +0 -1
  139. package/packages/datadog-plugin-playwright/src/index.js +76 -9
  140. package/packages/datadog-plugin-postgres/src/index.js +167 -0
  141. package/packages/datadog-plugin-prisma/src/datadog-tracing-helper.js +0 -1
  142. package/packages/datadog-plugin-redis/src/index.js +15 -1
  143. package/packages/datadog-plugin-supabase/src/error.js +18 -0
  144. package/packages/datadog-plugin-supabase/src/index.js +21 -0
  145. package/packages/datadog-plugin-supabase/src/supabase-auth-js-gotrueclient-getuser.js +69 -0
  146. package/packages/datadog-plugin-supabase/src/supabase-functions-js-functionsclient-invoke.js +70 -0
  147. package/packages/datadog-plugin-supabase/src/supabase-postgrest-js-postgrestbuilder-then.js +122 -0
  148. package/packages/datadog-plugin-supabase/src/supabase-realtime-js-realtimechannel-send.js +66 -0
  149. package/packages/datadog-plugin-supabase/src/supabase-storage-js-handle-request.js +93 -0
  150. package/packages/datadog-plugin-supabase/src/url.js +17 -0
  151. package/packages/datadog-plugin-vitest/src/index.js +10 -0
  152. package/packages/datadog-plugin-ws/src/util.js +0 -4
  153. package/packages/datadog-turbopack/index.js +206 -0
  154. package/packages/datadog-turbopack/src/constants.js +5 -0
  155. package/packages/datadog-turbopack/src/loader.js +484 -0
  156. package/packages/datadog-webpack/src/loader.js +0 -1
  157. package/packages/dd-trace/src/aiguard/client.js +2 -3
  158. package/packages/dd-trace/src/aiguard/evaluation.js +6 -12
  159. package/packages/dd-trace/src/aiguard/index.js +3 -2
  160. package/packages/dd-trace/src/aiguard/integrations/anthropic.js +53 -25
  161. package/packages/dd-trace/src/aiguard/integrations/evaluate.js +49 -25
  162. package/packages/dd-trace/src/aiguard/integrations/index.js +4 -3
  163. package/packages/dd-trace/src/aiguard/integrations/openai.js +132 -29
  164. package/packages/dd-trace/src/aiguard/integrations/vercel-ai.js +116 -42
  165. package/packages/dd-trace/src/aiguard/messages/anthropic.js +0 -2
  166. package/packages/dd-trace/src/aiguard/messages/openai.js +64 -1
  167. package/packages/dd-trace/src/aiguard/messages/utils.js +29 -2
  168. package/packages/dd-trace/src/aiguard/messages/vercel-ai.js +25 -0
  169. package/packages/dd-trace/src/aiguard/redaction.js +0 -1
  170. package/packages/dd-trace/src/aiguard/sdk.js +1 -1
  171. package/packages/dd-trace/src/appsec/activation.js +1 -1
  172. package/packages/dd-trace/src/appsec/api_security/normalized-route.js +0 -5
  173. package/packages/dd-trace/src/appsec/api_security/sampler.js +0 -4
  174. package/packages/dd-trace/src/appsec/blocking/index.js +3 -3
  175. package/packages/dd-trace/src/appsec/downstream_requests.js +1 -4
  176. package/packages/dd-trace/src/appsec/iast/index.js +1 -1
  177. package/packages/dd-trace/src/appsec/iast/overhead-controller.js +5 -5
  178. package/packages/dd-trace/src/appsec/iast/taint-tracking/index.js +1 -1
  179. package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +1 -1
  180. package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +3 -3
  181. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/sql-sensitive-analyzer.js +8 -10
  182. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/url-sensitive-analyzer.js +2 -2
  183. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +2 -2
  184. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/utils.js +4 -1
  185. package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +7 -7
  186. package/packages/dd-trace/src/appsec/index.js +2 -2
  187. package/packages/dd-trace/src/appsec/lambda.js +71 -2
  188. package/packages/dd-trace/src/appsec/rasp/utils.js +5 -1
  189. package/packages/dd-trace/src/appsec/remote_config.js +8 -6
  190. package/packages/dd-trace/src/appsec/reporter.js +10 -6
  191. package/packages/dd-trace/src/appsec/rule_manager.js +3 -3
  192. package/packages/dd-trace/src/appsec/sdk/track_event.js +0 -2
  193. package/packages/dd-trace/src/appsec/telemetry/api_security.js +1 -3
  194. package/packages/dd-trace/src/appsec/telemetry/common.js +4 -0
  195. package/packages/dd-trace/src/appsec/telemetry/index.js +23 -5
  196. package/packages/dd-trace/src/appsec/telemetry/rasp.js +1 -20
  197. package/packages/dd-trace/src/appsec/telemetry/user.js +1 -3
  198. package/packages/dd-trace/src/appsec/telemetry/waf.js +1 -20
  199. package/packages/dd-trace/src/appsec/waf/index.js +2 -2
  200. package/packages/dd-trace/src/appsec/waf/waf_manager.js +8 -5
  201. package/packages/dd-trace/src/carrier.js +0 -5
  202. package/packages/dd-trace/src/ci-visibility/dynamic-atr-retries.js +104 -0
  203. package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +0 -2
  204. package/packages/dd-trace/src/ci-visibility/efd-retry-policy.js +34 -3
  205. package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +0 -1
  206. package/packages/dd-trace/src/ci-visibility/exporters/agentless/di-logs-writer.js +0 -1
  207. package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +0 -1
  208. package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/index.js +0 -4
  209. package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/msgpack-to-json.js +0 -1
  210. package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/sink.js +0 -2
  211. package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +37 -15
  212. package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +0 -3
  213. package/packages/dd-trace/src/ci-visibility/exporters/request.js +0 -11
  214. package/packages/dd-trace/src/ci-visibility/exporters/settings-cache-key.js +0 -1
  215. package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +0 -1
  216. package/packages/dd-trace/src/ci-visibility/requests/fs-cache.js +0 -6
  217. package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +2 -2
  218. package/packages/dd-trace/src/ci-visibility/requests/rate-limit.js +0 -1
  219. package/packages/dd-trace/src/ci-visibility/requests/upload-test-screenshot.js +0 -5
  220. package/packages/dd-trace/src/ci-visibility/requests/video-request.js +0 -1
  221. package/packages/dd-trace/src/ci-visibility/telemetry.js +13 -0
  222. package/packages/dd-trace/src/ci-visibility/test-optimization-cache.js +0 -1
  223. package/packages/dd-trace/src/ci-visibility/test-screenshot.js +0 -2
  224. package/packages/dd-trace/src/ci-visibility/test-video.js +0 -1
  225. package/packages/dd-trace/src/config/defaults.js +3 -2
  226. package/packages/dd-trace/src/config/generated-config-types.d.ts +74 -66
  227. package/packages/dd-trace/src/config/helper.js +9 -2
  228. package/packages/dd-trace/src/config/index.js +44 -29
  229. package/packages/dd-trace/src/config/parsers.js +34 -6
  230. package/packages/dd-trace/src/config/remote_config.js +25 -109
  231. package/packages/dd-trace/src/config/supported-configurations.json +146 -9
  232. package/packages/dd-trace/src/datastreams/encoding.js +0 -1
  233. package/packages/dd-trace/src/datastreams/pathway.js +0 -1
  234. package/packages/dd-trace/src/debugger/constants.js +10 -0
  235. package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +76 -17
  236. package/packages/dd-trace/src/debugger/devtools_client/config.js +2 -0
  237. package/packages/dd-trace/src/debugger/devtools_client/guardrail-metrics.js +15 -0
  238. package/packages/dd-trace/src/debugger/devtools_client/index.js +103 -27
  239. package/packages/dd-trace/src/debugger/devtools_client/json-buffer.js +50 -7
  240. package/packages/dd-trace/src/debugger/devtools_client/log.js +3 -1
  241. package/packages/dd-trace/src/debugger/devtools_client/probe_sampler.js +34 -8
  242. package/packages/dd-trace/src/debugger/devtools_client/send.js +40 -14
  243. package/packages/dd-trace/src/debugger/devtools_client/snapshot/index.js +53 -13
  244. package/packages/dd-trace/src/debugger/devtools_client/snapshot/processor.js +118 -71
  245. package/packages/dd-trace/src/debugger/devtools_client/snapshot-pruner.js +0 -3
  246. package/packages/dd-trace/src/debugger/devtools_client/status.js +20 -6
  247. package/packages/dd-trace/src/debugger/guardrail-metrics.js +167 -0
  248. package/packages/dd-trace/src/debugger/index.js +50 -2
  249. package/packages/dd-trace/src/debugger/inspect-segment.js +0 -3
  250. package/packages/dd-trace/src/debugger/probe_sampler.js +133 -9
  251. package/packages/dd-trace/src/debugger/probe_sampler_constants.js +31 -1
  252. package/packages/dd-trace/src/dogstatsd.js +0 -23
  253. package/packages/dd-trace/src/encode/0.4-cross-payload.js +0 -3
  254. package/packages/dd-trace/src/encode/0.4.js +0 -7
  255. package/packages/dd-trace/src/encode/0.5.js +0 -2
  256. package/packages/dd-trace/src/encode/tags-processors.js +0 -1
  257. package/packages/dd-trace/src/evp_proxy/discovery.js +3 -5
  258. package/packages/dd-trace/src/evp_proxy/path.js +11 -4
  259. package/packages/dd-trace/src/exporters/agent/writer.js +0 -1
  260. package/packages/dd-trace/src/exporters/agentless/index.js +0 -1
  261. package/packages/dd-trace/src/exporters/agentless/intake.js +0 -1
  262. package/packages/dd-trace/src/exporters/agentless/writer.js +0 -3
  263. package/packages/dd-trace/src/exporters/common/docker.js +4 -1
  264. package/packages/dd-trace/src/exporters/common/final-flush-request-tracker.js +0 -6
  265. package/packages/dd-trace/src/exporters/common/proxy.js +3 -0
  266. package/packages/dd-trace/src/exporters/common/request.js +1 -0
  267. package/packages/dd-trace/src/exporters/common/url.js +0 -2
  268. package/packages/dd-trace/src/exporters/common/writer.js +0 -2
  269. package/packages/dd-trace/src/id.js +0 -11
  270. package/packages/dd-trace/src/llmobs/audio-codec.js +192 -0
  271. package/packages/dd-trace/src/llmobs/audio-utils.js +121 -0
  272. package/packages/dd-trace/src/llmobs/constants/audio.js +35 -0
  273. package/packages/dd-trace/src/llmobs/constants/prompts.js +14 -0
  274. package/packages/dd-trace/src/llmobs/constants/tags.js +17 -0
  275. package/packages/dd-trace/src/llmobs/eval-metric.js +0 -6
  276. package/packages/dd-trace/src/llmobs/experiments/dataset.js +0 -4
  277. package/packages/dd-trace/src/llmobs/experiments/experiment.js +0 -3
  278. package/packages/dd-trace/src/llmobs/experiments/index.js +7 -6
  279. package/packages/dd-trace/src/llmobs/experiments/util.js +1 -11
  280. package/packages/dd-trace/src/llmobs/index.js +1 -3
  281. package/packages/dd-trace/src/llmobs/noop.js +10 -0
  282. package/packages/dd-trace/src/llmobs/plugins/ai/util.js +0 -4
  283. package/packages/dd-trace/src/llmobs/plugins/anthropic/util.js +0 -1
  284. package/packages/dd-trace/src/llmobs/plugins/genai/util.js +0 -4
  285. package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/utils.js +0 -2
  286. package/packages/dd-trace/src/llmobs/plugins/openai/constants.js +0 -2
  287. package/packages/dd-trace/src/llmobs/plugins/openai/index.js +4 -6
  288. package/packages/dd-trace/src/llmobs/plugins/openai/realtime.js +285 -0
  289. package/packages/dd-trace/src/llmobs/plugins/openai/utils.js +16 -3
  290. package/packages/dd-trace/src/llmobs/prompts/cache.js +272 -0
  291. package/packages/dd-trace/src/llmobs/prompts/manager.js +639 -0
  292. package/packages/dd-trace/src/llmobs/prompts/noop.js +29 -0
  293. package/packages/dd-trace/src/llmobs/prompts/prompt.js +92 -0
  294. package/packages/dd-trace/src/llmobs/sdk.js +21 -6
  295. package/packages/dd-trace/src/llmobs/span_processor.js +81 -2
  296. package/packages/dd-trace/src/llmobs/tagger.js +30 -7
  297. package/packages/dd-trace/src/llmobs/telemetry.js +36 -4
  298. package/packages/dd-trace/src/llmobs/util.js +0 -34
  299. package/packages/dd-trace/src/llmobs/writers/base.js +0 -1
  300. package/packages/dd-trace/src/llmobs/writers/util.js +1 -2
  301. package/packages/dd-trace/src/log/channels.js +3 -0
  302. package/packages/dd-trace/src/log/index.js +23 -5
  303. package/packages/dd-trace/src/log-submission/log-submission-plugin.js +74 -6
  304. package/packages/dd-trace/src/msgpack/chunk.js +0 -1
  305. package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +0 -12
  306. package/packages/dd-trace/src/openfeature/encoding.js +0 -2
  307. package/packages/dd-trace/src/openfeature/eval-metrics-hook.js +0 -1
  308. package/packages/dd-trace/src/openfeature/index.js +0 -4
  309. package/packages/dd-trace/src/openfeature/span-enrichment-hook.js +0 -1
  310. package/packages/dd-trace/src/openfeature/span-enrichment.js +0 -4
  311. package/packages/dd-trace/src/openfeature/writers/base.js +0 -6
  312. package/packages/dd-trace/src/openfeature/writers/exposures.js +0 -5
  313. package/packages/dd-trace/src/openfeature/writers/util.js +0 -4
  314. package/packages/dd-trace/src/opentelemetry/logs/logger.js +0 -1
  315. package/packages/dd-trace/src/opentelemetry/logs/logger_provider.js +0 -1
  316. package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +0 -1
  317. package/packages/dd-trace/src/opentelemetry/logs/otlp_transformer.js +0 -2
  318. package/packages/dd-trace/src/opentelemetry/metrics/index.js +1 -1
  319. package/packages/dd-trace/src/opentelemetry/metrics/meter_provider.js +4 -4
  320. package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_transformer.js +0 -1
  321. package/packages/dd-trace/src/opentelemetry/metrics/otlp_transformer.js +0 -1
  322. package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +103 -35
  323. package/packages/dd-trace/src/opentelemetry/metrics/time.js +0 -1
  324. package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +36 -13
  325. package/packages/dd-trace/src/opentelemetry/otlp/otlp_transformer_base.js +0 -1
  326. package/packages/dd-trace/src/opentelemetry/span-helpers.js +0 -1
  327. package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +0 -1
  328. package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +0 -3
  329. package/packages/dd-trace/src/opentracing/propagation/text_map.js +0 -6
  330. package/packages/dd-trace/src/opentracing/span_context.js +0 -1
  331. package/packages/dd-trace/src/otel-thread-ctx.js +38 -11
  332. package/packages/dd-trace/src/payload-tagging/tagging.js +15 -3
  333. package/packages/dd-trace/src/plugin_manager.js +9 -3
  334. package/packages/dd-trace/src/plugins/ci_plugin.js +0 -1
  335. package/packages/dd-trace/src/plugins/database.js +2 -6
  336. package/packages/dd-trace/src/plugins/index.js +8 -0
  337. package/packages/dd-trace/src/plugins/plugin.js +0 -4
  338. package/packages/dd-trace/src/plugins/tracing.js +1 -1
  339. package/packages/dd-trace/src/plugins/util/git.js +1 -3
  340. package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +0 -1
  341. package/packages/dd-trace/src/plugins/util/llm.js +0 -2
  342. package/packages/dd-trace/src/plugins/util/status-validator.js +0 -1
  343. package/packages/dd-trace/src/plugins/util/test.js +25 -21
  344. package/packages/dd-trace/src/plugins/util/url.js +0 -5
  345. package/packages/dd-trace/src/priority_sampler.js +0 -6
  346. package/packages/dd-trace/src/process-tags/index.js +0 -1
  347. package/packages/dd-trace/src/profiler.js +132 -35
  348. package/packages/dd-trace/src/profiling/exporters/event_serializer.js +0 -1
  349. package/packages/dd-trace/src/profiling/profiler.js +101 -41
  350. package/packages/dd-trace/src/profiling/ssi-heuristics.js +29 -15
  351. package/packages/dd-trace/src/propagation-hash/index.js +0 -1
  352. package/packages/dd-trace/src/proxy.js +21 -45
  353. package/packages/dd-trace/src/random_sampler.js +0 -4
  354. package/packages/dd-trace/src/rate_limiter.js +0 -4
  355. package/packages/dd-trace/src/remote_config/capabilities.js +1 -9
  356. package/packages/dd-trace/src/remote_config/index.js +0 -1
  357. package/packages/dd-trace/src/runtime_metrics/otlp_runtime_metrics.js +0 -3
  358. package/packages/dd-trace/src/sampler.js +0 -4
  359. package/packages/dd-trace/src/sampling_rule.js +0 -7
  360. package/packages/dd-trace/src/serverless/vercel.js +0 -1
  361. package/packages/dd-trace/src/serverless.js +0 -1
  362. package/packages/dd-trace/src/service-naming/index.js +0 -1
  363. package/packages/dd-trace/src/service-naming/schemas/util.js +0 -1
  364. package/packages/dd-trace/src/service-naming/schemas/v0/storage.js +7 -0
  365. package/packages/dd-trace/src/service-naming/schemas/v1/storage.js +5 -0
  366. package/packages/dd-trace/src/span_processor.js +2 -2
  367. package/packages/dd-trace/src/span_sampler.js +0 -1
  368. package/packages/dd-trace/src/standalone/product.js +2 -2
  369. package/packages/dd-trace/src/standalone/tracesource.js +0 -1
  370. package/packages/dd-trace/src/startup-log.js +1 -1
  371. package/packages/dd-trace/src/telemetry/endpoints.js +0 -8
  372. package/packages/dd-trace/src/telemetry/logs/index.js +16 -5
  373. package/packages/dd-trace/src/telemetry/logs/log-collector.js +16 -6
  374. package/packages/dd-trace/src/telemetry/metrics.js +0 -2
  375. package/packages/dd-trace/src/telemetry/telemetry.js +4 -1
  376. package/packages/dd-trace/src/util.js +13 -1
  377. package/vendor/dist/@datadog/openfeature-node-server/index.js +1 -1
  378. package/packages/dd-trace/src/llmobs/plugins/claude-agent-sdk/utils.js +0 -10
@@ -61,9 +61,12 @@ class Profiler extends EventEmitter {
61
61
  #exporters
62
62
  #flushInterval
63
63
  #lastStart
64
+ #pendingStart
64
65
  #profileSeq = 0
65
66
  #profilers
66
67
  #spanFinishListener
68
+ #startFailed = false
69
+ #stopping
67
70
  #systemInfoReport
68
71
  #currentSnapshotTags
69
72
  #timer
@@ -175,48 +178,72 @@ class Profiler extends EventEmitter {
175
178
  */
176
179
  start (config) {
177
180
  if (this.enabled) return true
178
- this.#enabled = true
179
-
180
- const { tags: snapshotTags, exporters, flushInterval, profilers, uploadCompression, systemInfoReport } =
181
- buildProfilingRuntime(config)
182
- this.#config = config
183
- this.#exporters = exporters
184
- this.#flushInterval = flushInterval
185
- this.#profilers = profilers
186
- this.#currentSnapshotTags = snapshotTags
187
- this.#uploadCompression = uploadCompression
188
- this.#systemInfoReport = systemInfoReport
189
- if (this.#customLabelKeys.size > 0) {
190
- this.#applyCustomLabelKeys()
191
- }
192
-
193
- this._setInterval()
194
- // Log errors if the source map finder fails, but don't prevent the rest
195
- // of the profiler from running without source maps.
196
- let mapper
197
- const { setLogger, SourceMapper } = require('@datadog/pprof')
198
- setLogger(pprofLogger)
199
-
200
- if (config.DD_PROFILING_SOURCE_MAP) {
201
- mapper = new SourceMapper(config.DD_PROFILING_DEBUG_SOURCE_MAPS)
202
- mapper.loadDirectory(process.cwd())
203
- .then(() => {
204
- if (config.DD_PROFILING_DEBUG_SOURCE_MAPS) {
205
- const count = mapper.infoMap.size
206
- // eslint-disable-next-line eslint-rules/eslint-log-printf-style
207
- log.debug(() => {
208
- return count === 0
209
- ? 'Found no source maps'
210
- : `Found source maps for following files: [${[...mapper.infoMap.keys()].join(', ')}]`
211
- })
212
- }
213
- })
214
- .catch((error) => {
215
- log.error(error)
216
- })
181
+ // Initialization failures such as an unavailable native pprof binding are not expected to
182
+ // recover within the lifetime of this process. Preserve that decision without pretending the
183
+ // profiler is running or retrying setup on every subsequent config publication.
184
+ if (this.#startFailed) return false
185
+
186
+ // A prior stop()'s shutdown collection may still be encoding/exporting via #tags,
187
+ // #exporters and #endpointCounts. Wait for it to finish before this start() overwrites
188
+ // that shared state out from under it. Record the desired config rather than chaining
189
+ // straight onto #stopping, so a stop() arriving before it settles can cancel this restart.
190
+ if (this.#stopping) {
191
+ this.#pendingStart = config
192
+ return true
217
193
  }
218
194
 
219
195
  try {
196
+ const { tags: snapshotTags, exporters, flushInterval, profilers, uploadCompression, systemInfoReport } =
197
+ buildProfilingRuntime(config)
198
+ this.#config = config
199
+ this.#exporters = exporters
200
+ this.#flushInterval = flushInterval
201
+ this.#profilers = profilers
202
+ this.#currentSnapshotTags = snapshotTags
203
+ // A restart is installed only after the prior shutdown collection settles, so any endpoint
204
+ // counts left behind by a collection that produced no encodable profiles belong to the old run.
205
+ this.#endpointCounts.clear()
206
+ // Compression is initialized lazily and cached for a profiling run. A restarted profiler
207
+ // must derive it again from the newly built runtime instead of retaining the prior method
208
+ // or options.
209
+ this.#compressionFn = undefined
210
+ this.#compressionFnInitialized = false
211
+ this.#compressionOptions = undefined
212
+ this.#uploadCompression = uploadCompression
213
+ this.#systemInfoReport = systemInfoReport
214
+ if (this.#customLabelKeys.size > 0) {
215
+ this.#applyCustomLabelKeys()
216
+ }
217
+
218
+ this._setInterval()
219
+ // Log errors if the source map finder fails, but don't prevent the rest
220
+ // of the profiler from running without source maps.
221
+ let mapper
222
+ const { setLogger, SourceMapper } = require('@datadog/pprof')
223
+ setLogger(pprofLogger)
224
+
225
+ if (config.DD_PROFILING_SOURCE_MAP) {
226
+ mapper = new SourceMapper(config.DD_PROFILING_DEBUG_SOURCE_MAPS)
227
+ mapper.loadDirectory(process.cwd())
228
+ .then(() => {
229
+ if (config.DD_PROFILING_DEBUG_SOURCE_MAPS) {
230
+ const count = mapper.infoMap.size
231
+ // eslint-disable-next-line eslint-rules/eslint-log-printf-style
232
+ log.debug(() => {
233
+ return count === 0
234
+ ? 'Found no source maps'
235
+ : `Found source maps for following files: [${[...mapper.infoMap.keys()].join(', ')}]`
236
+ })
237
+ }
238
+ })
239
+ .catch((error) => {
240
+ log.error(error)
241
+ })
242
+ }
243
+
244
+ // Setup above does not start any sampler runtime resources. From this point onward, #stop()
245
+ // can safely clean up a partial start because #profilers and the rest of the runtime exist.
246
+ this.#enabled = true
220
247
  const start = new Date()
221
248
  const nearOOMCallback = this.#nearOOMExport.bind(this)
222
249
  for (const profiler of profilers) {
@@ -236,7 +263,17 @@ class Profiler extends EventEmitter {
236
263
  this._capture(this._timeoutInterval, start)
237
264
  } catch (error) {
238
265
  log.error(error)
239
- this.#stop()
266
+ this.#startFailed = true
267
+ if (this.enabled) {
268
+ try {
269
+ this.#stop()
270
+ } catch (stopError) {
271
+ // A cleanup failure must not leave the public running state stuck at true or escape into
272
+ // the customer application.
273
+ this.#enabled = false
274
+ log.error(stopError)
275
+ }
276
+ }
240
277
  return false
241
278
  }
242
279
 
@@ -258,11 +295,34 @@ class Profiler extends EventEmitter {
258
295
  }
259
296
 
260
297
  stop () {
298
+ // A stop() always reflects the latest desired state, so it cancels any restart queued by a
299
+ // start() that arrived while a prior shutdown collection was still in flight.
300
+ this.#pendingStart = undefined
301
+
261
302
  if (!this.enabled) return
262
303
 
263
304
  // collect and export current profiles
264
305
  // once collect returns, profilers can be safely stopped
265
- this._collect(snapshotKinds.ON_SHUTDOWN, false)
306
+ this.#stopping = this._collect(snapshotKinds.ON_SHUTDOWN, false)
307
+ .catch(error => {
308
+ // _collect() contains its own failures, but its cleanup can still throw. Nothing awaits
309
+ // this shutdown chain, so consume and log that failure instead of leaking a rejection.
310
+ log.error(error)
311
+ })
312
+ .finally(() => {
313
+ this.#stopping = undefined
314
+ if (this.#pendingStart) {
315
+ const config = this.#pendingStart
316
+ this.#pendingStart = undefined
317
+ // Unlike the synchronous entry point, nothing awaits this promise, so a throw here would
318
+ // become an unhandled rejection instead of a caught error.
319
+ try {
320
+ this.start(config)
321
+ } catch (error) {
322
+ log.error(error)
323
+ }
324
+ }
325
+ })
266
326
  this.#stop()
267
327
  }
268
328
 
@@ -10,6 +10,11 @@ const DEFAULT_LONG_LIVED_THRESHOLD = 30_000
10
10
  * This class embodies the SSI profiler-triggering heuristics under SSI.
11
11
  */
12
12
  class SSIHeuristics {
13
+ #active = false
14
+ #longLivedTimer
15
+ #onAppClosing = this.disable.bind(this)
16
+ #onSpanCreated = this.#handleSpanCreated.bind(this)
17
+
13
18
  /**
14
19
  * @param {import('../config/config-base')} config - Tracer configuration
15
20
  */
@@ -32,20 +37,36 @@ class SSIHeuristics {
32
37
  }
33
38
 
34
39
  start () {
40
+ if (this.#active) return
41
+ this.#active = true
42
+
35
43
  // Used to determine short-livedness of the process. We could use the process start time as the
36
44
  // reference point, but the tracer initialization point is more relevant, as we couldn't be
37
45
  // collecting profiles earlier anyway. The difference is not particularly significant if the
38
46
  // tracer is initialized early in the process lifetime.
39
- setTimeout(() => {
47
+ this.#longLivedTimer = setTimeout(() => {
48
+ this.#longLivedTimer = undefined
40
49
  this.shortLived = false
41
50
  this._maybeTriggered()
42
- }, this.longLivedThreshold).unref?.()
51
+ }, this.longLivedThreshold)
52
+ this.#longLivedTimer.unref?.()
43
53
 
44
- this._onSpanCreated = this._onSpanCreated.bind(this)
45
- dc.subscribe('dd-trace:span:start', this._onSpanCreated)
54
+ dc.subscribe('dd-trace:span:start', this.#onSpanCreated)
55
+ dc.subscribe('datadog:telemetry:app-closing', this.#onAppClosing)
56
+ }
46
57
 
47
- this._onAppClosing = this._onAppClosing.bind(this)
48
- dc.subscribe('datadog:telemetry:app-closing', this._onAppClosing)
58
+ /**
59
+ * Cancels the pending heuristic and releases all resources owned by this instance.
60
+ */
61
+ disable () {
62
+ this.triggeredCallback = undefined
63
+ if (!this.#active) return
64
+
65
+ this.#active = false
66
+ clearTimeout(this.#longLivedTimer)
67
+ this.#longLivedTimer = undefined
68
+ dc.unsubscribe('dd-trace:span:start', this.#onSpanCreated)
69
+ dc.unsubscribe('datadog:telemetry:app-closing', this.#onAppClosing)
49
70
  }
50
71
 
51
72
  onTriggered (callback) {
@@ -70,17 +91,10 @@ class SSIHeuristics {
70
91
  }
71
92
  }
72
93
 
73
- _onSpanCreated () {
94
+ #handleSpanCreated () {
74
95
  this.noSpan = false
75
96
  this._maybeTriggered()
76
- dc.unsubscribe('dd-trace:span:start', this._onSpanCreated)
77
- }
78
-
79
- _onAppClosing () {
80
- dc.unsubscribe('datadog:telemetry:app-closing', this._onAppClosing)
81
- if (this.noSpan) {
82
- dc.unsubscribe('dd-trace:span:start', this._onSpanCreated)
83
- }
97
+ dc.unsubscribe('dd-trace:span:start', this.#onSpanCreated)
84
98
  }
85
99
  }
86
100
 
@@ -30,7 +30,6 @@ class PropagationHashManager {
30
30
 
31
31
  /**
32
32
  * Check if process tags propagation is enabled
33
- * @returns {boolean}
34
33
  */
35
34
  isEnabled () {
36
35
  return this._config?.DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED === true
@@ -49,6 +49,10 @@ const OPENFEATURE_STATE_NOOP = 0
49
49
  const OPENFEATURE_STATE_LAZY = 1
50
50
  const OPENFEATURE_STATE_ACTIVE = 2
51
51
 
52
+ const configUpdateChannel = channel('datadog:config:update')
53
+
54
+ const profiler = require('./profiler')
55
+
52
56
  let dynamicInstrumentation
53
57
 
54
58
  function getDynamicInstrumentation () {
@@ -114,6 +118,9 @@ function defineLazily (obj, property, getClass, ...args) {
114
118
  class Tracer extends NoopProxy {
115
119
  #openfeatureState = OPENFEATURE_STATE_NOOP
116
120
 
121
+ /** @type {boolean} */
122
+ #configPublished = false
123
+
117
124
  constructor () {
118
125
  super()
119
126
 
@@ -249,20 +256,8 @@ class Tracer extends NoopProxy {
249
256
  openfeatureRemoteConfig.enable(rc, () => this.openfeature, subscribeOpenfeatureToRemoteConfig)
250
257
  }
251
258
 
252
- if (config.profiling.DD_PROFILING_ENABLED === 'true') {
253
- this._profilerStarted = this._startProfiler(config)
254
- } else {
255
- this._profilerStarted = false
256
- if (config.profiling.DD_PROFILING_ENABLED === 'auto') {
257
- const { SSIHeuristics } = require('./profiling/ssi-heuristics')
258
- const ssiHeuristics = new SSIHeuristics(config)
259
- ssiHeuristics.start()
260
- ssiHeuristics.onTriggered(() => {
261
- this._startProfiler(config)
262
- ssiHeuristics.onTriggered() // deregister this callback
263
- })
264
- }
265
- }
259
+ configUpdateChannel.publish(config)
260
+ this.#configPublished = true
266
261
 
267
262
  // Experimental: mirror the active trace ID, span ID and endpoint into
268
263
  // an OTEP-4947 thread-local context record an out-of-process eBPF
@@ -297,7 +292,7 @@ class Tracer extends NoopProxy {
297
292
 
298
293
  this.#updateTracing(config)
299
294
 
300
- if (config.iast.enabled) {
295
+ if (config.iast.DD_IAST_ENABLED) {
301
296
  this._modules.rewriter.enable(config)
302
297
  }
303
298
 
@@ -373,22 +368,6 @@ class Tracer extends NoopProxy {
373
368
  ch.subscribe(onHttpRequest)
374
369
  }
375
370
 
376
- /**
377
- * @param {import('./config/config-base')} config - Tracer configuration
378
- */
379
- _startProfiler (config) {
380
- // do not stop tracer initialization if the profiler fails to be imported
381
- try {
382
- return require('./profiler').start(config)
383
- } catch (error) {
384
- log.error(
385
- 'Error starting profiler. For troubleshooting tips, see <https://dtdg.co/nodejs-profiler-troubleshooting>',
386
- error
387
- )
388
- return false
389
- }
390
- }
391
-
392
371
  /**
393
372
  * `tracer.openfeature` is only reachable through this proxy. SSI itself (auto-injecting
394
373
  * the tracer, resolving the vendored provider regardless of the customer's own
@@ -428,7 +407,7 @@ class Tracer extends NoopProxy {
428
407
  */
429
408
  #updateTracing (config) {
430
409
  if (config.DD_TRACE_ENABLED !== false) {
431
- if (config.appsec.enabled) {
410
+ if (config.appsec.DD_APPSEC_ENABLED) {
432
411
  this._modules.appsec.enable(config)
433
412
  }
434
413
  if (config.llmobs.DD_LLMOBS_ENABLED) {
@@ -441,17 +420,18 @@ class Tracer extends NoopProxy {
441
420
  this._tracer = new DatadogTracer(config, prioritySampler)
442
421
  this.dataStreamsCheckpointer = this._tracer.dataStreamsCheckpointer
443
422
  lazyProxy(this, 'appsec', () => require('./appsec/sdk'), this._tracer, config)
444
- lazyProxy(this, 'llmobs', () => require('./llmobs/sdk'), this._tracer, this._modules.llmobs, config)
423
+ lazyProxy(this, 'llmobs', () => require('./llmobs/sdk'), this._tracer, this._modules.llmobs, config,
424
+ () => this.openfeature)
445
425
 
446
- if (config.experimental?.aiguard?.enabled) {
426
+ if (config.aiguard.DD_AI_GUARD_ENABLED) {
447
427
  lazyProxy(this, 'aiguard', () => require('./aiguard/sdk'), this._tracer, config)
448
428
  }
449
429
  this._tracingInitialized = true
450
430
  }
451
- if (config.experimental?.aiguard?.enabled) {
431
+ if (config.aiguard.DD_AI_GUARD_ENABLED) {
452
432
  this._modules.aiguard.enable(this._tracer, config)
453
433
  }
454
- if (config.iast.enabled) {
434
+ if (config.iast.DD_IAST_ENABLED) {
455
435
  this._modules.iast.enable(config, this._tracer)
456
436
  }
457
437
  // This needs to be after the IAST module is enabled
@@ -507,15 +487,13 @@ class Tracer extends NoopProxy {
507
487
  * @override
508
488
  */
509
489
  get profiling () {
510
- // Lazily require the profiler module and cache the result. If profiling
511
- // is not enabled, runWithLabels still works as a passthrough (just calls fn()).
512
- const profilerModule = require('./profiler')
490
+ // If profiling is not enabled, runWithLabels still works as a passthrough (just calls fn()).
513
491
  const profiling = {
514
492
  setCustomLabelKeys (keys) {
515
- profilerModule.setCustomLabelKeys(keys)
493
+ profiler.setCustomLabelKeys(keys)
516
494
  },
517
495
  runWithLabels (labels, fn) {
518
- return profilerModule.runWithLabels(labels, fn)
496
+ return profiler.runWithLabels(labels, fn)
519
497
  },
520
498
  }
521
499
  Reflect.defineProperty(this, 'profiling', { value: profiling, configurable: true, enumerable: true })
@@ -526,11 +504,11 @@ class Tracer extends NoopProxy {
526
504
  * @override
527
505
  */
528
506
  profilerStarted () {
529
- if (this._profilerStarted === undefined) {
507
+ if (!this.#configPublished) {
530
508
  // injection hardening: this is only ever invoked from tests.
531
509
  throw new Error('profilerStarted() must be called after init()')
532
510
  }
533
- return Promise.resolve(this._profilerStarted)
511
+ return Promise.resolve(profiler.isStarted())
534
512
  }
535
513
 
536
514
  /**
@@ -552,7 +530,6 @@ class Tracer extends NoopProxy {
552
530
  /**
553
531
  * Checks the private filesystem-only Test Optimization validation mode.
554
532
  *
555
- * @returns {boolean} whether network-capable tracer side channels must stay disabled
556
533
  */
557
534
  function isOfflineTestOptimizationValidation () {
558
535
  return isTrue(getEnvironmentVariable(VALIDATION_MODE_ENV)) &&
@@ -564,7 +541,6 @@ function isOfflineTestOptimizationValidation () {
564
541
  * Checks whether initialization selected a filesystem-only Test Optimization exporter.
565
542
  *
566
543
  * @param {import('../../../index').TracerOptions} [options] tracer initialization options
567
- * @returns {boolean} whether the selected exporter is safe for offline validation
568
544
  */
569
545
  function isOfflineValidationExporter (options) {
570
546
  return OFFLINE_VALIDATION_EXPORTERS.has(options?.experimental?.exporter)
@@ -17,9 +17,6 @@ class RandomSampler {
17
17
  this._rate = rate
18
18
  }
19
19
 
20
- /**
21
- * @returns {number}
22
- */
23
20
  rate () {
24
21
  return this._rate
25
22
  }
@@ -30,7 +27,6 @@ class RandomSampler {
30
27
  * Returns `true` if the sampling decision passes (i.e., the operation should be sampled).
31
28
  * This happens if the sampling rate is `1` (i.e., always sample) or if a random value falls below the rate.
32
29
  *
33
- * @returns {boolean} `true` if the operation should be sampled, otherwise `false`.
34
30
  */
35
31
  isSampled () {
36
32
  return this._rate === 1 || Math.random() < this._rate
@@ -21,7 +21,6 @@ class RateLimiter {
21
21
  * Attempts to consume a token and reports whether it was allowed.
22
22
  * Updates internal counters used for effective rate computation.
23
23
  *
24
- * @returns {boolean}
25
24
  */
26
25
  isAllowed () {
27
26
  const curIntervalStart = this._limiter.curIntervalStart
@@ -43,7 +42,6 @@ class RateLimiter {
43
42
  * Returns the fraction of allowed requests over requested ones in the
44
43
  * current and previous intervals combined.
45
44
  *
46
- * @returns {number}
47
45
  */
48
46
  effectiveRate () {
49
47
  if (this._rateLimit < 0) return 1
@@ -58,7 +56,6 @@ class RateLimiter {
58
56
 
59
57
  /**
60
58
  * Internal token consumption without counter side-effects.
61
- * @returns {boolean}
62
59
  */
63
60
  _isAllowed () {
64
61
  if (this._rateLimit < 0) return true
@@ -69,7 +66,6 @@ class RateLimiter {
69
66
 
70
67
  /**
71
68
  * Effective rate within the current interval only.
72
- * @returns {number}
73
69
  */
74
70
  _currentWindowRate () {
75
71
  if (this._rateLimit < 0) return 1
@@ -12,33 +12,25 @@ module.exports = {
12
12
  ASM_CUSTOM_BLOCKING_RESPONSE: 1n << 9n,
13
13
  ASM_TRUSTED_IPS: 1n << 10n,
14
14
  ASM_API_SECURITY_SAMPLE_RATE: 1n << 11n, // deprecated
15
- APM_TRACING_SAMPLE_RATE: 1n << 12n,
16
- APM_TRACING_LOGS_INJECTION: 1n << 13n,
17
- APM_TRACING_HTTP_HEADER_TAGS: 1n << 14n,
18
- APM_TRACING_CUSTOM_TAGS: 1n << 15n,
19
15
  ASM_PROCESSOR_OVERRIDES: 1n << 16n,
20
16
  ASM_CUSTOM_DATA_SCANNERS: 1n << 17n,
21
17
  ASM_EXCLUSION_DATA: 1n << 18n,
22
- APM_TRACING_ENABLED: 1n << 19n,
23
18
  ASM_RASP_SQLI: 1n << 21n,
24
19
  ASM_RASP_LFI: 1n << 22n,
25
20
  ASM_RASP_SSRF: 1n << 23n,
26
21
  ASM_RASP_SHI: 1n << 24n,
27
- APM_TRACING_SAMPLE_RULES: 1n << 29n,
28
22
  ASM_AUTO_USER_INSTRUM_MODE: 1n << 31n,
29
23
  ASM_ENDPOINT_FINGERPRINT: 1n << 32n,
30
24
  ASM_SESSION_FINGERPRINT: 1n << 33n,
31
25
  ASM_NETWORK_FINGERPRINT: 1n << 34n,
32
26
  ASM_HEADER_FINGERPRINT: 1n << 35n,
33
27
  ASM_RASP_CMDI: 1n << 37n,
34
- APM_TRACING_ENABLE_DYNAMIC_INSTRUMENTATION: 1n << 38n,
35
- APM_TRACING_ENABLE_CODE_ORIGIN: 1n << 40n,
36
- APM_TRACING_ENABLE_LIVE_DEBUGGING: 1n << 41n,
37
28
  ASM_DD_MULTICONFIG: 1n << 42n,
38
29
  ASM_TRACE_TAGGING_RULES: 1n << 43n,
39
30
  ASM_EXTENDED_DATA_COLLECTION: 1n << 44n,
40
31
  APM_TRACING_MULTICONFIG: 1n << 45n,
41
32
  FFE_FLAG_CONFIGURATION_RULES: 1n << 46n,
33
+ SDK_CONFIGURATION: 1n << 49n,
42
34
  /*
43
35
  DO NOT ADD ARBITRARY CAPABILITIES IN YOUR CODE
44
36
  UNLESS THEY ARE ALREADY DEFINED IN THE BACKEND SOURCE OF TRUTH
@@ -234,7 +234,6 @@ class RemoteConfig {
234
234
  /**
235
235
  * Updates the native client with the current products and capabilities.
236
236
  *
237
- * @returns {void}
238
237
  */
239
238
  #updateProductCapabilities () {
240
239
  const fetcher = this.#fetcher
@@ -195,9 +195,6 @@ module.exports = {
195
195
  log.debug('Started OTLP runtime metrics with OTel-native naming (v8js.*, nodejs.*)')
196
196
  },
197
197
 
198
- /**
199
- * @returns {void}
200
- */
201
198
  stop () {
202
199
  if (eventLoopHistogram) {
203
200
  eventLoopHistogram.disable()
@@ -28,9 +28,6 @@ class Sampler {
28
28
  this.#threshold = BigInt(Math.floor(rate * MAX_TRACE_ID))
29
29
  }
30
30
 
31
- /**
32
- * @returns {number}
33
- */
34
31
  rate () {
35
32
  return this._rate
36
33
  }
@@ -43,7 +40,6 @@ class Sampler {
43
40
  * Determines whether a trace/span should be sampled based on the configured sampling rate.
44
41
  *
45
42
  * @param {import("../../..").Span|import("../../..").SpanContext} span - The span or span context to evaluate.
46
- * @returns {boolean} `true` if the trace/span should be sampled, otherwise `false`.
47
43
  */
48
44
  isSampled (span) {
49
45
  if (this._rate === 1) {
@@ -27,7 +27,6 @@ const Sampler = require('./sampler')
27
27
  class AlwaysMatcher {
28
28
  /**
29
29
  * @param {DatadogSpan} span
30
- * @returns {boolean}
31
30
  */
32
31
  match (span) {
33
32
  return true
@@ -42,7 +41,6 @@ class AlwaysMatcher {
42
41
  class NeverMatcher {
43
42
  /**
44
43
  * @param {DatadogSpan} span
45
- * @returns {boolean}
46
44
  */
47
45
  match (span) {
48
46
  return false
@@ -64,7 +62,6 @@ class GlobMatcher {
64
62
 
65
63
  /**
66
64
  * @param {DatadogSpan} span
67
- * @returns {boolean}
68
65
  */
69
66
  match (span) {
70
67
  const subject = this.locator(span)
@@ -91,7 +88,6 @@ class RegExpMatcher {
91
88
 
92
89
  /**
93
90
  * @param {DatadogSpan} span
94
- * @returns {boolean}
95
91
  */
96
92
  match (span) {
97
93
  const subject = this.locator(span)
@@ -235,7 +231,6 @@ class SamplingRule {
235
231
 
236
232
  /**
237
233
  * Deterministic sampling rate in [0, 1].
238
- * @returns {number}
239
234
  */
240
235
  get sampleRate () {
241
236
  return this._sampler.rate()
@@ -261,7 +256,6 @@ class SamplingRule {
261
256
  * Checks whether the provided span matches all configured criteria.
262
257
  *
263
258
  * @param {DatadogSpan} span
264
- * @returns {boolean}
265
259
  */
266
260
  match (span) {
267
261
  for (const matcher of this.matchers) {
@@ -280,7 +274,6 @@ class SamplingRule {
280
274
  * Determines whether a span should be sampled based on the configured sampling rule.
281
275
  *
282
276
  * @param {DatadogSpan|DatadogSpanContext} span - The span or span context to evaluate.
283
- * @returns {boolean} `true` if the span should be sampled, otherwise `false`.
284
277
  */
285
278
  sample (span) {
286
279
  if (!this._sampler.isSampled(span)) {
@@ -32,7 +32,6 @@ function createVercelFlush () {
32
32
  /**
33
33
  * @param {TelemetryFlusher} tracer
34
34
  * @param {() => void} done
35
- * @returns {void}
36
35
  */
37
36
  function flushVercelTelemetry (tracer, done) {
38
37
  setImmediate(() => {
@@ -69,7 +69,6 @@ function getServerlessPlatform () {
69
69
  * Whether the current platform can retain an invocation for telemetry delivery.
70
70
  *
71
71
  * Add future serverless platforms here as they gain an equivalent retention hook.
72
- * @returns {boolean}
73
72
  */
74
73
  function supportsServerlessTelemetryRetention () {
75
74
  return isVercelAtStartup
@@ -30,7 +30,6 @@ class SchemaManager {
30
30
  * @param {string} kind
31
31
  * @param {string} plugin
32
32
  * @param {object} opts
33
- * @returns {string}
34
33
  */
35
34
  opName (type, kind, plugin, opts) {
36
35
  return this.schema.getOpName(type, kind, plugin, opts)
@@ -37,7 +37,6 @@ function optionServiceSource ({ pluginConfig }) {
37
37
  * @param {{ service?: string | ((params?: object) => unknown) }} [pluginConfig]
38
38
  * @param {object} [params]
39
39
  * @param {string} defaultService
40
- * @returns {string}
41
40
  */
42
41
  function configServiceName (pluginConfig, params, defaultService) {
43
42
  const service = pluginConfig?.service
@@ -156,6 +156,13 @@ const storage = {
156
156
  return optionServiceSource({ tracerService, pluginConfig, connectionName, integration: 'pg' })
157
157
  },
158
158
  },
159
+ postgres: {
160
+ opName: () => 'postgres.query',
161
+ serviceName: withSuffixFunction('postgres'),
162
+ serviceSource: ({ tracerService, pluginConfig, connectionName }) => {
163
+ return optionServiceSource({ tracerService, pluginConfig, connectionName, integration: 'postgres' })
164
+ },
165
+ },
159
166
  prisma: {
160
167
  opName: ({ operation }) => `prisma.${operation}`,
161
168
  serviceName: withSuffixFunction('prisma'),
@@ -86,6 +86,11 @@ const storage = {
86
86
  serviceName: withFunction,
87
87
  serviceSource: optionServiceSource,
88
88
  },
89
+ postgres: {
90
+ opName: () => 'postgresql.query',
91
+ serviceName: configWithFallback,
92
+ serviceSource: optionServiceSource,
93
+ },
89
94
  prisma: {
90
95
  opName: ({ operation }) => `prisma.${operation}`,
91
96
  serviceName: configWithFallback,
@@ -19,7 +19,8 @@ class SpanProcessor {
19
19
  this._config = config
20
20
  this._killAll = false
21
21
 
22
- if (config.stats?.DD_TRACE_STATS_COMPUTATION_ENABLED && !config.appsec?.standalone?.enabled) {
22
+ if (config.stats?.DD_TRACE_STATS_COMPUTATION_ENABLED &&
23
+ !config.appsec?.DD_EXPERIMENTAL_APPSEC_STANDALONE_ENABLED) {
23
24
  const { SpanStatsProcessor } = require('./span_stats')
24
25
  this._stats = new SpanStatsProcessor(config, otlpStatsExporter)
25
26
  }
@@ -45,7 +46,6 @@ class SpanProcessor {
45
46
  * `PrioritySampler.keepTrace()`), so `discard` only applies while the priority is still a reject.
46
47
  *
47
48
  * @param {import('./opentracing/span_context')} spanContext
48
- * @returns {boolean}
49
49
  */
50
50
  #isDiscarded (spanContext) {
51
51
  return spanContext._sampling.discard && spanContext._sampling.priority <= AUTO_REJECT