dd-trace 5.81.0 → 5.83.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 (371) hide show
  1. package/LICENSE-3rdparty.csv +78 -79
  2. package/ci/init.js +6 -6
  3. package/index.d.ts +159 -3
  4. package/loader-hook.mjs +8 -3
  5. package/package.json +64 -66
  6. package/packages/datadog-core/src/storage.js +7 -7
  7. package/packages/datadog-core/src/utils/src/parse-tags.js +1 -1
  8. package/packages/datadog-esbuild/index.js +14 -7
  9. package/packages/datadog-esbuild/src/utils.js +14 -2
  10. package/packages/datadog-instrumentations/src/aerospike.js +3 -2
  11. package/packages/datadog-instrumentations/src/ai.js +9 -5
  12. package/packages/datadog-instrumentations/src/amqp10.js +1 -1
  13. package/packages/datadog-instrumentations/src/amqplib.js +4 -4
  14. package/packages/datadog-instrumentations/src/anthropic.js +2 -2
  15. package/packages/datadog-instrumentations/src/apollo-server-core.js +2 -2
  16. package/packages/datadog-instrumentations/src/apollo-server.js +1 -1
  17. package/packages/datadog-instrumentations/src/apollo.js +3 -2
  18. package/packages/datadog-instrumentations/src/avsc.js +1 -1
  19. package/packages/datadog-instrumentations/src/aws-sdk.js +1 -1
  20. package/packages/datadog-instrumentations/src/azure-event-hubs.js +4 -3
  21. package/packages/datadog-instrumentations/src/azure-functions.js +2 -2
  22. package/packages/datadog-instrumentations/src/azure-service-bus.js +3 -4
  23. package/packages/datadog-instrumentations/src/bluebird.js +1 -1
  24. package/packages/datadog-instrumentations/src/bullmq.js +11 -0
  25. package/packages/datadog-instrumentations/src/bunyan.js +1 -1
  26. package/packages/datadog-instrumentations/src/cassandra-driver.js +1 -1
  27. package/packages/datadog-instrumentations/src/child_process.js +3 -3
  28. package/packages/datadog-instrumentations/src/confluentinc-kafka-javascript.js +3 -3
  29. package/packages/datadog-instrumentations/src/couchbase.js +1 -1
  30. package/packages/datadog-instrumentations/src/crypto.js +1 -1
  31. package/packages/datadog-instrumentations/src/cucumber.js +13 -14
  32. package/packages/datadog-instrumentations/src/cypress.js +1 -1
  33. package/packages/datadog-instrumentations/src/dns.js +1 -1
  34. package/packages/datadog-instrumentations/src/elasticsearch.js +1 -1
  35. package/packages/datadog-instrumentations/src/express-mongo-sanitize.js +1 -1
  36. package/packages/datadog-instrumentations/src/express.js +1 -1
  37. package/packages/datadog-instrumentations/src/fs.js +1 -1
  38. package/packages/datadog-instrumentations/src/generic-pool.js +1 -1
  39. package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +137 -15
  40. package/packages/datadog-instrumentations/src/google-cloud-vertexai.js +2 -3
  41. package/packages/datadog-instrumentations/src/google-genai.js +3 -3
  42. package/packages/datadog-instrumentations/src/graphql.js +2 -2
  43. package/packages/datadog-instrumentations/src/grpc/client.js +1 -1
  44. package/packages/datadog-instrumentations/src/grpc/server.js +1 -1
  45. package/packages/datadog-instrumentations/src/helpers/bundler-register.js +1 -1
  46. package/packages/datadog-instrumentations/src/helpers/hook.js +1 -1
  47. package/packages/datadog-instrumentations/src/helpers/hooks.js +4 -1
  48. package/packages/datadog-instrumentations/src/helpers/instrument.js +1 -1
  49. package/packages/datadog-instrumentations/src/helpers/instrumentations.js +4 -3
  50. package/packages/datadog-instrumentations/src/helpers/register.js +9 -11
  51. package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +2 -2
  52. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/bullmq.json +106 -0
  53. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/index.js +2 -1
  54. package/packages/datadog-instrumentations/src/helpers/router-helper.js +1 -1
  55. package/packages/datadog-instrumentations/src/helpers/shared-utils.js +9 -0
  56. package/packages/datadog-instrumentations/src/hono.js +55 -10
  57. package/packages/datadog-instrumentations/src/http/client.js +2 -2
  58. package/packages/datadog-instrumentations/src/ioredis.js +1 -1
  59. package/packages/datadog-instrumentations/src/iovalkey.js +1 -1
  60. package/packages/datadog-instrumentations/src/jest.js +37 -16
  61. package/packages/datadog-instrumentations/src/kafkajs.js +3 -3
  62. package/packages/datadog-instrumentations/src/knex.js +1 -1
  63. package/packages/datadog-instrumentations/src/koa.js +2 -1
  64. package/packages/datadog-instrumentations/src/ldapjs.js +1 -1
  65. package/packages/datadog-instrumentations/src/light-my-request.js +93 -0
  66. package/packages/datadog-instrumentations/src/limitd-client.js +1 -1
  67. package/packages/datadog-instrumentations/src/lodash.js +1 -2
  68. package/packages/datadog-instrumentations/src/mariadb.js +1 -2
  69. package/packages/datadog-instrumentations/src/memcached.js +1 -1
  70. package/packages/datadog-instrumentations/src/mocha/main.js +2 -2
  71. package/packages/datadog-instrumentations/src/mocha/worker.js +1 -1
  72. package/packages/datadog-instrumentations/src/mocha.js +1 -1
  73. package/packages/datadog-instrumentations/src/mongodb-core.js +1 -1
  74. package/packages/datadog-instrumentations/src/mongodb.js +1 -1
  75. package/packages/datadog-instrumentations/src/mongoose.js +1 -1
  76. package/packages/datadog-instrumentations/src/mquery.js +1 -1
  77. package/packages/datadog-instrumentations/src/mysql.js +2 -2
  78. package/packages/datadog-instrumentations/src/mysql2.js +3 -3
  79. package/packages/datadog-instrumentations/src/net.js +14 -6
  80. package/packages/datadog-instrumentations/src/next.js +1 -1
  81. package/packages/datadog-instrumentations/src/nyc.js +2 -2
  82. package/packages/datadog-instrumentations/src/openai.js +2 -2
  83. package/packages/datadog-instrumentations/src/opensearch.js +1 -1
  84. package/packages/datadog-instrumentations/src/oracledb.js +1 -1
  85. package/packages/datadog-instrumentations/src/otel-sdk-trace.js +5 -5
  86. package/packages/datadog-instrumentations/src/pg.js +7 -5
  87. package/packages/datadog-instrumentations/src/pino.js +1 -1
  88. package/packages/datadog-instrumentations/src/playwright.js +4 -4
  89. package/packages/datadog-instrumentations/src/prisma.js +52 -37
  90. package/packages/datadog-instrumentations/src/process.js +1 -1
  91. package/packages/datadog-instrumentations/src/promise-js.js +1 -1
  92. package/packages/datadog-instrumentations/src/promise.js +1 -1
  93. package/packages/datadog-instrumentations/src/protobufjs.js +1 -1
  94. package/packages/datadog-instrumentations/src/q.js +1 -1
  95. package/packages/datadog-instrumentations/src/redis.js +1 -1
  96. package/packages/datadog-instrumentations/src/rhea.js +1 -1
  97. package/packages/datadog-instrumentations/src/selenium.js +3 -3
  98. package/packages/datadog-instrumentations/src/sequelize.js +1 -2
  99. package/packages/datadog-instrumentations/src/sharedb.js +1 -1
  100. package/packages/datadog-instrumentations/src/tedious.js +1 -1
  101. package/packages/datadog-instrumentations/src/undici.js +15 -4
  102. package/packages/datadog-instrumentations/src/url.js +1 -1
  103. package/packages/datadog-instrumentations/src/vitest.js +1 -1
  104. package/packages/datadog-instrumentations/src/vm.js +1 -1
  105. package/packages/datadog-instrumentations/src/when.js +1 -1
  106. package/packages/datadog-instrumentations/src/winston.js +1 -1
  107. package/packages/datadog-instrumentations/src/ws.js +3 -2
  108. package/packages/datadog-plugin-amqp10/src/index.js +1 -1
  109. package/packages/datadog-plugin-amqplib/src/index.js +1 -1
  110. package/packages/datadog-plugin-anthropic/src/index.js +1 -1
  111. package/packages/datadog-plugin-aws-sdk/src/base.js +4 -4
  112. package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/index.js +1 -1
  113. package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +4 -4
  114. package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +2 -2
  115. package/packages/datadog-plugin-aws-sdk/src/util.js +3 -3
  116. package/packages/datadog-plugin-azure-event-hubs/src/index.js +1 -1
  117. package/packages/datadog-plugin-azure-event-hubs/src/producer.js +21 -7
  118. package/packages/datadog-plugin-azure-service-bus/src/index.js +1 -1
  119. package/packages/datadog-plugin-azure-service-bus/src/producer.js +6 -2
  120. package/packages/datadog-plugin-bullmq/src/consumer.js +60 -0
  121. package/packages/datadog-plugin-bullmq/src/index.js +18 -0
  122. package/packages/datadog-plugin-bullmq/src/producer.js +178 -0
  123. package/packages/datadog-plugin-confluentinc-kafka-javascript/src/index.js +1 -1
  124. package/packages/datadog-plugin-cucumber/src/index.js +2 -2
  125. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +2 -2
  126. package/packages/datadog-plugin-cypress/src/plugin.js +1 -1
  127. package/packages/datadog-plugin-dd-trace-api/src/index.js +2 -2
  128. package/packages/datadog-plugin-express/src/code_origin.js +21 -15
  129. package/packages/datadog-plugin-express/src/index.js +1 -1
  130. package/packages/datadog-plugin-fastify/src/code_origin.js +17 -4
  131. package/packages/datadog-plugin-fastify/src/index.js +1 -1
  132. package/packages/datadog-plugin-google-cloud-pubsub/src/client.js +13 -3
  133. package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +171 -12
  134. package/packages/datadog-plugin-google-cloud-pubsub/src/index.js +1 -2
  135. package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +160 -13
  136. package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +217 -0
  137. package/packages/datadog-plugin-google-cloud-vertexai/src/index.js +1 -1
  138. package/packages/datadog-plugin-google-genai/src/index.js +1 -1
  139. package/packages/datadog-plugin-graphql/src/resolve.js +1 -1
  140. package/packages/datadog-plugin-grpc/src/index.js +1 -1
  141. package/packages/datadog-plugin-http/src/client.js +2 -1
  142. package/packages/datadog-plugin-http/src/index.js +25 -5
  143. package/packages/datadog-plugin-http2/src/client.js +2 -2
  144. package/packages/datadog-plugin-http2/src/index.js +1 -1
  145. package/packages/datadog-plugin-jest/src/index.js +2 -2
  146. package/packages/datadog-plugin-kafkajs/src/index.js +1 -1
  147. package/packages/datadog-plugin-langchain/src/index.js +1 -1
  148. package/packages/datadog-plugin-mocha/src/index.js +2 -2
  149. package/packages/datadog-plugin-moleculer/src/index.js +1 -1
  150. package/packages/datadog-plugin-mongodb-core/src/index.js +8 -4
  151. package/packages/datadog-plugin-openai/src/index.js +1 -1
  152. package/packages/datadog-plugin-openai/src/stream-helpers.js +30 -10
  153. package/packages/datadog-plugin-openai/src/tracing.js +2 -2
  154. package/packages/datadog-plugin-playwright/src/index.js +3 -3
  155. package/packages/datadog-plugin-rhea/src/index.js +1 -1
  156. package/packages/datadog-plugin-undici/src/index.js +305 -2
  157. package/packages/datadog-plugin-vitest/src/index.js +5 -5
  158. package/packages/datadog-plugin-ws/src/close.js +56 -3
  159. package/packages/datadog-plugin-ws/src/index.js +4 -0
  160. package/packages/datadog-plugin-ws/src/producer.js +39 -4
  161. package/packages/datadog-plugin-ws/src/receiver.js +39 -3
  162. package/packages/datadog-plugin-ws/src/server.js +13 -1
  163. package/packages/datadog-plugin-ws/src/util.js +107 -0
  164. package/packages/datadog-shimmer/src/shimmer.js +2 -2
  165. package/packages/dd-trace/index.js +19 -0
  166. package/packages/dd-trace/src/aiguard/sdk.js +3 -3
  167. package/packages/dd-trace/src/appsec/graphql.js +2 -2
  168. package/packages/dd-trace/src/appsec/iast/analyzers/code-injection-analyzer.js +1 -1
  169. package/packages/dd-trace/src/appsec/iast/analyzers/command-injection-analyzer.js +1 -1
  170. package/packages/dd-trace/src/appsec/iast/analyzers/cookie-analyzer.js +1 -1
  171. package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-base-analyzer.js +1 -1
  172. package/packages/dd-trace/src/appsec/iast/analyzers/injection-analyzer.js +1 -1
  173. package/packages/dd-trace/src/appsec/iast/analyzers/ldap-injection-analyzer.js +1 -1
  174. package/packages/dd-trace/src/appsec/iast/analyzers/nosql-injection-mongodb-analyzer.js +3 -3
  175. package/packages/dd-trace/src/appsec/iast/analyzers/path-traversal-analyzer.js +1 -1
  176. package/packages/dd-trace/src/appsec/iast/analyzers/ssrf-analyzer.js +1 -1
  177. package/packages/dd-trace/src/appsec/iast/analyzers/untrusted-deserialization-analyzer.js +1 -1
  178. package/packages/dd-trace/src/appsec/iast/analyzers/unvalidated-redirect-analyzer.js +1 -1
  179. package/packages/dd-trace/src/appsec/iast/analyzers/weak-cipher-analyzer.js +1 -1
  180. package/packages/dd-trace/src/appsec/iast/analyzers/weak-hash-analyzer.js +3 -2
  181. package/packages/dd-trace/src/appsec/iast/analyzers/weak-randomness-analyzer.js +1 -1
  182. package/packages/dd-trace/src/appsec/iast/iast-plugin.js +3 -3
  183. package/packages/dd-trace/src/appsec/iast/index.js +5 -5
  184. package/packages/dd-trace/src/appsec/iast/security-controls/index.js +1 -1
  185. package/packages/dd-trace/src/appsec/iast/taint-tracking/index.js +1 -2
  186. package/packages/dd-trace/src/appsec/iast/taint-tracking/operations-taint-object.js +1 -1
  187. package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +1 -1
  188. package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +11 -15
  189. package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +1 -1
  190. package/packages/dd-trace/src/appsec/iast/telemetry/namespaces.js +1 -1
  191. package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +3 -3
  192. package/packages/dd-trace/src/appsec/index.js +8 -8
  193. package/packages/dd-trace/src/appsec/rasp/command_injection.js +1 -1
  194. package/packages/dd-trace/src/appsec/rasp/index.js +3 -5
  195. package/packages/dd-trace/src/appsec/rasp/lfi.js +1 -1
  196. package/packages/dd-trace/src/appsec/rc-products.js +10 -0
  197. package/packages/dd-trace/src/appsec/recommended.json +230 -3
  198. package/packages/dd-trace/src/appsec/remote_config.js +177 -0
  199. package/packages/dd-trace/src/appsec/reporter.js +3 -3
  200. package/packages/dd-trace/src/appsec/rule_manager.js +37 -20
  201. package/packages/dd-trace/src/appsec/sdk/index.js +1 -1
  202. package/packages/dd-trace/src/appsec/sdk/set_user.js +1 -1
  203. package/packages/dd-trace/src/appsec/sdk/track_event.js +2 -2
  204. package/packages/dd-trace/src/appsec/sdk/user_blocking.js +2 -2
  205. package/packages/dd-trace/src/appsec/user_tracking.js +2 -2
  206. package/packages/dd-trace/src/appsec/waf/index.js +17 -3
  207. package/packages/dd-trace/src/appsec/waf/waf_manager.js +11 -0
  208. package/packages/dd-trace/src/azure_metadata.js +15 -4
  209. package/packages/dd-trace/src/baggage.js +36 -11
  210. package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +5 -1
  211. package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +6 -0
  212. package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +2 -2
  213. package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +2 -2
  214. package/packages/dd-trace/src/ci-visibility/exporters/agentless/di-logs-writer.js +2 -2
  215. package/packages/dd-trace/src/ci-visibility/exporters/agentless/index.js +2 -2
  216. package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +2 -2
  217. package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +4 -3
  218. package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +3 -3
  219. package/packages/dd-trace/src/ci-visibility/exporters/test-worker/index.js +5 -5
  220. package/packages/dd-trace/src/ci-visibility/exporters/test-worker/writer.js +1 -1
  221. package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +2 -2
  222. package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +4 -4
  223. package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +4 -4
  224. package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +2 -2
  225. package/packages/dd-trace/src/{config_defaults.js → config/defaults.js} +5 -4
  226. package/packages/dd-trace/src/{config-helper.js → config/helper.js} +88 -15
  227. package/packages/dd-trace/src/{config.js → config/index.js} +115 -67
  228. package/packages/dd-trace/src/config/remote_config.js +202 -0
  229. package/packages/dd-trace/src/{config_stable.js → config/stable.js} +20 -32
  230. package/packages/dd-trace/src/{supported-configurations.json → config/supported-configurations.json} +5 -0
  231. package/packages/dd-trace/src/constants.js +5 -0
  232. package/packages/dd-trace/src/crashtracking/crashtracker.js +11 -2
  233. package/packages/dd-trace/src/datastreams/checkpointer.js +2 -2
  234. package/packages/dd-trace/src/datastreams/index.js +1 -1
  235. package/packages/dd-trace/src/datastreams/pathway.js +7 -7
  236. package/packages/dd-trace/src/datastreams/processor.js +3 -3
  237. package/packages/dd-trace/src/datastreams/writer.js +3 -3
  238. package/packages/dd-trace/src/debugger/config.js +1 -0
  239. package/packages/dd-trace/src/debugger/devtools_client/condition.js +1 -1
  240. package/packages/dd-trace/src/debugger/devtools_client/config.js +1 -1
  241. package/packages/dd-trace/src/debugger/devtools_client/index.js +7 -2
  242. package/packages/dd-trace/src/debugger/devtools_client/send.js +6 -6
  243. package/packages/dd-trace/src/debugger/devtools_client/session.js +1 -1
  244. package/packages/dd-trace/src/debugger/devtools_client/snapshot/collector.js +5 -5
  245. package/packages/dd-trace/src/debugger/devtools_client/snapshot/constants.js +1 -1
  246. package/packages/dd-trace/src/debugger/devtools_client/snapshot/index.js +2 -2
  247. package/packages/dd-trace/src/debugger/devtools_client/state.js +1 -1
  248. package/packages/dd-trace/src/debugger/devtools_client/status.js +2 -2
  249. package/packages/dd-trace/src/debugger/index.js +84 -16
  250. package/packages/dd-trace/src/dogstatsd.js +5 -4
  251. package/packages/dd-trace/src/encode/0.4.js +3 -3
  252. package/packages/dd-trace/src/encode/agentless-ci-visibility.js +2 -2
  253. package/packages/dd-trace/src/encode/coverage-ci-visibility.js +1 -1
  254. package/packages/dd-trace/src/encode/span-stats.js +6 -1
  255. package/packages/dd-trace/src/exporter.js +2 -2
  256. package/packages/dd-trace/src/exporters/agent/index.js +2 -4
  257. package/packages/dd-trace/src/exporters/agent/writer.js +9 -14
  258. package/packages/dd-trace/src/exporters/common/agent-info-exporter.js +2 -2
  259. package/packages/dd-trace/src/exporters/common/docker.js +2 -2
  260. package/packages/dd-trace/src/exporters/common/request.js +3 -3
  261. package/packages/dd-trace/src/exporters/common/util.js +2 -2
  262. package/packages/dd-trace/src/exporters/common/writer.js +1 -1
  263. package/packages/dd-trace/src/exporters/span-stats/index.js +1 -1
  264. package/packages/dd-trace/src/external-logger/src/index.js +1 -2
  265. package/packages/dd-trace/src/flare/index.js +2 -2
  266. package/packages/dd-trace/src/guardrails/index.js +6 -3
  267. package/packages/dd-trace/src/guardrails/telemetry.js +1 -1
  268. package/packages/dd-trace/src/id.js +1 -1
  269. package/packages/dd-trace/src/index.js +4 -4
  270. package/packages/dd-trace/src/lambda/handler.js +5 -5
  271. package/packages/dd-trace/src/lambda/index.js +2 -2
  272. package/packages/dd-trace/src/lambda/runtime/patch.js +6 -6
  273. package/packages/dd-trace/src/lambda/runtime/ritm.js +3 -3
  274. package/packages/dd-trace/src/llmobs/constants/tags.js +14 -1
  275. package/packages/dd-trace/src/llmobs/index.js +10 -11
  276. package/packages/dd-trace/src/llmobs/noop.js +2 -0
  277. package/packages/dd-trace/src/llmobs/plugins/ai/index.js +38 -7
  278. package/packages/dd-trace/src/llmobs/plugins/ai/util.js +30 -9
  279. package/packages/dd-trace/src/llmobs/plugins/bedrockruntime.js +3 -3
  280. package/packages/dd-trace/src/llmobs/plugins/genai/util.js +2 -2
  281. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chain.js +1 -1
  282. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chat_model.js +1 -1
  283. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/embedding.js +1 -1
  284. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/llm.js +1 -1
  285. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/vectorstore.js +1 -1
  286. package/packages/dd-trace/src/llmobs/plugins/openai/constants.js +16 -0
  287. package/packages/dd-trace/src/llmobs/plugins/openai/index.js +19 -5
  288. package/packages/dd-trace/src/llmobs/plugins/openai/utils.js +22 -10
  289. package/packages/dd-trace/src/llmobs/plugins/vertexai.js +1 -1
  290. package/packages/dd-trace/src/llmobs/sdk.js +46 -26
  291. package/packages/dd-trace/src/llmobs/span_processor.js +26 -20
  292. package/packages/dd-trace/src/llmobs/tagger.js +175 -1
  293. package/packages/dd-trace/src/llmobs/telemetry.js +3 -4
  294. package/packages/dd-trace/src/llmobs/writers/base.js +117 -38
  295. package/packages/dd-trace/src/llmobs/writers/spans.js +5 -5
  296. package/packages/dd-trace/src/log/index.js +5 -5
  297. package/packages/dd-trace/src/noop/proxy.js +5 -5
  298. package/packages/dd-trace/src/noop/span.js +1 -1
  299. package/packages/dd-trace/src/openfeature/index.js +2 -2
  300. package/packages/dd-trace/src/openfeature/noop.js +14 -14
  301. package/packages/dd-trace/src/openfeature/remote_config.js +31 -0
  302. package/packages/dd-trace/src/openfeature/writers/base.js +12 -13
  303. package/packages/dd-trace/src/openfeature/writers/exposures.js +9 -9
  304. package/packages/dd-trace/src/opentelemetry/context_manager.js +2 -2
  305. package/packages/dd-trace/src/opentelemetry/logs/logger.js +1 -1
  306. package/packages/dd-trace/src/opentelemetry/logs/logger_provider.js +4 -4
  307. package/packages/dd-trace/src/opentelemetry/logs/otlp_transformer.js +9 -8
  308. package/packages/dd-trace/src/opentelemetry/metrics/instruments.js +3 -3
  309. package/packages/dd-trace/src/opentelemetry/metrics/meter.js +2 -2
  310. package/packages/dd-trace/src/opentelemetry/metrics/otlp_transformer.js +4 -4
  311. package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +36 -11
  312. package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +2 -2
  313. package/packages/dd-trace/src/opentelemetry/otlp/otlp_transformer_base.js +11 -10
  314. package/packages/dd-trace/src/opentelemetry/otlp/protobuf_loader.js +1 -1
  315. package/packages/dd-trace/src/opentelemetry/span.js +2 -2
  316. package/packages/dd-trace/src/opentelemetry/tracer.js +51 -9
  317. package/packages/dd-trace/src/opentracing/propagation/text_map.js +68 -28
  318. package/packages/dd-trace/src/opentracing/span.js +7 -7
  319. package/packages/dd-trace/src/opentracing/tracer.js +5 -5
  320. package/packages/dd-trace/src/payload-tagging/index.js +6 -2
  321. package/packages/dd-trace/src/plugin_manager.js +8 -6
  322. package/packages/dd-trace/src/plugins/apollo.js +1 -1
  323. package/packages/dd-trace/src/plugins/ci_plugin.js +27 -27
  324. package/packages/dd-trace/src/plugins/database.js +1 -1
  325. package/packages/dd-trace/src/plugins/index.js +5 -1
  326. package/packages/dd-trace/src/plugins/log_plugin.js +1 -1
  327. package/packages/dd-trace/src/plugins/outbound.js +1 -1
  328. package/packages/dd-trace/src/plugins/tracing.js +1 -1
  329. package/packages/dd-trace/src/plugins/util/ci.js +5 -8
  330. package/packages/dd-trace/src/plugins/util/git-cache.js +3 -3
  331. package/packages/dd-trace/src/plugins/util/git.js +8 -8
  332. package/packages/dd-trace/src/plugins/util/stacktrace.js +1 -1
  333. package/packages/dd-trace/src/plugins/util/test.js +25 -25
  334. package/packages/dd-trace/src/plugins/util/user-provided-git.js +41 -43
  335. package/packages/dd-trace/src/plugins/util/web.js +8 -5
  336. package/packages/dd-trace/src/priority_sampler.js +15 -16
  337. package/packages/dd-trace/src/process-tags/index.js +31 -29
  338. package/packages/dd-trace/src/profiler.js +4 -39
  339. package/packages/dd-trace/src/profiling/config.js +104 -50
  340. package/packages/dd-trace/src/profiling/exporter_cli.js +8 -8
  341. package/packages/dd-trace/src/profiling/exporters/agent.js +6 -6
  342. package/packages/dd-trace/src/profiling/exporters/event_serializer.js +9 -2
  343. package/packages/dd-trace/src/profiling/index.js +1 -1
  344. package/packages/dd-trace/src/profiling/libuv-size.js +1 -1
  345. package/packages/dd-trace/src/profiling/profiler.js +61 -7
  346. package/packages/dd-trace/src/profiling/profilers/event_plugins/event.js +1 -1
  347. package/packages/dd-trace/src/profiling/profilers/events.js +2 -2
  348. package/packages/dd-trace/src/profiling/profilers/wall.js +4 -4
  349. package/packages/dd-trace/src/proxy.js +43 -20
  350. package/packages/dd-trace/src/remote_config/capabilities.js +3 -0
  351. package/packages/dd-trace/src/remote_config/index.js +541 -137
  352. package/packages/dd-trace/src/require-package-json.js +1 -1
  353. package/packages/dd-trace/src/ritm.js +58 -31
  354. package/packages/dd-trace/src/runtime_metrics/runtime_metrics.js +3 -3
  355. package/packages/dd-trace/src/serverless.js +17 -1
  356. package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +8 -0
  357. package/packages/dd-trace/src/service-naming/schemas/v1/messaging.js +8 -0
  358. package/packages/dd-trace/src/span_format.js +1 -1
  359. package/packages/dd-trace/src/span_processor.js +4 -4
  360. package/packages/dd-trace/src/span_stats.js +6 -4
  361. package/packages/dd-trace/src/standalone/index.js +1 -1
  362. package/packages/dd-trace/src/startup-log.js +7 -16
  363. package/packages/dd-trace/src/telemetry/dependencies.js +3 -3
  364. package/packages/dd-trace/src/telemetry/endpoints.js +75 -13
  365. package/packages/dd-trace/src/telemetry/logs/index.js +1 -1
  366. package/packages/dd-trace/src/telemetry/send-data.js +103 -4
  367. package/packages/dd-trace/src/telemetry/telemetry.js +238 -114
  368. package/packages/dd-trace/src/tracer.js +3 -3
  369. package/packages/dd-trace/src/tracer_metadata.js +19 -15
  370. package/packages/dd-trace/src/remote_config/manager.js +0 -368
  371. /package/packages/dd-trace/src/{git_properties.js → config/git_properties.js} +0 -0
@@ -0,0 +1,217 @@
1
+ 'use strict'
2
+
3
+ const TracingPlugin = require('../../dd-trace/src/plugins/tracing')
4
+ const SpanContext = require('../../dd-trace/src/opentracing/span_context')
5
+ const id = require('../../dd-trace/src/id')
6
+ const log = require('../../dd-trace/src/log')
7
+
8
+ // WeakMap to track push receive spans by request
9
+ const pushReceiveSpans = new WeakMap()
10
+
11
+ class GoogleCloudPubsubPushSubscriptionPlugin extends TracingPlugin {
12
+ static get id () { return 'google-cloud-pubsub-push-subscription' }
13
+
14
+ constructor (...args) {
15
+ super(...args)
16
+
17
+ /**
18
+ * PUSH SUBSCRIPTION: GCP sends HTTP POST requests to our service with message data in headers.
19
+ * We intercept these requests to create a pubsub.push.receive span that wraps the HTTP request.
20
+ *
21
+ * Flow: Detect push request -> Extract trace context -> Create receive span -> Activate it
22
+ * Hierarchy: pubsub.push.receive (parent) -> http.request (child) -> express.middleware...
23
+ *
24
+ * Plugin load order (http/index.js) ensures we subscribe before HttpServerPlugin.
25
+ */
26
+ this.addSub('apm:http:server:request:start', (ctx) => {
27
+ this.#handlePubSubRequest(ctx)
28
+ })
29
+
30
+ this.addSub('apm:http:server:request:finish', ({ req }) => {
31
+ this.#finishPushReceiveSpan(req)
32
+ })
33
+ }
34
+
35
+ #finishPushReceiveSpan (req) {
36
+ const pushReceiveSpan = pushReceiveSpans.get(req)
37
+ if (pushReceiveSpan && !pushReceiveSpan._duration) {
38
+ pushReceiveSpan.finish()
39
+ pushReceiveSpans.delete(req)
40
+ }
41
+ }
42
+
43
+ #handlePubSubRequest (ctx) {
44
+ const { req } = ctx
45
+ const userAgent = req.headers['user-agent'] || ''
46
+ if (req.method !== 'POST' || !userAgent.includes('APIs-Google')) {
47
+ return false
48
+ }
49
+
50
+ if (req.headers['x-goog-pubsub-message-id']) {
51
+ this.#createPushReceiveSpanAndActivate(ctx)
52
+ return true
53
+ }
54
+
55
+ log.warn(
56
+ '[PubSub] No x-goog-pubsub-* headers detected. pubsub.push.receive spans will not be created. ' +
57
+ 'Add --push-no-wrapper-write-metadata to your subscription.'
58
+ )
59
+ return false
60
+ }
61
+
62
+ #createPushReceiveSpanAndActivate (ctx) {
63
+ const { req, res } = ctx
64
+ const messageData = this.#parseMessage(req)
65
+ if (!messageData) {
66
+ return
67
+ }
68
+
69
+ const originalContext = this.#extractContext(messageData)
70
+ const pubsubRequestContext = this.#reconstructPubSubContext(messageData.attrs) || originalContext
71
+ const isSameTrace = pubsubRequestContext &&
72
+ originalContext?.toTraceId() === pubsubRequestContext.toTraceId()
73
+
74
+ /**
75
+ * Create receive span, choosing parent context:
76
+ * - Same trace: use batch context (message is part of the batch trace)
77
+ * - Different trace: use message context as parent, link to batch for observability
78
+ *
79
+ * this.enter() activates the span so the HTTP request span becomes its child.
80
+ */
81
+ const pushReceiveSpan = this.#createPushReceiveSpan(
82
+ messageData,
83
+ isSameTrace ? pubsubRequestContext : originalContext,
84
+ isSameTrace ? null : pubsubRequestContext
85
+ )
86
+
87
+ if (!pushReceiveSpan) {
88
+ return
89
+ }
90
+
91
+ this.enter(pushReceiveSpan, { req, res })
92
+ pushReceiveSpans.set(req, pushReceiveSpan)
93
+ }
94
+
95
+ #parseMessage (req) {
96
+ const subscription = req.headers['x-goog-pubsub-subscription-name']
97
+ const message = {
98
+ messageId: req.headers['x-goog-pubsub-message-id'],
99
+ publishTime: req.headers['x-goog-pubsub-publish-time']
100
+ }
101
+
102
+ const topicName = req.headers['pubsub.topic'] || 'push-subscription-topic'
103
+ return { message, subscription, attrs: req.headers, topicName }
104
+ }
105
+
106
+ #extractContext (messageData) {
107
+ return this.tracer.extract('text_map', messageData.attrs)
108
+ }
109
+
110
+ #reconstructPubSubContext (attrs) {
111
+ /**
112
+ * Reconstruct the batch publish span context from message attributes.
113
+ *
114
+ * When a batch is published, the producer injects:
115
+ * - _dd.pubsub_request.trace_id: lower 64 bits of the batch span's trace ID (hex)
116
+ * - _dd.pubsub_request.span_id: the batch span's span ID (hex)
117
+ * - _dd.pubsub_request.p.tid: upper 64 bits of trace ID (hex, optional for 128-bit traces)
118
+ *
119
+ * This context represents the "pubsub.request" span on the producer side.
120
+ * We use it to create span links, connecting each pubsub.push.receive span back to the original batch.
121
+ */
122
+ const traceIdLower = attrs['_dd.pubsub_request.trace_id']
123
+ const spanId = attrs['_dd.pubsub_request.span_id']
124
+ const traceIdUpper = attrs['_dd.pubsub_request.p.tid']
125
+
126
+ if (!traceIdLower || !spanId) return null
127
+
128
+ // Reconstruct full 128-bit trace ID (or pad 64-bit to 128-bit)
129
+ const traceId128 = traceIdUpper ? traceIdUpper + traceIdLower : traceIdLower.padStart(32, '0')
130
+ const traceId = id(traceId128, 16)
131
+ const parentId = id(spanId, 16)
132
+
133
+ const tags = {}
134
+ if (traceIdUpper) tags['_dd.p.tid'] = traceIdUpper
135
+
136
+ return new SpanContext({
137
+ traceId,
138
+ spanId: parentId,
139
+ tags
140
+ })
141
+ }
142
+
143
+ #createPushReceiveSpan (messageData, parentContext, linkContext) {
144
+ const { message, subscription, topicName, attrs } = messageData
145
+ const subscriptionName = subscription?.slice(subscription.lastIndexOf('/') + 1) ?? subscription
146
+ const publishStartTime = attrs['x-dd-publish-start-time']
147
+ const startTime = publishStartTime ? Number.parseInt(publishStartTime, 10) : undefined
148
+
149
+ // Get the base service name and construct the pubsub service override
150
+ const baseService = this.tracer._service
151
+ const serviceOverride = this.config.service ?? `${baseService}-pubsub`
152
+
153
+ // Use this.startSpan() which automatically activates the span
154
+ const span = this.startSpan('pubsub.push.receive', {
155
+ childOf: parentContext,
156
+ startTime,
157
+ kind: 'consumer',
158
+ service: serviceOverride,
159
+ meta: {
160
+ component: 'google-cloud-pubsub',
161
+ 'pubsub.method': 'receive',
162
+ 'pubsub.subscription': subscription,
163
+ 'pubsub.message_id': message.messageId,
164
+ 'pubsub.subscription_type': 'push',
165
+ 'pubsub.topic': topicName,
166
+ '_dd.base_service': baseService,
167
+ '_dd.serviceoverride.type': 'integration',
168
+ 'resource.name': `Push Subscription ${subscriptionName}`
169
+ }
170
+ })
171
+
172
+ if (!span) {
173
+ return null
174
+ }
175
+
176
+ span._integrationName = 'google-cloud-pubsub'
177
+ // Calculate delivery latency (queue time from publish to delivery)
178
+ if (publishStartTime) {
179
+ const deliveryDuration = Date.now() - Number(publishStartTime)
180
+ span.setTag('pubsub.delivery_duration_ms', deliveryDuration)
181
+ }
182
+
183
+ this.#addBatchMetadata(span, attrs)
184
+
185
+ if (linkContext) {
186
+ if (span.addLink) {
187
+ span.addLink(linkContext, {})
188
+ } else {
189
+ span._links ??= []
190
+ span._links.push({ context: linkContext, attributes: {} })
191
+ }
192
+ }
193
+
194
+ return span
195
+ }
196
+
197
+ #addBatchMetadata (span, attrs) {
198
+ const batchSizeStr = attrs['_dd.batch.size']
199
+ const batchIndexStr = attrs['_dd.batch.index']
200
+
201
+ if (!batchSizeStr || batchIndexStr === undefined) return
202
+
203
+ const size = Number(batchSizeStr)
204
+ const index = Number(batchIndexStr)
205
+
206
+ span.setTag('pubsub.batch.message_count', size)
207
+ span.setTag('pubsub.batch.message_index', index)
208
+ span.setTag('pubsub.batch.description', `Message ${index + 1} of ${size}`)
209
+
210
+ const requestTraceId = attrs['_dd.pubsub_request.trace_id']
211
+ if (requestTraceId) {
212
+ span.setTag('pubsub.batch.request_trace_id', requestTraceId)
213
+ }
214
+ }
215
+ }
216
+
217
+ module.exports = GoogleCloudPubsubPushSubscriptionPlugin
@@ -1,8 +1,8 @@
1
1
  'use strict'
2
2
 
3
3
  const CompositePlugin = require('../../dd-trace/src/plugins/composite')
4
- const GoogleVertexAITracingPlugin = require('./tracing')
5
4
  const VertexAILLMObsPlugin = require('../../dd-trace/src/llmobs/plugins/vertexai')
5
+ const GoogleVertexAITracingPlugin = require('./tracing')
6
6
 
7
7
  class GoogleCloudVertexAIPlugin extends CompositePlugin {
8
8
  static id = 'google-cloud-vertexai'
@@ -1,8 +1,8 @@
1
1
  'use strict'
2
2
 
3
3
  const CompositePlugin = require('../../dd-trace/src/plugins/composite')
4
- const GenAiTracingPlugin = require('./tracing')
5
4
  const GenAiLLMObsPlugin = require('../../dd-trace/src/llmobs/plugins/genai')
5
+ const GenAiTracingPlugin = require('./tracing')
6
6
 
7
7
  class GenAiPlugin extends CompositePlugin {
8
8
  static id = 'google-genai'
@@ -1,7 +1,7 @@
1
1
  'use strict'
2
2
 
3
- const TracingPlugin = require('../../dd-trace/src/plugins/tracing')
4
3
  const dc = require('dc-polyfill')
4
+ const TracingPlugin = require('../../dd-trace/src/plugins/tracing')
5
5
 
6
6
  const collapsedPathSym = Symbol('collapsedPaths')
7
7
 
@@ -1,8 +1,8 @@
1
1
  'use strict'
2
2
 
3
+ const CompositePlugin = require('../../dd-trace/src/plugins/composite')
3
4
  const GrpcServerPlugin = require('./server')
4
5
  const GrpcClientPlugin = require('./client')
5
- const CompositePlugin = require('../../dd-trace/src/plugins/composite')
6
6
 
7
7
  class GrpcPlugin extends CompositePlugin {
8
8
  static id = 'grpc'
@@ -1,5 +1,7 @@
1
1
  'use strict'
2
2
 
3
+ const { URL } = require('url')
4
+
3
5
  const ClientPlugin = require('../../dd-trace/src/plugins/client')
4
6
  const { storage } = require('../../datadog-core')
5
7
  const tags = require('../../../ext/tags')
@@ -9,7 +11,6 @@ const HTTP_HEADERS = formats.HTTP_HEADERS
9
11
  const urlFilter = require('../../dd-trace/src/plugins/util/urlfilter')
10
12
  const log = require('../../dd-trace/src/log')
11
13
  const { CLIENT_PORT_KEY, COMPONENT, ERROR_MESSAGE, ERROR_TYPE, ERROR_STACK } = require('../../dd-trace/src/constants')
12
- const { URL } = require('url')
13
14
 
14
15
  const HTTP_STATUS_CODE = tags.HTTP_STATUS_CODE
15
16
  const HTTP_REQUEST_HEADERS = tags.HTTP_REQUEST_HEADERS
@@ -1,16 +1,36 @@
1
1
  'use strict'
2
2
 
3
- const HttpServerPlugin = require('./server')
4
- const HttpClientPlugin = require('./client')
3
+ const PushSubscriptionPlugin = require('../../datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription')
5
4
  const CompositePlugin = require('../../dd-trace/src/plugins/composite')
5
+ const { enableGCPPubSubPushSubscription } = require('../../dd-trace/src/serverless')
6
+ const log = require('../../dd-trace/src/log')
7
+ const HttpClientPlugin = require('./client')
8
+ const HttpServerPlugin = require('./server')
6
9
 
10
+ /**
11
+ * HTTP Plugin loads server/client plugins with optional GCP Pub/Sub Push support.
12
+ * Plugin order is critical: PushSubscriptionPlugin must load FIRST to intercept
13
+ * Pub/Sub push requests and activate delivery spans before HTTP spans are created.
14
+ */
7
15
  class HttpPlugin extends CompositePlugin {
8
16
  static id = 'http'
9
17
  static get plugins () {
10
- return {
11
- server: HttpServerPlugin,
12
- client: HttpClientPlugin
18
+ const plugins = {}
19
+
20
+ // Load push subscription plugin first (if enabled) for GCP Cloud Run
21
+ if (enableGCPPubSubPushSubscription()) {
22
+ try {
23
+ plugins['pubsub-push-subscription'] = PushSubscriptionPlugin
24
+ log.debug('Loaded GCP Pub/Sub Push Subscription plugin for HTTP requests')
25
+ } catch (e) {
26
+ log.debug(`Failed to load GCP Pub/Sub Push Subscription plugin: ${e.message}`)
27
+ }
13
28
  }
29
+
30
+ plugins.server = HttpServerPlugin
31
+ plugins.client = HttpClientPlugin
32
+
33
+ return plugins
14
34
  }
15
35
  }
16
36
 
@@ -1,9 +1,9 @@
1
1
  'use strict'
2
2
 
3
+ const URL = require('url').URL
4
+
3
5
  const { storage } = require('../../datadog-core')
4
6
  const ClientPlugin = require('../../dd-trace/src/plugins/client')
5
-
6
- const URL = require('url').URL
7
7
  const log = require('../../dd-trace/src/log')
8
8
  const tags = require('../../../ext/tags')
9
9
  const kinds = require('../../../ext/kinds')
@@ -1,8 +1,8 @@
1
1
  'use strict'
2
2
 
3
+ const CompositePlugin = require('../../dd-trace/src/plugins/composite')
3
4
  const Http2ServerPlugin = require('./server')
4
5
  const Http2ClientPlugin = require('./client')
5
- const CompositePlugin = require('../../dd-trace/src/plugins/composite')
6
6
 
7
7
  class Http2Plugin extends CompositePlugin {
8
8
  static id = 'http2'
@@ -2,7 +2,7 @@
2
2
 
3
3
  const CiPlugin = require('../../dd-trace/src/plugins/ci_plugin')
4
4
  const { storage } = require('../../datadog-core')
5
- const { getEnvironmentVariable } = require('../../dd-trace/src/config-helper')
5
+ const { getEnvironmentVariable, getValueFromEnvSources } = require('../../dd-trace/src/config/helper')
6
6
 
7
7
  const {
8
8
  TEST_STATUS,
@@ -161,7 +161,7 @@ class JestPlugin extends CiPlugin {
161
161
 
162
162
  this.telemetry.count(TELEMETRY_TEST_SESSION, {
163
163
  provider: this.ciProviderName,
164
- autoInjected: !!getEnvironmentVariable('DD_CIVISIBILITY_AUTO_INSTRUMENTATION_PROVIDER')
164
+ autoInjected: !!getValueFromEnvSources('DD_CIVISIBILITY_AUTO_INSTRUMENTATION_PROVIDER')
165
165
  })
166
166
 
167
167
  this.tracer._exporter.flush(() => {
@@ -1,9 +1,9 @@
1
1
  'use strict'
2
2
 
3
+ const CompositePlugin = require('../../dd-trace/src/plugins/composite')
3
4
  const ProducerPlugin = require('./producer')
4
5
  const ConsumerPlugin = require('./consumer')
5
6
  const BatchConsumerPlugin = require('./batch-consumer')
6
- const CompositePlugin = require('../../dd-trace/src/plugins/composite')
7
7
 
8
8
  class KafkajsPlugin extends CompositePlugin {
9
9
  static id = 'kafkajs'
@@ -1,8 +1,8 @@
1
1
  'use strict'
2
2
 
3
- const langChainTracingPlugins = require('./tracing')
4
3
  const langChainLLMObsPlugins = require('../../dd-trace/src/llmobs/plugins/langchain')
5
4
  const CompositePlugin = require('../../dd-trace/src/plugins/composite')
5
+ const langChainTracingPlugins = require('./tracing')
6
6
 
7
7
  const plugins = {}
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  const CiPlugin = require('../../dd-trace/src/plugins/ci_plugin')
4
4
  const { storage } = require('../../datadog-core')
5
- const { getEnvironmentVariable } = require('../../dd-trace/src/config-helper')
5
+ const { getValueFromEnvSources } = require('../../dd-trace/src/config/helper')
6
6
 
7
7
  const {
8
8
  TEST_STATUS,
@@ -406,7 +406,7 @@ class MochaPlugin extends CiPlugin {
406
406
  finishAllTraceSpans(this.testSessionSpan)
407
407
  this.telemetry.count(TELEMETRY_TEST_SESSION, {
408
408
  provider: this.ciProviderName,
409
- autoInjected: !!getEnvironmentVariable('DD_CIVISIBILITY_AUTO_INSTRUMENTATION_PROVIDER')
409
+ autoInjected: !!getValueFromEnvSources('DD_CIVISIBILITY_AUTO_INSTRUMENTATION_PROVIDER')
410
410
  })
411
411
  }
412
412
  this.libraryConfig = null
@@ -2,9 +2,9 @@
2
2
 
3
3
  // TODO: support https://moleculer.services/docs/0.13/actions.html#Streaming
4
4
 
5
+ const CompositePlugin = require('../../dd-trace/src/plugins/composite')
5
6
  const MoleculerServerPlugin = require('./server')
6
7
  const MoleculerClientPlugin = require('./client')
7
- const CompositePlugin = require('../../dd-trace/src/plugins/composite')
8
8
 
9
9
  class MoleculerPlugin extends CompositePlugin {
10
10
  static id = 'moleculer'
@@ -2,7 +2,7 @@
2
2
 
3
3
  const { isTrue } = require('../../dd-trace/src/util')
4
4
  const DatabasePlugin = require('../../dd-trace/src/plugins/database')
5
- const { getEnvironmentVariable } = require('../../dd-trace/src/config-helper')
5
+ const { getValueFromEnvSources } = require('../../dd-trace/src/config/helper')
6
6
 
7
7
  class MongodbCorePlugin extends DatabasePlugin {
8
8
  static id = 'mongodb-core'
@@ -20,7 +20,7 @@ class MongodbCorePlugin extends DatabasePlugin {
20
20
  configure (config) {
21
21
  super.configure(config)
22
22
 
23
- const heartbeatFromEnv = getEnvironmentVariable('DD_TRACE_MONGODB_HEARTBEAT_ENABLED')
23
+ const heartbeatFromEnv = getValueFromEnvSources('DD_TRACE_MONGODB_HEARTBEAT_ENABLED')
24
24
 
25
25
  this.config.heartbeatEnabled = config.heartbeatEnabled ??
26
26
  (heartbeatFromEnv && isTrue(heartbeatFromEnv)) ??
@@ -204,8 +204,12 @@ function isBinary (val) {
204
204
  }
205
205
 
206
206
  function isHeartbeat (ops, config) {
207
- // Check if it's a heartbeat command hello: 1 or helloOk: 1
208
- return ops && typeof ops === 'object' && (ops.hello === 1 || ops.helloOk === true)
207
+ // Check if it's a heartbeat command https://github.com/mongodb/specifications/blob/master/source/mongodb-handshake/handshake.md
208
+ return (
209
+ ops &&
210
+ typeof ops === 'object' &&
211
+ (ops.hello === 1 || ops.helloOk === true || ops.ismaster === 1 || ops.isMaster === 1)
212
+ )
209
213
  }
210
214
 
211
215
  module.exports = MongodbCorePlugin
@@ -1,8 +1,8 @@
1
1
  'use strict'
2
2
 
3
3
  const CompositePlugin = require('../../dd-trace/src/plugins/composite')
4
- const OpenAiTracingPlugin = require('./tracing')
5
4
  const OpenAiLLMObsPlugin = require('../../dd-trace/src/llmobs/plugins/openai')
5
+ const OpenAiTracingPlugin = require('./tracing')
6
6
 
7
7
  class OpenAiPlugin extends CompositePlugin {
8
8
  static id = 'openai'
@@ -1,10 +1,30 @@
1
1
  'use strict'
2
2
 
3
+ /**
4
+ * @typedef {Record<string, unknown>} JsonObject
5
+ *
6
+ * @typedef {{ function: { arguments: string } }} ToolCall
7
+ * @typedef {{ content?: string, tool_calls?: ToolCall[] }} ChatDelta
8
+ *
9
+ * @typedef {{
10
+ * index: number,
11
+ * finish_reason?: string | null,
12
+ * text?: string,
13
+ * delta?: ChatDelta
14
+ * }} StreamChoice
15
+ *
16
+ * @typedef {JsonObject & { choices: StreamChoice[], usage?: unknown }} StreamChunk
17
+ * @typedef {JsonObject & { choices: Array<StreamChoice | undefined>, usage?: unknown }} StreamResponseBody
18
+ *
19
+ * @typedef {JsonObject & { status?: string }} ResponsesApiResponse
20
+ * @typedef {JsonObject & { response?: ResponsesApiResponse }} ResponsesApiChunk
21
+ */
22
+
3
23
  /**
4
24
  * Combines legacy OpenAI streamed chunks into a single object.
5
25
  * These legacy chunks are returned as buffers instead of individual objects.
6
26
  * @param {readonly Uint8Array[]} chunks
7
- * @returns {Array<Record<string, any>>}
27
+ * @returns {JsonObject[]}
8
28
  */
9
29
  function convertBuffersToObjects (chunks) {
10
30
  return Buffer
@@ -21,10 +41,10 @@ function convertBuffersToObjects (chunks) {
21
41
  * The shared logic will add a new choice index entry if it doesn't exist, and otherwise
22
42
  * hand off to a onChoice handler to add that choice to the previously stored choice.
23
43
  *
24
- * @param {Array<Record<string, any>>} chunks
44
+ * @param {StreamChunk[]} chunks
25
45
  * @param {number} n
26
- * @param {function(Record<string, any>, Record<string, any>): void} onChoice
27
- * @returns {Record<string, any>}
46
+ * @param {(newChoice: StreamChoice, existingChoice: StreamChoice) => void} onChoice
47
+ * @returns {StreamResponseBody}
28
48
  */
29
49
  function constructResponseFromStreamedChunks (chunks, n, onChoice) {
30
50
  const body = { ...chunks[0], choices: Array.from({ length: n }) }
@@ -54,9 +74,9 @@ function constructResponseFromStreamedChunks (chunks, n, onChoice) {
54
74
  /**
55
75
  * Constructs the entire response from a stream of OpenAI completion chunks,
56
76
  * mainly combining the text choices of each chunk into a single string per choice.
57
- * @param {Array<Record<string, any>>} chunks
77
+ * @param {StreamChunk[]} chunks
58
78
  * @param {number} n the number of choices to expect in the response
59
- * @returns {Record<string, any>}
79
+ * @returns {StreamResponseBody}
60
80
  */
61
81
  function constructCompletionResponseFromStreamedChunks (chunks, n) {
62
82
  return constructResponseFromStreamedChunks(chunks, n, (choice, oldChoice) => {
@@ -74,9 +94,9 @@ function constructCompletionResponseFromStreamedChunks (chunks, n) {
74
94
  /**
75
95
  * Constructs the entire response from a stream of OpenAI chat completion chunks,
76
96
  * mainly combining the text choices of each chunk into a single string per choice.
77
- * @param {Array<Record<string, any>>} chunks
97
+ * @param {StreamChunk[]} chunks
78
98
  * @param {number} n the number of choices to expect in the response
79
- * @returns {Record<string, any>}
99
+ * @returns {StreamResponseBody}
80
100
  */
81
101
  function constructChatCompletionResponseFromStreamedChunks (chunks, n) {
82
102
  return constructResponseFromStreamedChunks(chunks, n, (choice, oldChoice) => {
@@ -110,8 +130,8 @@ function constructChatCompletionResponseFromStreamedChunks (chunks, n) {
110
130
  /**
111
131
  * Constructs the entire response from a stream of OpenAI responses chunks.
112
132
  * The responses API uses event-based streaming with delta chunks.
113
- * @param {Array<Record<string, any>>} chunks
114
- * @returns {Record<string, any>|undefined}
133
+ * @param {ResponsesApiChunk[]} chunks
134
+ * @returns {ResponsesApiResponse|undefined}
115
135
  */
116
136
  function constructResponseResponseFromStreamedChunks (chunks) {
117
137
  // The responses API streams events with different types:
@@ -4,10 +4,10 @@ const path = require('path')
4
4
 
5
5
  const TracingPlugin = require('../../dd-trace/src/plugins/tracing')
6
6
  const { storage } = require('../../datadog-core')
7
- const services = require('./services')
8
7
  const Sampler = require('../../dd-trace/src/sampler')
9
8
  const { MEASURED } = require('../../../ext/tags')
10
9
 
10
+ const { DD_MAJOR } = require('../../../version')
11
11
  const {
12
12
  convertBuffersToObjects,
13
13
  constructCompletionResponseFromStreamedChunks,
@@ -15,7 +15,7 @@ const {
15
15
  constructResponseResponseFromStreamedChunks
16
16
  } = require('./stream-helpers')
17
17
 
18
- const { DD_MAJOR } = require('../../../version')
18
+ const services = require('./services')
19
19
 
20
20
  class OpenAiTracingPlugin extends TracingPlugin {
21
21
  static id = 'openai'
@@ -3,7 +3,7 @@
3
3
  const { storage } = require('../../datadog-core')
4
4
  const id = require('../../dd-trace/src/id')
5
5
  const CiPlugin = require('../../dd-trace/src/plugins/ci_plugin')
6
- const { getEnvironmentVariable } = require('../../dd-trace/src/config-helper')
6
+ const { getValueFromEnvSources } = require('../../dd-trace/src/config/helper')
7
7
 
8
8
  const {
9
9
  TEST_STATUS,
@@ -106,7 +106,7 @@ class PlaywrightPlugin extends CiPlugin {
106
106
  finishAllTraceSpans(this.testSessionSpan)
107
107
  this.telemetry.count(TELEMETRY_TEST_SESSION, {
108
108
  provider: this.ciProviderName,
109
- autoInjected: !!getEnvironmentVariable('DD_CIVISIBILITY_AUTO_INSTRUMENTATION_PROVIDER')
109
+ autoInjected: !!getValueFromEnvSources('DD_CIVISIBILITY_AUTO_INSTRUMENTATION_PROVIDER')
110
110
  })
111
111
  appClosingTelemetry()
112
112
  this.tracer._exporter.flush(onDone)
@@ -393,7 +393,7 @@ class PlaywrightPlugin extends CiPlugin {
393
393
  span.finish()
394
394
 
395
395
  finishAllTraceSpans(span)
396
- if (getEnvironmentVariable('DD_PLAYWRIGHT_WORKER')) {
396
+ if (getValueFromEnvSources('DD_PLAYWRIGHT_WORKER')) {
397
397
  this.tracer._exporter.flush(onDone)
398
398
  }
399
399
  })
@@ -1,8 +1,8 @@
1
1
  'use strict'
2
2
 
3
+ const CompositePlugin = require('../../dd-trace/src/plugins/composite')
3
4
  const ProducerPlugin = require('./producer')
4
5
  const ConsumerPlugin = require('./consumer')
5
- const CompositePlugin = require('../../dd-trace/src/plugins/composite')
6
6
 
7
7
  class RheaPlugin extends CompositePlugin {
8
8
  static id = 'rhea'