dd-trace 5.80.0 → 5.82.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 (460) hide show
  1. package/LICENSE-3rdparty.csv +79 -88
  2. package/ext/tags.d.ts +1 -0
  3. package/ext/tags.js +1 -0
  4. package/index.d.ts +42 -35
  5. package/loader-hook.mjs +16 -4
  6. package/package.json +33 -56
  7. package/packages/datadog-core/src/utils/src/parse-tags.js +1 -1
  8. package/packages/datadog-esbuild/index.js +44 -26
  9. package/packages/datadog-esbuild/src/utils.js +14 -2
  10. package/packages/datadog-instrumentations/index.js +1 -0
  11. package/packages/datadog-instrumentations/src/aerospike.js +3 -2
  12. package/packages/datadog-instrumentations/src/ai.js +2 -2
  13. package/packages/datadog-instrumentations/src/amqp10.js +1 -1
  14. package/packages/datadog-instrumentations/src/amqplib.js +4 -4
  15. package/packages/datadog-instrumentations/src/anthropic.js +14 -2
  16. package/packages/datadog-instrumentations/src/apollo-server-core.js +2 -2
  17. package/packages/datadog-instrumentations/src/apollo-server.js +1 -1
  18. package/packages/datadog-instrumentations/src/apollo.js +3 -2
  19. package/packages/datadog-instrumentations/src/avsc.js +1 -1
  20. package/packages/datadog-instrumentations/src/aws-sdk.js +6 -2
  21. package/packages/datadog-instrumentations/src/azure-event-hubs.js +4 -3
  22. package/packages/datadog-instrumentations/src/azure-functions.js +2 -2
  23. package/packages/datadog-instrumentations/src/azure-service-bus.js +3 -4
  24. package/packages/datadog-instrumentations/src/bluebird.js +1 -1
  25. package/packages/datadog-instrumentations/src/bullmq.js +11 -0
  26. package/packages/datadog-instrumentations/src/bunyan.js +1 -1
  27. package/packages/datadog-instrumentations/src/cassandra-driver.js +1 -1
  28. package/packages/datadog-instrumentations/src/child_process.js +2 -2
  29. package/packages/datadog-instrumentations/src/confluentinc-kafka-javascript.js +3 -3
  30. package/packages/datadog-instrumentations/src/couchbase.js +1 -1
  31. package/packages/datadog-instrumentations/src/crypto.js +1 -1
  32. package/packages/datadog-instrumentations/src/cucumber.js +12 -13
  33. package/packages/datadog-instrumentations/src/cypress.js +1 -1
  34. package/packages/datadog-instrumentations/src/dns.js +1 -1
  35. package/packages/datadog-instrumentations/src/elasticsearch.js +1 -1
  36. package/packages/datadog-instrumentations/src/express-mongo-sanitize.js +1 -1
  37. package/packages/datadog-instrumentations/src/express.js +1 -1
  38. package/packages/datadog-instrumentations/src/find-my-way.js +6 -5
  39. package/packages/datadog-instrumentations/src/fs.js +1 -1
  40. package/packages/datadog-instrumentations/src/generic-pool.js +1 -1
  41. package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +137 -15
  42. package/packages/datadog-instrumentations/src/google-cloud-vertexai.js +2 -3
  43. package/packages/datadog-instrumentations/src/google-genai.js +120 -0
  44. package/packages/datadog-instrumentations/src/graphql.js +21 -1
  45. package/packages/datadog-instrumentations/src/grpc/client.js +1 -1
  46. package/packages/datadog-instrumentations/src/grpc/server.js +1 -1
  47. package/packages/datadog-instrumentations/src/helpers/bundler-register.js +1 -1
  48. package/packages/datadog-instrumentations/src/helpers/hook.js +1 -1
  49. package/packages/datadog-instrumentations/src/helpers/hooks.js +5 -1
  50. package/packages/datadog-instrumentations/src/helpers/instrument.js +11 -1
  51. package/packages/datadog-instrumentations/src/helpers/register.js +12 -5
  52. package/packages/datadog-instrumentations/src/helpers/rewriter/compiler.js +27 -0
  53. package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +152 -0
  54. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/bullmq.json +106 -0
  55. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/index.js +6 -0
  56. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/langchain.js +237 -0
  57. package/packages/datadog-instrumentations/src/helpers/rewriter/loader.js +9 -0
  58. package/packages/datadog-instrumentations/src/helpers/rewriter/loader.mjs +11 -0
  59. package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +139 -0
  60. package/packages/datadog-instrumentations/src/helpers/router-helper.js +1 -1
  61. package/packages/datadog-instrumentations/src/helpers/shared-utils.js +9 -0
  62. package/packages/datadog-instrumentations/src/hono.js +55 -10
  63. package/packages/datadog-instrumentations/src/ioredis.js +1 -1
  64. package/packages/datadog-instrumentations/src/iovalkey.js +1 -1
  65. package/packages/datadog-instrumentations/src/jest.js +2 -2
  66. package/packages/datadog-instrumentations/src/kafkajs.js +3 -3
  67. package/packages/datadog-instrumentations/src/knex.js +1 -1
  68. package/packages/datadog-instrumentations/src/langchain.js +3 -109
  69. package/packages/datadog-instrumentations/src/ldapjs.js +1 -1
  70. package/packages/datadog-instrumentations/src/light-my-request.js +93 -0
  71. package/packages/datadog-instrumentations/src/limitd-client.js +1 -1
  72. package/packages/datadog-instrumentations/src/lodash.js +1 -2
  73. package/packages/datadog-instrumentations/src/mariadb.js +1 -2
  74. package/packages/datadog-instrumentations/src/memcached.js +1 -1
  75. package/packages/datadog-instrumentations/src/mocha/main.js +1 -1
  76. package/packages/datadog-instrumentations/src/mongodb-core.js +1 -1
  77. package/packages/datadog-instrumentations/src/mongodb.js +1 -1
  78. package/packages/datadog-instrumentations/src/mongoose.js +1 -1
  79. package/packages/datadog-instrumentations/src/mquery.js +1 -1
  80. package/packages/datadog-instrumentations/src/mysql.js +1 -1
  81. package/packages/datadog-instrumentations/src/mysql2.js +2 -2
  82. package/packages/datadog-instrumentations/src/net.js +1 -1
  83. package/packages/datadog-instrumentations/src/next.js +1 -1
  84. package/packages/datadog-instrumentations/src/nyc.js +1 -1
  85. package/packages/datadog-instrumentations/src/openai.js +2 -2
  86. package/packages/datadog-instrumentations/src/opensearch.js +1 -1
  87. package/packages/datadog-instrumentations/src/oracledb.js +1 -1
  88. package/packages/datadog-instrumentations/src/otel-sdk-trace.js +1 -1
  89. package/packages/datadog-instrumentations/src/pg.js +3 -3
  90. package/packages/datadog-instrumentations/src/pino.js +1 -1
  91. package/packages/datadog-instrumentations/src/playwright.js +46 -17
  92. package/packages/datadog-instrumentations/src/prisma.js +52 -37
  93. package/packages/datadog-instrumentations/src/process.js +1 -1
  94. package/packages/datadog-instrumentations/src/promise-js.js +1 -1
  95. package/packages/datadog-instrumentations/src/promise.js +1 -1
  96. package/packages/datadog-instrumentations/src/protobufjs.js +1 -1
  97. package/packages/datadog-instrumentations/src/q.js +1 -1
  98. package/packages/datadog-instrumentations/src/redis.js +1 -1
  99. package/packages/datadog-instrumentations/src/rhea.js +1 -1
  100. package/packages/datadog-instrumentations/src/router.js +1 -1
  101. package/packages/datadog-instrumentations/src/selenium.js +4 -2
  102. package/packages/datadog-instrumentations/src/sequelize.js +1 -2
  103. package/packages/datadog-instrumentations/src/sharedb.js +1 -1
  104. package/packages/datadog-instrumentations/src/tedious.js +1 -1
  105. package/packages/datadog-instrumentations/src/undici.js +4 -4
  106. package/packages/datadog-instrumentations/src/url.js +1 -1
  107. package/packages/datadog-instrumentations/src/vitest.js +1 -1
  108. package/packages/datadog-instrumentations/src/vm.js +1 -1
  109. package/packages/datadog-instrumentations/src/when.js +1 -1
  110. package/packages/datadog-instrumentations/src/winston.js +1 -1
  111. package/packages/datadog-instrumentations/src/ws.js +38 -19
  112. package/packages/datadog-plugin-amqp10/src/index.js +1 -1
  113. package/packages/datadog-plugin-amqplib/src/index.js +1 -1
  114. package/packages/datadog-plugin-anthropic/src/index.js +1 -1
  115. package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/index.js +1 -1
  116. package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +4 -4
  117. package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +2 -2
  118. package/packages/datadog-plugin-aws-sdk/src/util.js +3 -3
  119. package/packages/datadog-plugin-azure-event-hubs/src/index.js +1 -1
  120. package/packages/datadog-plugin-azure-event-hubs/src/producer.js +19 -5
  121. package/packages/datadog-plugin-azure-service-bus/src/index.js +1 -1
  122. package/packages/datadog-plugin-azure-service-bus/src/producer.js +4 -0
  123. package/packages/datadog-plugin-bullmq/src/consumer.js +60 -0
  124. package/packages/datadog-plugin-bullmq/src/index.js +18 -0
  125. package/packages/datadog-plugin-bullmq/src/producer.js +178 -0
  126. package/packages/datadog-plugin-child_process/src/scrub-cmd-params.js +1 -1
  127. package/packages/datadog-plugin-confluentinc-kafka-javascript/src/index.js +1 -1
  128. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +23 -2
  129. package/packages/datadog-plugin-cypress/src/plugin.js +2 -2
  130. package/packages/datadog-plugin-cypress/src/support.js +73 -31
  131. package/packages/datadog-plugin-express/src/index.js +1 -1
  132. package/packages/datadog-plugin-fastify/src/index.js +1 -1
  133. package/packages/datadog-plugin-google-cloud-pubsub/src/client.js +13 -3
  134. package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +171 -12
  135. package/packages/datadog-plugin-google-cloud-pubsub/src/index.js +1 -2
  136. package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +160 -13
  137. package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +217 -0
  138. package/packages/datadog-plugin-google-cloud-vertexai/src/index.js +1 -1
  139. package/packages/datadog-plugin-google-genai/src/index.js +17 -0
  140. package/packages/datadog-plugin-google-genai/src/tracing.js +41 -0
  141. package/packages/datadog-plugin-graphql/src/resolve.js +1 -1
  142. package/packages/datadog-plugin-graphql/src/tools/transforms.js +5 -4
  143. package/packages/datadog-plugin-grpc/src/index.js +1 -1
  144. package/packages/datadog-plugin-http/src/client.js +2 -1
  145. package/packages/datadog-plugin-http/src/index.js +25 -5
  146. package/packages/datadog-plugin-http2/src/client.js +2 -2
  147. package/packages/datadog-plugin-http2/src/index.js +1 -1
  148. package/packages/datadog-plugin-jest/src/util.js +1 -1
  149. package/packages/datadog-plugin-kafkajs/src/index.js +1 -1
  150. package/packages/datadog-plugin-langchain/src/index.js +1 -1
  151. package/packages/datadog-plugin-langchain/src/tracing.js +7 -3
  152. package/packages/datadog-plugin-moleculer/src/index.js +1 -1
  153. package/packages/datadog-plugin-mongodb-core/src/index.js +6 -2
  154. package/packages/datadog-plugin-next/src/index.js +11 -3
  155. package/packages/datadog-plugin-openai/src/index.js +1 -1
  156. package/packages/datadog-plugin-openai/src/stream-helpers.js +30 -10
  157. package/packages/datadog-plugin-openai/src/tracing.js +2 -2
  158. package/packages/datadog-plugin-rhea/src/index.js +1 -1
  159. package/packages/datadog-plugin-ws/src/close.js +56 -3
  160. package/packages/datadog-plugin-ws/src/index.js +4 -0
  161. package/packages/datadog-plugin-ws/src/producer.js +39 -4
  162. package/packages/datadog-plugin-ws/src/receiver.js +39 -3
  163. package/packages/datadog-plugin-ws/src/server.js +13 -1
  164. package/packages/datadog-plugin-ws/src/util.js +107 -0
  165. package/packages/datadog-shimmer/src/shimmer.js +2 -2
  166. package/packages/dd-trace/src/aiguard/sdk.js +21 -13
  167. package/packages/dd-trace/src/appsec/api_security_sampler.js +1 -1
  168. package/packages/dd-trace/src/appsec/graphql.js +2 -2
  169. package/packages/dd-trace/src/appsec/iast/analyzers/code-injection-analyzer.js +1 -1
  170. package/packages/dd-trace/src/appsec/iast/analyzers/command-injection-analyzer.js +1 -1
  171. package/packages/dd-trace/src/appsec/iast/analyzers/cookie-analyzer.js +1 -1
  172. package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-base-analyzer.js +1 -1
  173. package/packages/dd-trace/src/appsec/iast/analyzers/injection-analyzer.js +1 -1
  174. package/packages/dd-trace/src/appsec/iast/analyzers/ldap-injection-analyzer.js +1 -1
  175. package/packages/dd-trace/src/appsec/iast/analyzers/nosql-injection-mongodb-analyzer.js +3 -3
  176. package/packages/dd-trace/src/appsec/iast/analyzers/path-traversal-analyzer.js +1 -1
  177. package/packages/dd-trace/src/appsec/iast/analyzers/ssrf-analyzer.js +1 -1
  178. package/packages/dd-trace/src/appsec/iast/analyzers/untrusted-deserialization-analyzer.js +1 -1
  179. package/packages/dd-trace/src/appsec/iast/analyzers/unvalidated-redirect-analyzer.js +1 -1
  180. package/packages/dd-trace/src/appsec/iast/analyzers/weak-cipher-analyzer.js +1 -1
  181. package/packages/dd-trace/src/appsec/iast/analyzers/weak-hash-analyzer.js +3 -2
  182. package/packages/dd-trace/src/appsec/iast/analyzers/weak-randomness-analyzer.js +1 -1
  183. package/packages/dd-trace/src/appsec/iast/iast-plugin.js +3 -3
  184. package/packages/dd-trace/src/appsec/iast/index.js +5 -5
  185. package/packages/dd-trace/src/appsec/iast/overhead-controller.js +1 -1
  186. package/packages/dd-trace/src/appsec/iast/security-controls/index.js +1 -1
  187. package/packages/dd-trace/src/appsec/iast/taint-tracking/index.js +1 -2
  188. package/packages/dd-trace/src/appsec/iast/taint-tracking/operations-taint-object.js +1 -1
  189. package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +1 -1
  190. package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter-esm.mjs +1 -1
  191. package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +11 -16
  192. package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +1 -1
  193. package/packages/dd-trace/src/appsec/iast/telemetry/namespaces.js +1 -1
  194. package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +4 -4
  195. package/packages/dd-trace/src/appsec/index.js +8 -8
  196. package/packages/dd-trace/src/appsec/rasp/command_injection.js +1 -1
  197. package/packages/dd-trace/src/appsec/rasp/index.js +1 -1
  198. package/packages/dd-trace/src/appsec/rasp/lfi.js +1 -1
  199. package/packages/dd-trace/src/appsec/rc-products.js +10 -0
  200. package/packages/dd-trace/src/appsec/recommended.json +230 -3
  201. package/packages/dd-trace/src/appsec/remote_config.js +177 -0
  202. package/packages/dd-trace/src/appsec/reporter.js +3 -7
  203. package/packages/dd-trace/src/appsec/rule_manager.js +37 -20
  204. package/packages/dd-trace/src/appsec/sdk/index.js +1 -1
  205. package/packages/dd-trace/src/appsec/sdk/set_user.js +1 -1
  206. package/packages/dd-trace/src/appsec/sdk/track_event.js +2 -2
  207. package/packages/dd-trace/src/appsec/sdk/user_blocking.js +2 -2
  208. package/packages/dd-trace/src/appsec/user_tracking.js +2 -2
  209. package/packages/dd-trace/src/appsec/waf/index.js +17 -3
  210. package/packages/dd-trace/src/appsec/waf/waf_manager.js +11 -0
  211. package/packages/dd-trace/src/azure_metadata.js +8 -2
  212. package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +8 -6
  213. package/packages/dd-trace/src/ci-visibility/exporters/agentless/index.js +2 -2
  214. package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +1 -1
  215. package/packages/dd-trace/src/ci-visibility/exporters/test-worker/index.js +1 -1
  216. package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +4 -2
  217. package/packages/dd-trace/src/config/remote_config.js +34 -0
  218. package/packages/dd-trace/src/config.js +109 -34
  219. package/packages/dd-trace/src/config_defaults.js +16 -3
  220. package/packages/dd-trace/src/constants.js +5 -0
  221. package/packages/dd-trace/src/crashtracking/crashtracker.js +10 -1
  222. package/packages/dd-trace/src/datastreams/checkpointer.js +2 -2
  223. package/packages/dd-trace/src/datastreams/encoding.js +23 -6
  224. package/packages/dd-trace/src/datastreams/index.js +1 -1
  225. package/packages/dd-trace/src/datastreams/pathway.js +41 -2
  226. package/packages/dd-trace/src/datastreams/processor.js +3 -3
  227. package/packages/dd-trace/src/datastreams/schemas/schema_builder.js +1 -1
  228. package/packages/dd-trace/src/datastreams/writer.js +2 -2
  229. package/packages/dd-trace/src/debugger/config.js +1 -0
  230. package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +15 -5
  231. package/packages/dd-trace/src/debugger/devtools_client/condition.js +1 -1
  232. package/packages/dd-trace/src/debugger/devtools_client/config.js +3 -1
  233. package/packages/dd-trace/src/debugger/devtools_client/index.js +37 -17
  234. package/packages/dd-trace/src/debugger/devtools_client/inspector_promises_polyfill.js +2 -0
  235. package/packages/dd-trace/src/debugger/devtools_client/json-buffer.js +24 -18
  236. package/packages/dd-trace/src/debugger/devtools_client/send.js +21 -11
  237. package/packages/dd-trace/src/debugger/devtools_client/session.js +1 -1
  238. package/packages/dd-trace/src/debugger/devtools_client/snapshot/collector.js +103 -15
  239. package/packages/dd-trace/src/debugger/devtools_client/snapshot/constants.js +25 -0
  240. package/packages/dd-trace/src/debugger/devtools_client/snapshot/index.js +56 -25
  241. package/packages/dd-trace/src/debugger/devtools_client/snapshot/processor.js +64 -23
  242. package/packages/dd-trace/src/debugger/devtools_client/snapshot/symbols.js +3 -1
  243. package/packages/dd-trace/src/debugger/devtools_client/snapshot-pruner.js +404 -0
  244. package/packages/dd-trace/src/debugger/devtools_client/source-maps.js +1 -1
  245. package/packages/dd-trace/src/debugger/devtools_client/state.js +8 -3
  246. package/packages/dd-trace/src/debugger/devtools_client/status.js +3 -3
  247. package/packages/dd-trace/src/debugger/index.js +2 -2
  248. package/packages/dd-trace/src/dogstatsd.js +3 -2
  249. package/packages/dd-trace/src/encode/0.4.js +1 -1
  250. package/packages/dd-trace/src/encode/agentless-ci-visibility.js +2 -2
  251. package/packages/dd-trace/src/encode/coverage-ci-visibility.js +1 -1
  252. package/packages/dd-trace/src/encode/span-stats.js +13 -2
  253. package/packages/dd-trace/src/exporter.js +2 -2
  254. package/packages/dd-trace/src/exporters/agent/index.js +1 -1
  255. package/packages/dd-trace/src/exporters/common/agent-info-exporter.js +1 -1
  256. package/packages/dd-trace/src/exporters/common/request.js +2 -2
  257. package/packages/dd-trace/src/exporters/common/writer.js +1 -1
  258. package/packages/dd-trace/src/exporters/span-stats/index.js +1 -1
  259. package/packages/dd-trace/src/external-logger/src/index.js +1 -2
  260. package/packages/dd-trace/src/flare/index.js +1 -1
  261. package/packages/dd-trace/src/guardrails/index.js +6 -3
  262. package/packages/dd-trace/src/histogram.js +1 -1
  263. package/packages/dd-trace/src/id.js +60 -0
  264. package/packages/dd-trace/src/index.js +1 -1
  265. package/packages/dd-trace/src/lambda/handler.js +4 -4
  266. package/packages/dd-trace/src/lambda/index.js +1 -1
  267. package/packages/dd-trace/src/lambda/runtime/patch.js +4 -4
  268. package/packages/dd-trace/src/lambda/runtime/ritm.js +2 -2
  269. package/packages/dd-trace/src/llmobs/constants/tags.js +8 -1
  270. package/packages/dd-trace/src/llmobs/index.js +8 -9
  271. package/packages/dd-trace/src/llmobs/plugins/ai/index.js +38 -7
  272. package/packages/dd-trace/src/llmobs/plugins/ai/util.js +30 -9
  273. package/packages/dd-trace/src/llmobs/plugins/bedrockruntime.js +3 -3
  274. package/packages/dd-trace/src/llmobs/plugins/genai/index.js +104 -0
  275. package/packages/dd-trace/src/llmobs/plugins/genai/util.js +486 -0
  276. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chain.js +1 -1
  277. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chat_model.js +1 -1
  278. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/embedding.js +1 -1
  279. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/llm.js +1 -1
  280. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/vectorstore.js +1 -1
  281. package/packages/dd-trace/src/llmobs/plugins/langchain/index.js +2 -2
  282. package/packages/dd-trace/src/llmobs/plugins/openai/constants.js +16 -0
  283. package/packages/dd-trace/src/llmobs/plugins/{openai.js → openai/index.js} +63 -6
  284. package/packages/dd-trace/src/llmobs/plugins/openai/utils.js +126 -0
  285. package/packages/dd-trace/src/llmobs/plugins/vertexai.js +1 -1
  286. package/packages/dd-trace/src/llmobs/sdk.js +20 -22
  287. package/packages/dd-trace/src/llmobs/span_processor.js +15 -14
  288. package/packages/dd-trace/src/llmobs/tagger.js +4 -0
  289. package/packages/dd-trace/src/llmobs/telemetry.js +3 -4
  290. package/packages/dd-trace/src/llmobs/writers/base.js +2 -2
  291. package/packages/dd-trace/src/llmobs/writers/spans.js +1 -2
  292. package/packages/dd-trace/src/log/index.js +1 -1
  293. package/packages/dd-trace/src/noop/proxy.js +2 -2
  294. package/packages/dd-trace/src/noop/span.js +1 -1
  295. package/packages/dd-trace/src/openfeature/index.js +2 -2
  296. package/packages/dd-trace/src/openfeature/noop.js +14 -14
  297. package/packages/dd-trace/src/openfeature/remote_config.js +31 -0
  298. package/packages/dd-trace/src/openfeature/writers/base.js +5 -5
  299. package/packages/dd-trace/src/openfeature/writers/exposures.js +9 -9
  300. package/packages/dd-trace/src/opentelemetry/context_manager.js +2 -2
  301. package/packages/dd-trace/src/opentelemetry/logs/index.js +2 -2
  302. package/packages/dd-trace/src/opentelemetry/logs/logger.js +3 -2
  303. package/packages/dd-trace/src/opentelemetry/logs/logger_provider.js +4 -4
  304. package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +5 -3
  305. package/packages/dd-trace/src/opentelemetry/logs/otlp_transformer.js +17 -16
  306. package/packages/dd-trace/src/opentelemetry/metrics/constants.js +34 -0
  307. package/packages/dd-trace/src/opentelemetry/metrics/index.js +81 -0
  308. package/packages/dd-trace/src/opentelemetry/metrics/instruments.js +225 -0
  309. package/packages/dd-trace/src/opentelemetry/metrics/meter.js +171 -0
  310. package/packages/dd-trace/src/opentelemetry/metrics/meter_provider.js +54 -0
  311. package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +62 -0
  312. package/packages/dd-trace/src/opentelemetry/metrics/otlp_transformer.js +251 -0
  313. package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +557 -0
  314. package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +10 -18
  315. package/packages/dd-trace/src/opentelemetry/otlp/otlp_transformer_base.js +47 -32
  316. package/packages/dd-trace/src/opentelemetry/otlp/protobuf_loader.js +1 -1
  317. package/packages/dd-trace/src/opentelemetry/span.js +3 -3
  318. package/packages/dd-trace/src/opentelemetry/tracer.js +4 -4
  319. package/packages/dd-trace/src/opentelemetry/tracer_provider.js +1 -1
  320. package/packages/dd-trace/src/opentracing/propagation/text_map.js +24 -8
  321. package/packages/dd-trace/src/opentracing/span.js +3 -3
  322. package/packages/dd-trace/src/opentracing/tracer.js +5 -5
  323. package/packages/dd-trace/src/payload-tagging/index.js +8 -4
  324. package/packages/dd-trace/src/plugin_manager.js +5 -3
  325. package/packages/dd-trace/src/plugins/apollo.js +1 -1
  326. package/packages/dd-trace/src/plugins/ci_plugin.js +27 -27
  327. package/packages/dd-trace/src/plugins/database.js +1 -1
  328. package/packages/dd-trace/src/plugins/index.js +6 -1
  329. package/packages/dd-trace/src/plugins/log_plugin.js +1 -1
  330. package/packages/dd-trace/src/plugins/outbound.js +1 -1
  331. package/packages/dd-trace/src/plugins/tracing.js +1 -1
  332. package/packages/dd-trace/src/plugins/util/ci.js +1 -1
  333. package/packages/dd-trace/src/plugins/util/git.js +8 -8
  334. package/packages/dd-trace/src/plugins/util/stacktrace.js +1 -1
  335. package/packages/dd-trace/src/plugins/util/test.js +27 -27
  336. package/packages/dd-trace/src/plugins/util/url.js +119 -1
  337. package/packages/dd-trace/src/plugins/util/user-provided-git.js +1 -1
  338. package/packages/dd-trace/src/plugins/util/web.js +18 -46
  339. package/packages/dd-trace/src/priority_sampler.js +15 -16
  340. package/packages/dd-trace/src/process-tags/index.js +83 -0
  341. package/packages/dd-trace/src/profiling/config.js +33 -22
  342. package/packages/dd-trace/src/profiling/exporter_cli.js +4 -4
  343. package/packages/dd-trace/src/profiling/exporters/agent.js +5 -5
  344. package/packages/dd-trace/src/profiling/index.js +1 -1
  345. package/packages/dd-trace/src/profiling/libuv-size.js +1 -1
  346. package/packages/dd-trace/src/profiling/profiler.js +4 -5
  347. package/packages/dd-trace/src/profiling/profilers/event_plugins/event.js +1 -1
  348. package/packages/dd-trace/src/profiling/profilers/events.js +11 -2
  349. package/packages/dd-trace/src/profiling/profilers/wall.js +4 -4
  350. package/packages/dd-trace/src/proxy.js +17 -18
  351. package/packages/dd-trace/src/rate_limiter.js +1 -1
  352. package/packages/dd-trace/src/remote_config/index.js +541 -137
  353. package/packages/dd-trace/src/require-package-json.js +1 -1
  354. package/packages/dd-trace/src/ritm.js +50 -27
  355. package/packages/dd-trace/src/runtime_metrics/runtime_metrics.js +1 -1
  356. package/packages/dd-trace/src/serverless.js +16 -0
  357. package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +8 -0
  358. package/packages/dd-trace/src/service-naming/schemas/v0/web.js +4 -0
  359. package/packages/dd-trace/src/service-naming/schemas/v1/messaging.js +8 -0
  360. package/packages/dd-trace/src/service-naming/schemas/v1/web.js +4 -0
  361. package/packages/dd-trace/src/span_format.js +10 -5
  362. package/packages/dd-trace/src/span_processor.js +8 -3
  363. package/packages/dd-trace/src/span_stats.js +21 -8
  364. package/packages/dd-trace/src/spanleak.js +1 -1
  365. package/packages/dd-trace/src/standalone/index.js +1 -1
  366. package/packages/dd-trace/src/startup-log.js +3 -3
  367. package/packages/dd-trace/src/supported-configurations.json +16 -0
  368. package/packages/dd-trace/src/telemetry/dependencies.js +4 -4
  369. package/packages/dd-trace/src/telemetry/endpoints.js +8 -8
  370. package/packages/dd-trace/src/telemetry/logs/index.js +1 -1
  371. package/packages/dd-trace/src/telemetry/telemetry.js +22 -8
  372. package/packages/dd-trace/src/tracer.js +3 -3
  373. package/packages/dd-trace/src/tracer_metadata.js +19 -15
  374. package/vendor/dist/@datadog/sketches-js/LICENSE +39 -0
  375. package/vendor/dist/@datadog/sketches-js/index.js +1 -0
  376. package/vendor/dist/@datadog/source-map/LICENSE +28 -0
  377. package/vendor/dist/@datadog/source-map/index.js +1 -0
  378. package/vendor/dist/@isaacs/ttlcache/LICENSE +55 -0
  379. package/vendor/dist/@isaacs/ttlcache/index.js +1 -0
  380. package/vendor/dist/@opentelemetry/core/LICENSE +201 -0
  381. package/vendor/dist/@opentelemetry/core/index.js +1 -0
  382. package/vendor/dist/@opentelemetry/resources/LICENSE +201 -0
  383. package/vendor/dist/@opentelemetry/resources/index.js +1 -0
  384. package/vendor/dist/astring/LICENSE +19 -0
  385. package/vendor/dist/astring/index.js +1 -0
  386. package/vendor/dist/crypto-randomuuid/index.js +1 -0
  387. package/vendor/dist/escape-string-regexp/LICENSE +9 -0
  388. package/vendor/dist/escape-string-regexp/index.js +1 -0
  389. package/vendor/dist/esquery/LICENSE +24 -0
  390. package/vendor/dist/esquery/index.js +1 -0
  391. package/vendor/dist/ignore/LICENSE +21 -0
  392. package/vendor/dist/ignore/index.js +1 -0
  393. package/vendor/dist/istanbul-lib-coverage/LICENSE +24 -0
  394. package/vendor/dist/istanbul-lib-coverage/index.js +1 -0
  395. package/vendor/dist/jest-docblock/LICENSE +21 -0
  396. package/vendor/dist/jest-docblock/index.js +1 -0
  397. package/vendor/dist/jsonpath-plus/LICENSE +22 -0
  398. package/vendor/dist/jsonpath-plus/index.js +1 -0
  399. package/vendor/dist/limiter/LICENSE +19 -0
  400. package/vendor/dist/limiter/index.js +1 -0
  401. package/vendor/dist/lodash.sortby/LICENSE +47 -0
  402. package/vendor/dist/lodash.sortby/index.js +1 -0
  403. package/vendor/dist/lru-cache/LICENSE +15 -0
  404. package/vendor/dist/lru-cache/index.js +1 -0
  405. package/vendor/dist/meriyah/LICENSE +7 -0
  406. package/vendor/dist/meriyah/index.js +1 -0
  407. package/vendor/dist/module-details-from-path/LICENSE +21 -0
  408. package/vendor/dist/module-details-from-path/index.js +1 -0
  409. package/vendor/dist/mutexify/promise/LICENSE +21 -0
  410. package/vendor/dist/mutexify/promise/index.js +1 -0
  411. package/vendor/dist/opentracing/LICENSE +201 -0
  412. package/vendor/dist/opentracing/binary_carrier.d.ts +11 -0
  413. package/vendor/dist/opentracing/constants.d.ts +61 -0
  414. package/vendor/dist/opentracing/examples/demo/demo.d.ts +2 -0
  415. package/vendor/dist/opentracing/ext/tags.d.ts +90 -0
  416. package/vendor/dist/opentracing/functions.d.ts +20 -0
  417. package/vendor/dist/opentracing/global_tracer.d.ts +14 -0
  418. package/vendor/dist/opentracing/index.d.ts +12 -0
  419. package/vendor/dist/opentracing/index.js +1 -0
  420. package/vendor/dist/opentracing/mock_tracer/index.d.ts +5 -0
  421. package/vendor/dist/opentracing/mock_tracer/mock_context.d.ts +13 -0
  422. package/vendor/dist/opentracing/mock_tracer/mock_report.d.ts +16 -0
  423. package/vendor/dist/opentracing/mock_tracer/mock_span.d.ts +50 -0
  424. package/vendor/dist/opentracing/mock_tracer/mock_tracer.d.ts +26 -0
  425. package/vendor/dist/opentracing/noop.d.ts +8 -0
  426. package/vendor/dist/opentracing/reference.d.ts +33 -0
  427. package/vendor/dist/opentracing/span.d.ts +147 -0
  428. package/vendor/dist/opentracing/span_context.d.ts +26 -0
  429. package/vendor/dist/opentracing/test/api_compatibility.d.ts +16 -0
  430. package/vendor/dist/opentracing/test/mocktracer_implemenation.d.ts +3 -0
  431. package/vendor/dist/opentracing/test/noop_implementation.d.ts +4 -0
  432. package/vendor/dist/opentracing/test/opentracing_api.d.ts +3 -0
  433. package/vendor/dist/opentracing/test/unittest.d.ts +2 -0
  434. package/vendor/dist/opentracing/tracer.d.ts +127 -0
  435. package/vendor/dist/path-to-regexp/LICENSE +21 -0
  436. package/vendor/dist/path-to-regexp/index.js +1 -0
  437. package/vendor/dist/pprof-format/LICENSE +8 -0
  438. package/vendor/dist/pprof-format/index.js +1 -0
  439. package/vendor/dist/protobufjs/LICENSE +39 -0
  440. package/vendor/dist/protobufjs/index.js +1 -0
  441. package/vendor/dist/protobufjs/minimal/LICENSE +39 -0
  442. package/vendor/dist/protobufjs/minimal/index.js +1 -0
  443. package/vendor/dist/retry/LICENSE +21 -0
  444. package/vendor/dist/retry/index.js +1 -0
  445. package/vendor/dist/rfdc/LICENSE +15 -0
  446. package/vendor/dist/rfdc/index.js +1 -0
  447. package/vendor/dist/semifies/LICENSE +201 -0
  448. package/vendor/dist/semifies/index.js +1 -0
  449. package/vendor/dist/shell-quote/LICENSE +24 -0
  450. package/vendor/dist/shell-quote/index.js +1 -0
  451. package/vendor/dist/source-map/LICENSE +28 -0
  452. package/vendor/dist/source-map/index.js +1 -0
  453. package/vendor/dist/source-map/lib/util/LICENSE +28 -0
  454. package/vendor/dist/source-map/lib/util/index.js +1 -0
  455. package/vendor/dist/source-map/mappings.wasm +0 -0
  456. package/vendor/dist/tlhunter-sorted-set/LICENSE +21 -0
  457. package/vendor/dist/tlhunter-sorted-set/index.js +1 -0
  458. package/vendor/dist/ttl-set/LICENSE +21 -0
  459. package/vendor/dist/ttl-set/index.js +1 -0
  460. package/packages/dd-trace/src/remote_config/manager.js +0 -368
@@ -4,8 +4,8 @@ const { readFile } = require('fs')
4
4
  const { types } = require('util')
5
5
  const { join } = require('path')
6
6
  const { Worker, MessageChannel, threadId: parentThreadId } = require('worker_threads')
7
- const getDebuggerConfig = require('./config')
8
7
  const log = require('../log')
8
+ const getDebuggerConfig = require('./config')
9
9
 
10
10
  let worker = null
11
11
  let configChannel = null
@@ -89,7 +89,7 @@ function start (config, rc) {
89
89
 
90
90
  log.error('[debugger] worker thread exited unexpectedly', error)
91
91
 
92
- // Be nice, clean up now that the worker thread encounted an issue and we can't continue
92
+ // Be nice, clean up now that the worker thread encountered an issue and we can't continue
93
93
  rc.removeProductHandler('LIVE_DEBUGGING')
94
94
  worker.removeAllListeners()
95
95
  configChannel = null
@@ -1,11 +1,12 @@
1
1
  'use strict'
2
2
 
3
3
  const lookup = require('dns').lookup // cache to avoid instrumentation
4
- const request = require('./exporters/common/request')
5
4
  const dgram = require('dgram')
6
5
  const isIP = require('net').isIP
7
- const log = require('./log')
8
6
  const { URL, format } = require('url')
7
+
8
+ const request = require('./exporters/common/request')
9
+ const log = require('./log')
9
10
  const Histogram = require('./histogram')
10
11
  const defaults = require('./config_defaults')
11
12
 
@@ -1,11 +1,11 @@
1
1
  'use strict'
2
2
 
3
- const { truncateSpan, normalizeSpan } = require('./tags-processors')
4
3
  const { MsgpackChunk, MsgpackEncoder } = require('../msgpack')
5
4
  const log = require('../log')
6
5
  const { isTrue } = require('../util')
7
6
  const { memoize } = require('../log/utils')
8
7
  const { getEnvironmentVariable } = require('../config-helper')
8
+ const { truncateSpan, normalizeSpan } = require('./tags-processors')
9
9
 
10
10
  const SOFT_LIMIT = 8 * 1024 * 1024 // 8MB
11
11
 
@@ -1,6 +1,4 @@
1
1
  'use strict'
2
- const { truncateSpan, normalizeSpan } = require('./tags-processors')
3
- const { AgentEncoder } = require('./0.4')
4
2
  const { version: ddTraceVersion } = require('../../../../package.json')
5
3
  const { ITR_CORRELATION_ID } = require('../../src/plugins/util/test')
6
4
  const id = require('../../src/id')
@@ -9,6 +7,8 @@ const {
9
7
  TELEMETRY_ENDPOINT_PAYLOAD_SERIALIZATION_MS,
10
8
  TELEMETRY_ENDPOINT_PAYLOAD_EVENTS_COUNT
11
9
  } = require('../ci-visibility/telemetry')
10
+ const { AgentEncoder } = require('./0.4')
11
+ const { truncateSpan, normalizeSpan } = require('./tags-processors')
12
12
 
13
13
  const ENCODING_VERSION = 1
14
14
  const ALLOWED_CONTENT_TYPES = new Set(['test_session_end', 'test_module_end', 'test_suite_end', 'test'])
@@ -1,5 +1,4 @@
1
1
  'use strict'
2
- const { AgentEncoder } = require('./0.4')
3
2
  const { MsgpackChunk } = require('../msgpack')
4
3
 
5
4
  const {
@@ -8,6 +7,7 @@ const {
8
7
  TELEMETRY_ENDPOINT_PAYLOAD_EVENTS_COUNT
9
8
  } = require('../ci-visibility/telemetry')
10
9
  const FormData = require('../exporters/common/form-data')
10
+ const { AgentEncoder } = require('./0.4')
11
11
 
12
12
  const COVERAGE_PAYLOAD_VERSION = 2
13
13
  const COVERAGE_KEYS_LENGTH = 2
@@ -31,7 +31,7 @@ class SpanStatsEncoder extends AgentEncoder {
31
31
  }
32
32
 
33
33
  _encodeStat (bytes, stat) {
34
- this._encodeMapPrefix(bytes, 12)
34
+ this._encodeMapPrefix(bytes, 14)
35
35
 
36
36
  this._encodeString(bytes, 'Service')
37
37
  const service = stat.Service || DEFAULT_SERVICE_NAME
@@ -70,6 +70,12 @@ class SpanStatsEncoder extends AgentEncoder {
70
70
 
71
71
  this._encodeString(bytes, 'TopLevelHits')
72
72
  this._encodeLong(bytes, stat.TopLevelHits)
73
+
74
+ this._encodeString(bytes, 'HTTPMethod')
75
+ this._encodeString(bytes, stat.HTTPMethod)
76
+
77
+ this._encodeString(bytes, 'HTTPEndpoint')
78
+ this._encodeString(bytes, stat.HTTPEndpoint)
73
79
  }
74
80
 
75
81
  _encodeBucket (bytes, bucket) {
@@ -89,7 +95,7 @@ class SpanStatsEncoder extends AgentEncoder {
89
95
  }
90
96
 
91
97
  _encode (bytes, stats) {
92
- this._encodeMapPrefix(bytes, 8)
98
+ this._encodeMapPrefix(bytes, stats.ProcessTags ? 9 : 8)
93
99
 
94
100
  this._encodeString(bytes, 'Hostname')
95
101
  this._encodeString(bytes, stats.Hostname)
@@ -117,6 +123,11 @@ class SpanStatsEncoder extends AgentEncoder {
117
123
 
118
124
  this._encodeString(bytes, 'Sequence')
119
125
  this._encodeLong(bytes, stats.Sequence)
126
+
127
+ if (stats.ProcessTags) {
128
+ this._encodeString(bytes, 'ProcessTags')
129
+ this._encodeString(bytes, stats.ProcessTags)
130
+ }
120
131
  }
121
132
  }
122
133
 
@@ -1,9 +1,9 @@
1
1
  'use strict'
2
2
 
3
- const exporters = require('../../../ext/exporters')
4
3
  const fs = require('fs')
5
- const constants = require('./constants')
4
+ const exporters = require('../../../ext/exporters')
6
5
  const { getEnvironmentVariable } = require('../../dd-trace/src/config-helper')
6
+ const constants = require('./constants')
7
7
 
8
8
  module.exports = function getExporter (name) {
9
9
  switch (name) {
@@ -2,8 +2,8 @@
2
2
 
3
3
  const { URL, format } = require('url')
4
4
  const log = require('../../log')
5
- const Writer = require('./writer')
6
5
  const defaults = require('../../config_defaults')
6
+ const Writer = require('./writer')
7
7
 
8
8
  class AgentExporter {
9
9
  #timer
@@ -2,9 +2,9 @@
2
2
 
3
3
  const { URL, format } = require('url')
4
4
 
5
- const request = require('./request')
6
5
  const defaults = require('../../config_defaults')
7
6
  const { incrementCountMetric, TELEMETRY_EVENTS_ENQUEUED_FOR_SERIALIZATION } = require('../../ci-visibility/telemetry')
7
+ const request = require('./request')
8
8
 
9
9
  function fetchAgentInfo (url, callback) {
10
10
  request('', {
@@ -8,11 +8,11 @@ const http = require('http')
8
8
  const https = require('https')
9
9
  const zlib = require('zlib')
10
10
 
11
+ const { storage } = require('../../../../datadog-core')
12
+ const log = require('../../log')
11
13
  const { urlToHttpOptions } = require('./url-to-http-options-polyfill')
12
14
  const docker = require('./docker')
13
15
  const { httpAgent, httpsAgent } = require('./agents')
14
- const { storage } = require('../../../../datadog-core')
15
- const log = require('../../log')
16
16
 
17
17
  const maxActiveRequests = 8
18
18
 
@@ -1,7 +1,7 @@
1
1
  'use strict'
2
2
 
3
- const request = require('./request')
4
3
  const log = require('../../log')
4
+ const request = require('./request')
5
5
  const { safeJSONStringify } = require('./util')
6
6
 
7
7
  class Writer {
@@ -2,8 +2,8 @@
2
2
 
3
3
  const { URL, format } = require('url')
4
4
 
5
- const { Writer } = require('./writer')
6
5
  const defaults = require('../../config_defaults')
6
+ const { Writer } = require('./writer')
7
7
 
8
8
  class SpanStatsExporter {
9
9
  constructor (config) {
@@ -1,8 +1,7 @@
1
1
  'use strict'
2
2
 
3
- const tracerLogger = require('../../log')// path to require tracer logger
4
-
5
3
  const https = require('https')
4
+ const tracerLogger = require('../../log')// path to require tracer logger
6
5
 
7
6
  class ExternalLogger {
8
7
  // Note: these attribute names match the corresponding entry in the JSON payload.
@@ -2,10 +2,10 @@
2
2
 
3
3
  const log = require('../log')
4
4
  const startupLog = require('../startup-log')
5
- const FlareFile = require('./file')
6
5
  const { LogChannel } = require('../log/channels')
7
6
  const request = require('../exporters/common/request')
8
7
  const FormData = require('../exporters/common/form-data')
8
+ const FlareFile = require('./file')
9
9
 
10
10
  const MAX_LOG_SIZE = 12 * 1024 * 1024 // 12MB soft limit
11
11
  const TIMEOUT = 20 * 1000 * 60
@@ -2,10 +2,11 @@
2
2
 
3
3
  var path = require('path')
4
4
  var Module = require('module')
5
+
6
+ var nodeVersion = require('../../../../version')
5
7
  var isTrue = require('./util').isTrue
6
8
  var log = require('./log')
7
9
  var telemetry = require('./telemetry')
8
- var nodeVersion = require('../../../../version')
9
10
 
10
11
  var NODE_MAJOR = nodeVersion.NODE_MAJOR
11
12
 
@@ -14,7 +15,9 @@ function guard (fn) {
14
15
  var clobberBailout = false
15
16
  var forced = isTrue(process.env.DD_INJECT_FORCE)
16
17
  var engines = require('../../../../package.json').engines
17
- var minMajor = parseInt(engines.node.replace(/[^0-9]/g, ''))
18
+ var versions = engines.node.match(/^>=(\d+) <(\d+)$/)
19
+ var minMajor = versions[1]
20
+ var nextMajor = versions[2]
18
21
  var version = process.versions.node
19
22
 
20
23
  if (process.env.DD_INJECTION_ENABLED) {
@@ -40,7 +43,7 @@ function guard (fn) {
40
43
 
41
44
  // If the runtime doesn't match the engines field in package.json, then we
42
45
  // should not initialize the tracer.
43
- if (!clobberBailout && NODE_MAJOR < minMajor) {
46
+ if (!clobberBailout && (NODE_MAJOR < minMajor || NODE_MAJOR >= nextMajor)) {
44
47
  initBailout = true
45
48
  telemetry([
46
49
  { name: 'abort', tags: ['reason:incompatible_runtime'] },
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const { DDSketch } = require('@datadog/sketches-js')
3
+ const { DDSketch } = require('../../../vendor/dist/@datadog/sketches-js')
4
4
 
5
5
  class Histogram {
6
6
  constructor () {
@@ -14,26 +14,43 @@ let batch = 0
14
14
 
15
15
  // Internal representation of a trace or span ID.
16
16
  class Identifier {
17
+ /**
18
+ * @param {string} value
19
+ * @param {number} [radix]
20
+ */
17
21
  constructor (value, radix = 16) {
18
22
  this._buffer = radix === 16
19
23
  ? createBuffer(value)
20
24
  : fromString(value, radix)
21
25
  }
22
26
 
27
+ /**
28
+ * @param {number} [radix]
29
+ * @returns {string}
30
+ */
23
31
  toString (radix = 16) {
24
32
  return radix === 16
25
33
  ? toHexString(this._buffer)
26
34
  : toNumberString(this._buffer, radix)
27
35
  }
28
36
 
37
+ /**
38
+ * @returns {bigint}
39
+ */
29
40
  toBigInt () {
30
41
  return Buffer.from(this._buffer).readBigUInt64BE(0)
31
42
  }
32
43
 
44
+ /**
45
+ * @returns {number[] | Uint8Array}
46
+ */
33
47
  toBuffer () {
34
48
  return this._buffer
35
49
  }
36
50
 
51
+ /**
52
+ * @returns {number[] | Uint8Array}
53
+ */
37
54
  toArray () {
38
55
  if (this._buffer.length === 8) {
39
56
  return this._buffer
@@ -41,10 +58,17 @@ class Identifier {
41
58
  return this._buffer.slice(-8)
42
59
  }
43
60
 
61
+ /**
62
+ * @returns {string}
63
+ */
44
64
  toJSON () {
45
65
  return this.toString()
46
66
  }
47
67
 
68
+ /**
69
+ * @param {Identifier} other
70
+ * @returns {boolean}
71
+ */
48
72
  equals (other) {
49
73
  const length = this._buffer.length
50
74
  const otherLength = other._buffer.length
@@ -59,6 +83,10 @@ class Identifier {
59
83
  }
60
84
 
61
85
  // Create a buffer, using an optional hexadecimal value if provided.
86
+ /**
87
+ * @param {string} value
88
+ * @returns {number[] | Uint8Array}
89
+ */
62
90
  function createBuffer (value) {
63
91
  if (value === '0') return zeroId
64
92
  if (!value) return pseudoRandom()
@@ -77,6 +105,11 @@ function createBuffer (value) {
77
105
  }
78
106
 
79
107
  // Convert a numerical string to a buffer using the specified radix.
108
+ /**
109
+ * @param {string} str
110
+ * @param {number} raddix
111
+ * @returns {number[]}
112
+ */
80
113
  function fromString (str, raddix) {
81
114
  const buffer = new Array(8)
82
115
  const len = str.length
@@ -116,6 +149,11 @@ function fromString (str, raddix) {
116
149
  }
117
150
 
118
151
  // Convert a buffer to a numerical string.
152
+ /**
153
+ * @param {number[] | Uint8Array} buffer
154
+ * @param {number} [radix]
155
+ * @returns {string}
156
+ */
119
157
  function toNumberString (buffer, radix) {
120
158
  let high = readInt32(buffer, buffer.length - 8)
121
159
  let low = readInt32(buffer, buffer.length - 4)
@@ -137,11 +175,18 @@ function toNumberString (buffer, radix) {
137
175
  }
138
176
 
139
177
  // Convert a buffer to a hexadecimal string.
178
+ /**
179
+ * @param {number[] | Uint8Array} buffer
180
+ * @returns {string}
181
+ */
140
182
  function toHexString (buffer) {
141
183
  return map.call(buffer, pad).join('')
142
184
  }
143
185
 
144
186
  // Simple pseudo-random 64-bit ID generator.
187
+ /**
188
+ * @returns {number[] | Uint8Array}
189
+ */
145
190
  function pseudoRandom () {
146
191
  if (batch === 0) {
147
192
  randomFillSync(data)
@@ -164,6 +209,11 @@ function pseudoRandom () {
164
209
  }
165
210
 
166
211
  // Read a buffer to unsigned integer bytes.
212
+ /**
213
+ * @param {number[] | Uint8Array} buffer
214
+ * @param {number} offset
215
+ * @returns {number}
216
+ */
167
217
  function readInt32 (buffer, offset) {
168
218
  return (buffer[offset + 0] * 16_777_216) +
169
219
  (buffer[offset + 1] << 16) +
@@ -172,6 +222,11 @@ function readInt32 (buffer, offset) {
172
222
  }
173
223
 
174
224
  // Write unsigned integer bytes to a buffer.
225
+ /**
226
+ * @param {number[] | Uint8Array} buffer
227
+ * @param {number} value
228
+ * @param {number} offset
229
+ */
175
230
  function writeUInt32BE (buffer, value, offset) {
176
231
  buffer[3 + offset] = value & 255
177
232
  value >>= 8
@@ -182,6 +237,11 @@ function writeUInt32BE (buffer, value, offset) {
182
237
  buffer[0 + offset] = value & 255
183
238
  }
184
239
 
240
+ /**
241
+ * @param {string} [value]
242
+ * @param {number} [radix]
243
+ * @returns {Identifier}
244
+ */
185
245
  module.exports = function createIdentifier (value, radix) {
186
246
  return new Identifier(value, radix)
187
247
  }
@@ -1,7 +1,7 @@
1
1
  'use strict'
2
2
 
3
- const { isFalse } = require('./util')
4
3
  const { getEnvironmentVariable } = require('../../dd-trace/src/config-helper')
4
+ const { isFalse } = require('./util')
5
5
 
6
6
  // Global `jest` is only present in Jest workers.
7
7
  const inJestWorker = typeof jest !== 'undefined'
@@ -3,8 +3,8 @@
3
3
  const log = require('../log')
4
4
  const { channel } = require('../../../datadog-instrumentations/src/helpers/instrument')
5
5
  const { ERROR_MESSAGE, ERROR_TYPE } = require('../constants')
6
- const { ImpendingTimeout } = require('./runtime/errors')
7
6
  const { getEnvironmentVariable } = require('../config-helper')
7
+ const { ImpendingTimeout } = require('./runtime/errors')
8
8
 
9
9
  const globalTracer = global._ddtrace
10
10
  const tracer = globalTracer._tracer
@@ -21,7 +21,7 @@ let __lambdaTimeout
21
21
  * Publishes to the `apm:aws:lambda:timeout` channel when
22
22
  * the AWS Lambda run time is about to end.
23
23
  *
24
- * @param {*} context AWS Lambda context object.
24
+ * @param {object} context AWS Lambda context object.
25
25
  */
26
26
  function checkTimeout (context) {
27
27
  const remainingTimeInMillis = context.getRemainingTimeInMillis()
@@ -63,7 +63,7 @@ function crashFlush () {
63
63
  /**
64
64
  * Extracts the context from the given Lambda handler arguments.
65
65
  *
66
- * @param {*} args any amount of arguments
66
+ * @param {unknown[]} args any amount of arguments
67
67
  * @returns the context, if extraction was succesful.
68
68
  */
69
69
  function extractContext (args) {
@@ -80,7 +80,7 @@ function extractContext (args) {
80
80
  /**
81
81
  * Patches your AWS Lambda handler function to add some tracing support.
82
82
  *
83
- * @param {*} lambdaHandler a Lambda handler function.
83
+ * @param {Function} lambdaHandler a Lambda handler function.
84
84
  */
85
85
  exports.datadog = function datadog (lambdaHandler) {
86
86
  return (...args) => {
@@ -1,7 +1,7 @@
1
1
  'use strict'
2
2
 
3
- const { registerLambdaHook } = require('./runtime/ritm')
4
3
  const { getEnvironmentVariable } = require('../config-helper')
4
+ const { registerLambdaHook } = require('./runtime/ritm')
5
5
 
6
6
  /**
7
7
  * It is safe to do it this way, since customers will never be expected to disable
@@ -2,17 +2,17 @@
2
2
 
3
3
  const path = require('path')
4
4
 
5
- const { _extractModuleNameAndHandlerPath, _extractModuleRootAndHandler, _getLambdaFilePaths } = require('./ritm')
6
5
  const { datadog } = require('../handler')
7
6
  const { addHook } = require('../../../../datadog-instrumentations/src/helpers/instrument')
8
7
  const shimmer = require('../../../../datadog-shimmer')
9
8
  const { getEnvironmentVariable } = require('../../config-helper')
9
+ const { _extractModuleNameAndHandlerPath, _extractModuleRootAndHandler, _getLambdaFilePaths } = require('./ritm')
10
10
 
11
11
  /**
12
12
  * Patches a Datadog Lambda module by calling `patchDatadogLambdaHandler`
13
13
  * with the handler name `datadog`.
14
14
  *
15
- * @param {*} datadogLambdaModule node module to be patched.
15
+ * @param {object} datadogLambdaModule node module to be patched.
16
16
  * @returns a Datadog Lambda module with the `datadog` function from
17
17
  * `datadog-lambda-js` patched.
18
18
  */
@@ -27,7 +27,7 @@ const patchDatadogLambdaModule = (datadogLambdaModule) => {
27
27
  * Datadog instrumentation by getting the Lambda handler from its
28
28
  * arguments.
29
29
  *
30
- * @param {*} datadogHandler the Datadog Lambda handler to destructure.
30
+ * @param {Function} datadogHandler the Datadog Lambda handler to destructure.
31
31
  * @returns the datadogHandler with its arguments patched.
32
32
  */
33
33
  function patchDatadogLambdaHandler (datadogHandler) {
@@ -51,7 +51,7 @@ const patchLambdaModule = (handlerPath) => (lambdaModule) => {
51
51
  /**
52
52
  * Patches a Lambda handler in order to do Datadog instrumentation.
53
53
  *
54
- * @param {*} lambdaHandler the Lambda handler to be patched.
54
+ * @param {Function} lambdaHandler the Lambda handler to be patched.
55
55
  * @returns a function which patches the given Lambda handler.
56
56
  */
57
57
  function patchLambdaHandler (lambdaHandler) {
@@ -3,7 +3,7 @@
3
3
  * Modifications copyright 2022 Datadog, Inc.
4
4
  *
5
5
  * Some functions are part of aws-lambda-nodejs-runtime-interface-client
6
- * https://github.com/aws/aws-lambda-nodejs-runtime-interface-client/blob/main/src/utils/UserFunction.ts
6
+ * https://github.com/aws/aws-lambda-nodejs-runtime-interface-client/blob/v2.1.0/src/utils/UserFunction.ts
7
7
  */
8
8
  'use strict'
9
9
 
@@ -61,7 +61,7 @@ function _extractModuleNameAndHandlerPath (handler) {
61
61
  /**
62
62
  * Returns all possible paths of the files to be patched when required.
63
63
  *
64
- * @param {*} lambdaStylePath the path comprised of the `LAMBDA_TASK_ROOT`,
64
+ * @param {string} lambdaStylePath the path comprised of the `LAMBDA_TASK_ROOT`,
65
65
  * the root of the module of the Lambda handler, and the module name.
66
66
  * @returns the lambdaStylePath with appropiate extensions for the hook.
67
67
  */
@@ -34,6 +34,13 @@ module.exports = {
34
34
  TOTAL_TOKENS_METRIC_KEY: 'total_tokens',
35
35
  CACHE_READ_INPUT_TOKENS_METRIC_KEY: 'cache_read_input_tokens',
36
36
  CACHE_WRITE_INPUT_TOKENS_METRIC_KEY: 'cache_write_input_tokens',
37
+ REASONING_OUTPUT_TOKENS_METRIC_KEY: 'reasoning_output_tokens',
37
38
 
38
- DROPPED_IO_COLLECTION_ERROR: 'dropped_io'
39
+ DROPPED_IO_COLLECTION_ERROR: 'dropped_io',
40
+
41
+ PROMPT_TRACKING_INSTRUMENTATION_METHOD: 'prompt_tracking_instrumentation_method',
42
+ PROMPT_MULTIMODAL: 'prompt_multimodal',
43
+ INSTRUMENTATION_METHOD_AUTO: 'auto',
44
+ INSTRUMENTATION_METHOD_ANNOTATED: 'annotated',
45
+ INSTRUMENTATION_METHOD_UNKNOWN: 'unknown'
39
46
  }
@@ -1,5 +1,9 @@
1
1
  'use strict'
2
2
 
3
+ const util = require('node:util')
4
+
5
+ const { channel } = require('dc-polyfill')
6
+
3
7
  const log = require('../log')
4
8
  const {
5
9
  ML_APP,
@@ -7,24 +11,19 @@ const {
7
11
  PROPAGATED_PARENT_ID_KEY
8
12
  } = require('./constants/tags')
9
13
  const { storage } = require('./storage')
10
-
11
14
  const telemetry = require('./telemetry')
12
15
  const LLMObsSpanProcessor = require('./span_processor')
16
+ const LLMObsEvalMetricsWriter = require('./writers/evaluations')
17
+ const LLMObsTagger = require('./tagger')
18
+ const LLMObsSpanWriter = require('./writers/spans')
19
+ const { setAgentStrategy } = require('./writers/util')
13
20
 
14
- const { channel } = require('dc-polyfill')
15
21
  const spanFinishCh = channel('dd-trace:span:finish')
16
22
  const evalMetricAppendCh = channel('llmobs:eval-metric:append')
17
23
  const flushCh = channel('llmobs:writers:flush')
18
24
  const injectCh = channel('dd-trace:span:inject')
19
25
  const registerUserSpanProcessorCh = channel('llmobs:register-processor')
20
26
 
21
- const LLMObsEvalMetricsWriter = require('./writers/evaluations')
22
- const LLMObsTagger = require('./tagger')
23
- const LLMObsSpanWriter = require('./writers/spans')
24
- const { setAgentStrategy } = require('./writers/util')
25
-
26
- const util = require('node:util')
27
-
28
27
  /**
29
28
  * Setting writers and processor globally when LLMObs is enabled
30
29
  * We're setting these in this module instead of on the SDK.
@@ -1,10 +1,9 @@
1
1
  'use strict'
2
2
 
3
+ const { channel } = require('dc-polyfill')
3
4
  const BaseLLMObsPlugin = require('../base')
4
5
  const { getModelProvider } = require('../../../../../datadog-plugin-ai/src/utils')
5
6
 
6
- const { channel } = require('dc-polyfill')
7
-
8
7
  const toolCreationCh = channel('dd-trace:vercel-ai:tool')
9
8
  const setAttributesCh = channel('dd-trace:vercel-ai:span:setAttributes')
10
9
 
@@ -21,6 +20,38 @@ const {
21
20
  getLlmObsSpanName
22
21
  } = require('./util')
23
22
 
23
+ /**
24
+ * @typedef {Record<string, unknown> & { description?: string, id?: string }} AvailableToolArgs
25
+ */
26
+
27
+ /**
28
+ * @typedef {string | number | boolean | null | undefined | string[] | number[] | boolean[]} TagValue
29
+ * @typedef {Record<string, TagValue>} SpanTags
30
+ *
31
+ * @typedef {{ name?: string, description?: string }} ToolForModel
32
+ *
33
+ * @typedef {{ type: 'text' | 'reasoning' | 'redacted-reasoning', text?: string, data?: string }} TextPart
34
+ * @typedef {{ type: 'tool-call', toolName: string, toolCallId: string, args?: unknown, input?: unknown }} ToolCallPart
35
+ * @typedef {(
36
+ * { type: 'tool-result', toolCallId: string, output?: { type: string, value?: unknown }, result?: unknown } &
37
+ * Record<string, unknown>
38
+ * )} ToolResultPart
39
+ *
40
+ * @typedef {{
41
+ * role: 'system',
42
+ * content: string
43
+ * } | {
44
+ * role: 'user',
45
+ * content: TextPart[]
46
+ * } | {
47
+ * role: 'assistant',
48
+ * content: Array<TextPart | ToolCallPart>
49
+ * } | {
50
+ * role: 'tool',
51
+ * content: ToolResultPart[]
52
+ * }} AiSdkMessage
53
+ */
54
+
24
55
  const SPAN_NAME_TO_KIND_MAPPING = {
25
56
  // embeddings
26
57
  embed: 'workflow',
@@ -47,7 +78,7 @@ class VercelAILLMObsPlugin extends BaseLLMObsPlugin {
47
78
  /**
48
79
  * The available tools within the runtime scope of this integration.
49
80
  * This essentially acts as a global registry for all tools made through the Vercel AI SDK.
50
- * @type {Set<Record<string, any>>}
81
+ * @type {Set<AvailableToolArgs>}
51
82
  */
52
83
  #availableTools
53
84
 
@@ -80,7 +111,7 @@ class VercelAILLMObsPlugin extends BaseLLMObsPlugin {
80
111
  * We use the tool description as the next best identifier for a tool.
81
112
  *
82
113
  * @param {string} toolName
83
- * @param {string} toolDescription
114
+ * @param {string | undefined} toolDescription
84
115
  * @returns {string | undefined}
85
116
  */
86
117
  findToolName (toolName, toolDescription) {
@@ -223,7 +254,7 @@ class VercelAILLMObsPlugin extends BaseLLMObsPlugin {
223
254
 
224
255
  /**
225
256
  * @param {import('../../../opentracing/span')} span
226
- * @param {Record<string, unknown>} tags
257
+ * @param {SpanTags} tags
227
258
  */
228
259
  setLLMOperationTags (span, tags) {
229
260
  const toolsForModel = tags['ai.prompt.tools']?.map(getJsonStringValue)
@@ -290,8 +321,8 @@ class VercelAILLMObsPlugin extends BaseLLMObsPlugin {
290
321
  * it is possible to have multiple tool call results in a single message that we
291
322
  * need to split into multiple messages.
292
323
  *
293
- * @param {*} message
294
- * @param {*} toolsForModel
324
+ * @param {AiSdkMessage} message
325
+ * @param {ToolForModel[] | null | undefined} toolsForModel
295
326
  * @returns {Array<{role: string, content: string, toolId?: string,
296
327
  * toolCalls?: Array<{arguments: string, name: string, toolId: string, type: string}>}>}
297
328
  */