dd-trace 6.0.0-pre-d6f5ded → 6.0.0-pre-71c4307

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 (314) hide show
  1. package/LICENSE-3rdparty.csv +11 -3
  2. package/ci/init.js +16 -0
  3. package/ext/types.d.ts +1 -0
  4. package/ext/types.js +1 -0
  5. package/index.d.ts +393 -13
  6. package/init.js +5 -54
  7. package/initialize.mjs +13 -10
  8. package/loader-hook.mjs +4 -0
  9. package/package.json +37 -21
  10. package/packages/datadog-code-origin/index.js +38 -0
  11. package/packages/datadog-core/index.js +1 -3
  12. package/packages/datadog-core/src/storage.js +67 -0
  13. package/packages/datadog-core/src/utils/src/parse-tags.js +33 -0
  14. package/packages/datadog-esbuild/index.js +4 -2
  15. package/packages/datadog-instrumentations/src/aerospike.js +1 -1
  16. package/packages/datadog-instrumentations/src/amqplib.js +65 -5
  17. package/packages/datadog-instrumentations/src/avsc.js +37 -0
  18. package/packages/datadog-instrumentations/src/aws-sdk.js +2 -1
  19. package/packages/datadog-instrumentations/src/azure-functions.js +48 -0
  20. package/packages/datadog-instrumentations/src/child_process.js +144 -27
  21. package/packages/datadog-instrumentations/src/cucumber.js +330 -58
  22. package/packages/datadog-instrumentations/src/express.js +76 -9
  23. package/packages/datadog-instrumentations/src/fastify.js +12 -1
  24. package/packages/datadog-instrumentations/src/fs.js +30 -7
  25. package/packages/datadog-instrumentations/src/handlebars.js +40 -0
  26. package/packages/datadog-instrumentations/src/helpers/bundler-register.js +3 -3
  27. package/packages/datadog-instrumentations/src/helpers/hooks.js +11 -1
  28. package/packages/datadog-instrumentations/src/helpers/register.js +12 -4
  29. package/packages/datadog-instrumentations/src/http/client.js +1 -1
  30. package/packages/datadog-instrumentations/src/jest.js +85 -34
  31. package/packages/datadog-instrumentations/src/kafkajs.js +123 -63
  32. package/packages/datadog-instrumentations/src/langchain.js +77 -0
  33. package/packages/datadog-instrumentations/src/mocha/common.js +1 -1
  34. package/packages/datadog-instrumentations/src/mocha/main.js +139 -54
  35. package/packages/datadog-instrumentations/src/mocha/utils.js +60 -23
  36. package/packages/datadog-instrumentations/src/mocha/worker.js +29 -1
  37. package/packages/datadog-instrumentations/src/multer.js +37 -0
  38. package/packages/datadog-instrumentations/src/mysql2.js +226 -2
  39. package/packages/datadog-instrumentations/src/next.js +26 -11
  40. package/packages/datadog-instrumentations/src/openai.js +2 -2
  41. package/packages/datadog-instrumentations/src/passport-http.js +2 -14
  42. package/packages/datadog-instrumentations/src/passport-local.js +2 -14
  43. package/packages/datadog-instrumentations/src/passport-utils.js +43 -19
  44. package/packages/datadog-instrumentations/src/pg.js +64 -9
  45. package/packages/datadog-instrumentations/src/playwright.js +17 -4
  46. package/packages/datadog-instrumentations/src/protobufjs.js +127 -0
  47. package/packages/datadog-instrumentations/src/pug.js +23 -0
  48. package/packages/datadog-instrumentations/src/router.js +99 -4
  49. package/packages/datadog-instrumentations/src/sequelize.js +9 -4
  50. package/packages/datadog-instrumentations/src/url.js +88 -0
  51. package/packages/datadog-instrumentations/src/utils/src/extract-package-and-module-path.js +7 -4
  52. package/packages/datadog-instrumentations/src/vitest.js +244 -9
  53. package/packages/datadog-instrumentations/src/winston.js +22 -0
  54. package/packages/datadog-plugin-amqplib/src/consumer.js +5 -7
  55. package/packages/datadog-plugin-avsc/src/index.js +9 -0
  56. package/packages/datadog-plugin-avsc/src/schema_iterator.js +174 -0
  57. package/packages/datadog-plugin-aws-sdk/src/base.js +5 -0
  58. package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime.js +295 -0
  59. package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +154 -0
  60. package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +2 -1
  61. package/packages/datadog-plugin-aws-sdk/src/services/index.js +1 -0
  62. package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +9 -7
  63. package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +1 -1
  64. package/packages/datadog-plugin-aws-sdk/src/services/s3.js +35 -0
  65. package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +11 -10
  66. package/packages/datadog-plugin-aws-sdk/src/util.js +92 -0
  67. package/packages/datadog-plugin-azure-functions/src/index.js +77 -0
  68. package/packages/datadog-plugin-child_process/src/scrub-cmd-params.js +1 -1
  69. package/packages/datadog-plugin-cucumber/src/index.js +61 -5
  70. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +81 -53
  71. package/packages/datadog-plugin-cypress/src/support.js +5 -1
  72. package/packages/datadog-plugin-fastify/src/code_origin.js +31 -0
  73. package/packages/datadog-plugin-fastify/src/index.js +10 -12
  74. package/packages/datadog-plugin-fastify/src/tracing.js +19 -0
  75. package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +8 -1
  76. package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +8 -0
  77. package/packages/datadog-plugin-grpc/src/client.js +5 -2
  78. package/packages/datadog-plugin-grpc/src/server.js +3 -0
  79. package/packages/datadog-plugin-grpc/src/util.js +1 -1
  80. package/packages/datadog-plugin-jest/src/index.js +49 -7
  81. package/packages/datadog-plugin-kafkajs/src/batch-consumer.js +7 -5
  82. package/packages/datadog-plugin-kafkajs/src/consumer.js +9 -6
  83. package/packages/datadog-plugin-kafkajs/src/producer.js +10 -4
  84. package/packages/datadog-plugin-langchain/src/handlers/chain.js +50 -0
  85. package/packages/datadog-plugin-langchain/src/handlers/default.js +53 -0
  86. package/packages/datadog-plugin-langchain/src/handlers/embedding.js +63 -0
  87. package/packages/datadog-plugin-langchain/src/handlers/language_models/chat_model.js +99 -0
  88. package/packages/datadog-plugin-langchain/src/handlers/language_models/index.js +48 -0
  89. package/packages/datadog-plugin-langchain/src/handlers/language_models/llm.js +57 -0
  90. package/packages/datadog-plugin-langchain/src/index.js +89 -0
  91. package/packages/datadog-plugin-langchain/src/tokens.js +35 -0
  92. package/packages/datadog-plugin-mocha/src/index.js +40 -3
  93. package/packages/datadog-plugin-moleculer/src/server.js +0 -1
  94. package/packages/datadog-plugin-openai/src/index.js +9 -1006
  95. package/packages/datadog-plugin-openai/src/tracing.js +1023 -0
  96. package/packages/datadog-plugin-oracledb/src/index.js +1 -1
  97. package/packages/datadog-plugin-playwright/src/index.js +9 -0
  98. package/packages/datadog-plugin-protobufjs/src/index.js +14 -0
  99. package/packages/datadog-plugin-protobufjs/src/schema_iterator.js +180 -0
  100. package/packages/datadog-plugin-rhea/src/consumer.js +1 -3
  101. package/packages/datadog-plugin-vitest/src/index.js +71 -5
  102. package/packages/datadog-shimmer/src/shimmer.js +8 -4
  103. package/packages/dd-trace/src/appsec/addresses.js +14 -1
  104. package/packages/dd-trace/src/appsec/api_security_sampler.js +50 -27
  105. package/packages/dd-trace/src/appsec/blocked_templates.js +1 -1
  106. package/packages/dd-trace/src/appsec/blocking.js +1 -1
  107. package/packages/dd-trace/src/appsec/channels.js +11 -2
  108. package/packages/dd-trace/src/appsec/iast/analyzers/analyzers.js +1 -0
  109. package/packages/dd-trace/src/appsec/iast/analyzers/code-injection-analyzer.js +4 -0
  110. package/packages/dd-trace/src/appsec/iast/analyzers/cookie-analyzer.js +13 -1
  111. package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-password-rules.js +1 -1
  112. package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-secret-rules.js +1 -1
  113. package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-secrets-rules.js +1 -1
  114. package/packages/dd-trace/src/appsec/iast/analyzers/header-injection-analyzer.js +33 -16
  115. package/packages/dd-trace/src/appsec/iast/analyzers/injection-analyzer.js +10 -3
  116. package/packages/dd-trace/src/appsec/iast/analyzers/path-traversal-analyzer.js +8 -1
  117. package/packages/dd-trace/src/appsec/iast/analyzers/sql-injection-analyzer.js +4 -0
  118. package/packages/dd-trace/src/appsec/iast/analyzers/template-injection-analyzer.js +22 -0
  119. package/packages/dd-trace/src/appsec/iast/iast-plugin.js +9 -22
  120. package/packages/dd-trace/src/appsec/iast/index.js +3 -0
  121. package/packages/dd-trace/src/appsec/iast/taint-tracking/csi-methods.js +1 -0
  122. package/packages/dd-trace/src/appsec/iast/taint-tracking/index.js +3 -3
  123. package/packages/dd-trace/src/appsec/iast/taint-tracking/operations-taint-object.js +2 -2
  124. package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +119 -10
  125. package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +5 -8
  126. package/packages/dd-trace/src/appsec/iast/taint-tracking/source-types.js +2 -1
  127. package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +20 -9
  128. package/packages/dd-trace/src/appsec/iast/telemetry/namespaces.js +2 -3
  129. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/command-sensitive-analyzer.js +2 -2
  130. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/ldap-sensitive-analyzer.js +2 -2
  131. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/sql-sensitive-analyzer.js +2 -2
  132. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/url-sensitive-analyzer.js +2 -2
  133. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +6 -5
  134. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-regex.js +2 -2
  135. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/utils.js +1 -1
  136. package/packages/dd-trace/src/appsec/iast/vulnerabilities.js +1 -0
  137. package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +34 -37
  138. package/packages/dd-trace/src/appsec/index.js +81 -58
  139. package/packages/dd-trace/src/appsec/rasp/command_injection.js +56 -0
  140. package/packages/dd-trace/src/appsec/rasp/fs-plugin.js +99 -0
  141. package/packages/dd-trace/src/appsec/rasp/index.js +120 -0
  142. package/packages/dd-trace/src/appsec/rasp/lfi.js +114 -0
  143. package/packages/dd-trace/src/appsec/rasp/sql_injection.js +108 -0
  144. package/packages/dd-trace/src/appsec/rasp/ssrf.js +40 -0
  145. package/packages/dd-trace/src/appsec/rasp/utils.js +65 -0
  146. package/packages/dd-trace/src/appsec/recommended.json +354 -160
  147. package/packages/dd-trace/src/appsec/remote_config/capabilities.js +11 -2
  148. package/packages/dd-trace/src/appsec/remote_config/index.js +44 -7
  149. package/packages/dd-trace/src/appsec/remote_config/manager.js +13 -3
  150. package/packages/dd-trace/src/appsec/reporter.js +24 -13
  151. package/packages/dd-trace/src/appsec/sdk/set_user.js +2 -2
  152. package/packages/dd-trace/src/appsec/sdk/track_event.js +41 -21
  153. package/packages/dd-trace/src/appsec/sdk/user_blocking.js +4 -4
  154. package/packages/dd-trace/src/appsec/sdk/utils.js +21 -2
  155. package/packages/dd-trace/src/appsec/telemetry.js +17 -2
  156. package/packages/dd-trace/src/appsec/user_tracking.js +168 -0
  157. package/packages/dd-trace/src/appsec/waf/index.js +4 -4
  158. package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +33 -20
  159. package/packages/dd-trace/src/appsec/waf/waf_manager.js +7 -2
  160. package/packages/dd-trace/src/azure_metadata.js +120 -0
  161. package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +128 -0
  162. package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +166 -0
  163. package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +2 -14
  164. package/packages/dd-trace/src/ci-visibility/exporters/agent-proxy/index.js +19 -1
  165. package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +1 -1
  166. package/packages/dd-trace/src/ci-visibility/exporters/agentless/di-logs-writer.js +53 -0
  167. package/packages/dd-trace/src/ci-visibility/exporters/agentless/index.js +9 -2
  168. package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +1 -1
  169. package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +72 -9
  170. package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +53 -0
  171. package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +4 -2
  172. package/packages/dd-trace/src/config.js +176 -41
  173. package/packages/dd-trace/src/constants.js +16 -1
  174. package/packages/dd-trace/src/crashtracking/crashtracker.js +99 -0
  175. package/packages/dd-trace/src/crashtracking/index.js +15 -0
  176. package/packages/dd-trace/src/crashtracking/noop.js +8 -0
  177. package/packages/dd-trace/src/data_streams_context.js +3 -0
  178. package/packages/dd-trace/src/datastreams/fnv.js +23 -0
  179. package/packages/dd-trace/src/datastreams/pathway.js +13 -5
  180. package/packages/dd-trace/src/datastreams/processor.js +39 -6
  181. package/packages/dd-trace/src/datastreams/schemas/schema.js +8 -0
  182. package/packages/dd-trace/src/datastreams/schemas/schema_builder.js +133 -0
  183. package/packages/dd-trace/src/datastreams/schemas/schema_sampler.js +29 -0
  184. package/packages/dd-trace/src/datastreams/writer.js +6 -5
  185. package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +80 -0
  186. package/packages/dd-trace/src/debugger/devtools_client/config.js +30 -0
  187. package/packages/dd-trace/src/debugger/devtools_client/defaults.js +7 -0
  188. package/packages/dd-trace/src/debugger/devtools_client/index.js +178 -0
  189. package/packages/dd-trace/src/debugger/devtools_client/inspector_promises_polyfill.js +23 -0
  190. package/packages/dd-trace/src/debugger/devtools_client/json-buffer.js +36 -0
  191. package/packages/dd-trace/src/debugger/devtools_client/remote_config.js +107 -0
  192. package/packages/dd-trace/src/debugger/devtools_client/send.js +79 -0
  193. package/packages/dd-trace/src/debugger/devtools_client/session.js +7 -0
  194. package/packages/dd-trace/src/debugger/devtools_client/snapshot/collector.js +187 -0
  195. package/packages/dd-trace/src/debugger/devtools_client/snapshot/index.js +40 -0
  196. package/packages/dd-trace/src/debugger/devtools_client/snapshot/processor.js +286 -0
  197. package/packages/dd-trace/src/debugger/devtools_client/snapshot/redaction.js +117 -0
  198. package/packages/dd-trace/src/debugger/devtools_client/snapshot/symbols.js +6 -0
  199. package/packages/dd-trace/src/debugger/devtools_client/state.js +62 -0
  200. package/packages/dd-trace/src/debugger/devtools_client/status.js +116 -0
  201. package/packages/dd-trace/src/debugger/index.js +92 -0
  202. package/packages/dd-trace/src/dogstatsd.js +2 -2
  203. package/packages/dd-trace/src/encode/0.4.js +23 -78
  204. package/packages/dd-trace/src/encode/agentless-ci-visibility.js +0 -32
  205. package/packages/dd-trace/src/encode/coverage-ci-visibility.js +1 -2
  206. package/packages/dd-trace/src/encode/span-stats.js +0 -30
  207. package/packages/dd-trace/src/exporters/agent/writer.js +3 -3
  208. package/packages/dd-trace/src/exporters/common/request.js +10 -36
  209. package/packages/dd-trace/src/exporters/common/url-to-http-options-polyfill.js +31 -0
  210. package/packages/dd-trace/src/exporters/span-stats/writer.js +1 -1
  211. package/packages/dd-trace/src/flare/index.js +1 -1
  212. package/packages/dd-trace/src/guardrails/index.js +64 -0
  213. package/packages/dd-trace/src/guardrails/log.js +32 -0
  214. package/packages/dd-trace/src/guardrails/telemetry.js +78 -0
  215. package/packages/dd-trace/src/guardrails/util.js +10 -0
  216. package/packages/dd-trace/src/lambda/runtime/ritm.js +2 -2
  217. package/packages/dd-trace/src/llmobs/constants/tags.js +34 -0
  218. package/packages/dd-trace/src/llmobs/constants/text.js +6 -0
  219. package/packages/dd-trace/src/llmobs/constants/writers.js +13 -0
  220. package/packages/dd-trace/src/llmobs/index.js +103 -0
  221. package/packages/dd-trace/src/llmobs/noop.js +82 -0
  222. package/packages/dd-trace/src/llmobs/plugins/base.js +65 -0
  223. package/packages/dd-trace/src/llmobs/plugins/openai.js +205 -0
  224. package/packages/dd-trace/src/llmobs/sdk.js +441 -0
  225. package/packages/dd-trace/src/llmobs/span_processor.js +195 -0
  226. package/packages/dd-trace/src/llmobs/storage.js +6 -0
  227. package/packages/dd-trace/src/llmobs/tagger.js +322 -0
  228. package/packages/dd-trace/src/llmobs/util.js +176 -0
  229. package/packages/dd-trace/src/llmobs/writers/base.js +111 -0
  230. package/packages/dd-trace/src/llmobs/writers/evaluations.js +29 -0
  231. package/packages/dd-trace/src/llmobs/writers/spans/agentProxy.js +23 -0
  232. package/packages/dd-trace/src/llmobs/writers/spans/agentless.js +17 -0
  233. package/packages/dd-trace/src/llmobs/writers/spans/base.js +52 -0
  234. package/packages/dd-trace/src/log/channels.js +9 -2
  235. package/packages/dd-trace/src/log/index.js +30 -14
  236. package/packages/dd-trace/src/log/log.js +52 -0
  237. package/packages/dd-trace/src/log/writer.js +63 -20
  238. package/packages/dd-trace/src/{encode → msgpack}/chunk.js +8 -5
  239. package/packages/dd-trace/src/msgpack/encoder.js +309 -0
  240. package/packages/dd-trace/src/msgpack/index.js +6 -0
  241. package/packages/dd-trace/src/noop/proxy.js +5 -2
  242. package/packages/dd-trace/src/noop/span.js +5 -1
  243. package/packages/dd-trace/src/opentelemetry/context_manager.js +2 -2
  244. package/packages/dd-trace/src/opentelemetry/span.js +16 -1
  245. package/packages/dd-trace/src/opentelemetry/tracer.js +1 -0
  246. package/packages/dd-trace/src/opentracing/propagation/text_map.js +114 -37
  247. package/packages/dd-trace/src/opentracing/span.js +39 -3
  248. package/packages/dd-trace/src/opentracing/span_context.js +13 -0
  249. package/packages/dd-trace/src/opentracing/tracer.js +10 -3
  250. package/packages/dd-trace/src/payload-tagging/config/aws.json +71 -3
  251. package/packages/dd-trace/src/payload-tagging/index.js +1 -1
  252. package/packages/dd-trace/src/payload-tagging/jsonpath-plus.js +2094 -0
  253. package/packages/dd-trace/src/plugin_manager.js +6 -2
  254. package/packages/dd-trace/src/plugins/ci_plugin.js +89 -11
  255. package/packages/dd-trace/src/plugins/index.js +6 -0
  256. package/packages/dd-trace/src/plugins/log_plugin.js +1 -1
  257. package/packages/dd-trace/src/plugins/outbound.js +9 -0
  258. package/packages/dd-trace/src/plugins/plugin.js +1 -1
  259. package/packages/dd-trace/src/plugins/schema.js +35 -0
  260. package/packages/dd-trace/src/plugins/tracing.js +3 -3
  261. package/packages/dd-trace/src/plugins/util/ci.js +23 -1
  262. package/packages/dd-trace/src/plugins/util/env.js +5 -2
  263. package/packages/dd-trace/src/plugins/util/git.js +7 -7
  264. package/packages/dd-trace/src/plugins/util/inferred_proxy.js +121 -0
  265. package/packages/dd-trace/src/plugins/util/ip_extractor.js +0 -1
  266. package/packages/dd-trace/src/plugins/util/serverless.js +7 -0
  267. package/packages/dd-trace/src/plugins/util/stacktrace.js +94 -0
  268. package/packages/dd-trace/src/plugins/util/tags.js +7 -0
  269. package/packages/dd-trace/src/plugins/util/test.js +87 -26
  270. package/packages/dd-trace/src/plugins/util/web.js +47 -17
  271. package/packages/dd-trace/src/priority_sampler.js +32 -1
  272. package/packages/dd-trace/src/profiling/config.js +6 -1
  273. package/packages/dd-trace/src/profiling/exporters/agent.js +57 -77
  274. package/packages/dd-trace/src/profiling/exporters/event_serializer.js +76 -0
  275. package/packages/dd-trace/src/profiling/exporters/file.js +8 -4
  276. package/packages/dd-trace/src/profiling/profiler.js +86 -21
  277. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns.js +13 -0
  278. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_lookup.js +16 -0
  279. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_lookupservice.js +16 -0
  280. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_resolve.js +24 -0
  281. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_reverse.js +16 -0
  282. package/packages/dd-trace/src/profiling/profilers/event_plugins/event.js +62 -0
  283. package/packages/dd-trace/src/profiling/profilers/event_plugins/fs.js +49 -0
  284. package/packages/dd-trace/src/profiling/profilers/event_plugins/net.js +24 -0
  285. package/packages/dd-trace/src/profiling/profilers/events.js +188 -36
  286. package/packages/dd-trace/src/profiling/profilers/shared.js +5 -0
  287. package/packages/dd-trace/src/profiling/profilers/wall.js +103 -83
  288. package/packages/dd-trace/src/profiling/webspan-utils.js +23 -0
  289. package/packages/dd-trace/src/proxy.js +38 -3
  290. package/packages/dd-trace/src/runtime_metrics.js +107 -4
  291. package/packages/dd-trace/src/scope.js +1 -1
  292. package/packages/dd-trace/src/serverless.js +1 -1
  293. package/packages/dd-trace/src/service-naming/schemas/v0/index.js +2 -1
  294. package/packages/dd-trace/src/service-naming/schemas/v0/serverless.js +12 -0
  295. package/packages/dd-trace/src/service-naming/schemas/v1/index.js +2 -1
  296. package/packages/dd-trace/src/service-naming/schemas/v1/serverless.js +12 -0
  297. package/packages/dd-trace/src/span_processor.js +15 -10
  298. package/packages/dd-trace/src/span_stats.js +4 -2
  299. package/packages/dd-trace/src/tagger.js +1 -1
  300. package/packages/dd-trace/src/telemetry/index.js +13 -1
  301. package/packages/dd-trace/src/telemetry/logs/index.js +16 -11
  302. package/packages/dd-trace/src/telemetry/logs/log-collector.js +12 -9
  303. package/packages/dd-trace/src/telemetry/metrics.js +6 -1
  304. package/packages/dd-trace/src/telemetry/send-data.js +2 -2
  305. package/packages/dd-trace/src/util.js +4 -0
  306. package/version.js +4 -2
  307. package/packages/datadog-core/src/storage/async_resource.js +0 -108
  308. package/packages/datadog-core/src/storage/index.js +0 -5
  309. package/packages/datadog-instrumentations/src/qs.js +0 -24
  310. package/packages/dd-trace/src/appsec/iast/iast-log.js +0 -86
  311. package/packages/dd-trace/src/appsec/passport.js +0 -110
  312. package/packages/dd-trace/src/appsec/rasp.js +0 -176
  313. package/packages/dd-trace/src/telemetry/init-telemetry.js +0 -75
  314. /package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/{code-injection-sensitive-analyzer.js → tainted-range-based-sensitive-analyzer.js} +0 -0
@@ -1,4 +1,5 @@
1
1
  Component,Origin,License,Copyright
2
+ require,@datadog/libdatadog,Apache license 2.0,Copyright 2024 Datadog Inc.
2
3
  require,@datadog/native-appsec,Apache license 2.0,Copyright 2018 Datadog Inc.
3
4
  require,@datadog/native-metrics,Apache license 2.0,Copyright 2018 Datadog Inc.
4
5
  require,@datadog/native-iast-rewriter,Apache license 2.0,Copyright 2018 Datadog Inc.
@@ -7,20 +8,18 @@ require,@datadog/pprof,Apache license 2.0,Copyright 2019 Google Inc.
7
8
  require,@datadog/sketches-js,Apache license 2.0,Copyright 2020 Datadog Inc.
8
9
  require,@opentelemetry/api,Apache license 2.0,Copyright OpenTelemetry Authors
9
10
  require,@opentelemetry/core,Apache license 2.0,Copyright OpenTelemetry Authors
11
+ require,@isaacs/ttlcache,ISC,Copyright (c) 2022-2023 - Isaac Z. Schlueter and Contributors
10
12
  require,crypto-randomuuid,MIT,Copyright 2021 Node.js Foundation and contributors
11
13
  require,dc-polyfill,MIT,Copyright 2023 Datadog Inc.
12
14
  require,ignore,MIT,Copyright 2013 Kael Zhang and contributors
13
15
  require,import-in-the-middle,Apache license 2.0,Copyright 2021 Datadog Inc.
14
- require,int64-buffer,MIT,Copyright 2015-2016 Yusuke Kawasaki
15
16
  require,istanbul-lib-coverage,BSD-3-Clause,Copyright 2012-2015 Yahoo! Inc.
16
17
  require,jest-docblock,MIT,Copyright Meta Platforms, Inc. and affiliates.
17
- require,jsonpath-plus,MIT,Copyright (c) 2011-2019 Stefan Goessner, Subbu Allamaraju, Mike Brevoort, Robert Krahn, Brett Zamir, Richard Schneider
18
18
  require,koalas,MIT,Copyright 2013-2017 Brian Woodward
19
19
  require,limiter,MIT,Copyright 2011 John Hurliman
20
20
  require,lodash.sortby,MIT,Copyright JS Foundation and other contributors
21
21
  require,lru-cache,ISC,Copyright (c) 2010-2022 Isaac Z. Schlueter and Contributors
22
22
  require,module-details-from-path,MIT,Copyright 2016 Thomas Watson Steen
23
- require,msgpack-lite,MIT,Copyright 2015 Yusuke Kawasaki
24
23
  require,opentracing,MIT,Copyright 2016 Resonance Labs Inc
25
24
  require,path-to-regexp,MIT,Copyright 2014 Blake Embrey
26
25
  require,pprof-format,MIT,Copyright 2022 Stephen Belanger
@@ -30,7 +29,12 @@ require,retry,MIT,Copyright 2011 Tim Koschützki Felix Geisendörfer
30
29
  require,rfdc,MIT,Copyright 2019 David Mark Clements
31
30
  require,semver,ISC,Copyright Isaac Z. Schlueter and Contributors
32
31
  require,shell-quote,mit,Copyright (c) 2013 James Halliday
32
+ require,source-map,BSD-3-Clause,Copyright (c) 2009-2011, Mozilla Foundation and contributors
33
+ dev,@apollo/server,MIT,Copyright (c) 2016-2020 Apollo Graph, Inc. (Formerly Meteor Development Group, Inc.)
33
34
  dev,@types/node,MIT,Copyright Authors
35
+ dev,@eslint/eslintrc,MIT,Copyright OpenJS Foundation and other contributors, <www.openjsf.org>
36
+ dev,@eslint/js,MIT,Copyright OpenJS Foundation and other contributors, <www.openjsf.org>
37
+ dev,@stylistic/eslint-plugin-js,MIT,Copyright OpenJS Foundation and other contributors, <www.openjsf.org>
34
38
  dev,autocannon,MIT,Copyright 2016 Matteo Collina
35
39
  dev,aws-sdk,Apache 2.0,Copyright 2012-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
36
40
  dev,axios,MIT,Copyright 2014-present Matt Zabriskie
@@ -51,11 +55,14 @@ dev,eslint-plugin-promise,ISC,jden and other contributors
51
55
  dev,express,MIT,Copyright 2009-2014 TJ Holowaychuk 2013-2014 Roman Shtylman 2014-2015 Douglas Christopher Wilson
52
56
  dev,get-port,MIT,Copyright Sindre Sorhus
53
57
  dev,glob,ISC,Copyright Isaac Z. Schlueter and Contributors
58
+ dev,globals,MIT,Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
54
59
  dev,graphql,MIT,Copyright 2015 Facebook Inc.
60
+ dev,int64-buffer,MIT,Copyright 2015-2016 Yusuke Kawasaki
55
61
  dev,jszip,MIT,Copyright 2015-2016 Stuart Knightley and contributors
56
62
  dev,knex,MIT,Copyright (c) 2013-present Tim Griesser
57
63
  dev,mkdirp,MIT,Copyright 2010 James Halliday
58
64
  dev,mocha,MIT,Copyright 2011-2018 JS Foundation and contributors https://js.foundation
65
+ dev,msgpack-lite,MIT,Copyright 2015 Yusuke Kawasaki
59
66
  dev,multer,MIT,Copyright 2014 Hage Yaapa
60
67
  dev,nock,MIT,Copyright 2017 Pedro Teixeira and other contributors
61
68
  dev,nyc,ISC,Copyright 2015 Contributors
@@ -65,6 +72,7 @@ dev,sinon,BSD-3-Clause,Copyright 2010-2017 Christian Johansen
65
72
  dev,sinon-chai,WTFPL and BSD-2-Clause,Copyright 2004 Sam Hocevar 2012–2017 Domenic Denicola
66
73
  dev,tap,ISC,Copyright 2011-2022 Isaac Z. Schlueter and Contributors
67
74
  dev,tiktoken,MIT,Copyright (c) 2022 OpenAI, Shantanu Jain
75
+ dev,yaml,ISC,Copyright Eemeli Aro <eemeli@gmail.com>
68
76
  file,aws-lambda-nodejs-runtime-interface-client,Apache 2.0,Copyright 2019 Amazon.com Inc. or its affiliates. All Rights Reserved.
69
77
  file,profile.proto,Apache license 2.0,Copyright 2016 Google Inc.
70
78
  file,is-git-url,MIT,Copyright (c) 2017 Jon Schlinkert.
package/ci/init.js CHANGED
@@ -1,11 +1,22 @@
1
1
  /* eslint-disable no-console */
2
2
  const tracer = require('../packages/dd-trace')
3
3
  const { isTrue } = require('../packages/dd-trace/src/util')
4
+ const log = require('../packages/dd-trace/src/log')
4
5
 
5
6
  const isJestWorker = !!process.env.JEST_WORKER_ID
6
7
  const isCucumberWorker = !!process.env.CUCUMBER_WORKER_ID
7
8
  const isMochaWorker = !!process.env.MOCHA_WORKER_ID
8
9
 
10
+ const packageManagers = [
11
+ 'npm',
12
+ 'yarn',
13
+ 'pnpm'
14
+ ]
15
+
16
+ const isPackageManager = () => {
17
+ return packageManagers.some(packageManager => process.argv[1]?.includes(`bin/${packageManager}`))
18
+ }
19
+
9
20
  const options = {
10
21
  startupLogs: false,
11
22
  isCiVisibility: true,
@@ -14,6 +25,11 @@ const options = {
14
25
 
15
26
  let shouldInit = true
16
27
 
28
+ if (isPackageManager()) {
29
+ log.debug('dd-trace is not initialized in a package manager.')
30
+ shouldInit = false
31
+ }
32
+
17
33
  const isAgentlessEnabled = isTrue(process.env.DD_CIVISIBILITY_AGENTLESS_ENABLED)
18
34
 
19
35
  if (isAgentlessEnabled) {
package/ext/types.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  declare const types: {
2
2
  HTTP: 'http'
3
+ SERVERLESS: 'serverless'
3
4
  WEB: 'web'
4
5
  }
5
6
 
package/ext/types.js CHANGED
@@ -2,5 +2,6 @@
2
2
 
3
3
  module.exports = {
4
4
  HTTP: 'http',
5
+ SERVERLESS: 'serverless',
5
6
  WEB: 'web'
6
7
  }
package/index.d.ts CHANGED
@@ -137,6 +137,11 @@ interface Tracer extends opentracing.Tracer {
137
137
  TracerProvider: tracer.opentelemetry.TracerProvider;
138
138
 
139
139
  dogstatsd: tracer.DogStatsD;
140
+
141
+ /**
142
+ * LLM Observability SDK
143
+ */
144
+ llmobs: tracer.llmobs.LLMObs;
140
145
  }
141
146
 
142
147
  // left out of the namespace, so it
@@ -147,7 +152,9 @@ interface Plugins {
147
152
  "amqp10": tracer.plugins.amqp10;
148
153
  "amqplib": tracer.plugins.amqplib;
149
154
  "apollo": tracer.plugins.apollo;
155
+ "avsc": tracer.plugins.avsc;
150
156
  "aws-sdk": tracer.plugins.aws_sdk;
157
+ "azure-functions": tracer.plugins.azure_functions;
151
158
  "bunyan": tracer.plugins.bunyan;
152
159
  "cassandra-driver": tracer.plugins.cassandra_driver;
153
160
  "child_process": tracer.plugins.child_process;
@@ -172,6 +179,7 @@ interface Plugins {
172
179
  "kafkajs": tracer.plugins.kafkajs
173
180
  "knex": tracer.plugins.knex;
174
181
  "koa": tracer.plugins.koa;
182
+ "langchain": tracer.plugins.langchain;
175
183
  "mariadb": tracer.plugins.mariadb;
176
184
  "memcached": tracer.plugins.memcached;
177
185
  "microgateway-core": tracer.plugins.microgateway_core;
@@ -190,6 +198,7 @@ interface Plugins {
190
198
  "playwright": tracer.plugins.playwright;
191
199
  "pg": tracer.plugins.pg;
192
200
  "pino": tracer.plugins.pino;
201
+ "protobufjs": tracer.plugins.protobufjs;
193
202
  "redis": tracer.plugins.redis;
194
203
  "restify": tracer.plugins.restify;
195
204
  "rhea": tracer.plugins.rhea;
@@ -646,27 +655,33 @@ declare namespace tracer {
646
655
  */
647
656
  eventTracking?: {
648
657
  /**
649
- * Controls the automated user event tracking mode. Possible values are disabled, safe and extended.
650
- * On safe mode, any detected Personally Identifiable Information (PII) about the user will be redacted from the event.
651
- * On extended mode, no redaction will take place.
652
- * @default 'safe'
658
+ * Controls the automated user tracking mode for user IDs and logins collections. Possible values:
659
+ * * 'anonymous': will hash user IDs and user logins before collecting them
660
+ * * 'anon': alias for 'anonymous'
661
+ * * 'safe': deprecated alias for 'anonymous'
662
+ *
663
+ * * 'identification': will collect user IDs and logins without redaction
664
+ * * 'ident': alias for 'identification'
665
+ * * 'extended': deprecated alias for 'identification'
666
+ *
667
+ * * 'disabled': will not collect user IDs and logins
668
+ *
669
+ * Unknown values will be considered as 'disabled'
670
+ * @default 'identification'
653
671
  */
654
- mode?: 'safe' | 'extended' | 'disabled'
672
+ mode?:
673
+ 'anonymous' | 'anon' | 'safe' |
674
+ 'identification' | 'ident' | 'extended' |
675
+ 'disabled'
655
676
  },
656
677
  /**
657
- * Configuration for Api Security sampling
678
+ * Configuration for Api Security
658
679
  */
659
680
  apiSecurity?: {
660
681
  /** Whether to enable Api Security.
661
- * @default false
682
+ * @default true
662
683
  */
663
684
  enabled?: boolean,
664
-
665
- /** Controls the request sampling rate (between 0 and 1) in which Api Security is triggered.
666
- * The value will be coerced back if it's outside of the 0-1 range.
667
- * @default 0.1
668
- */
669
- requestSampling?: number
670
685
  },
671
686
  /**
672
687
  * Configuration for RASP
@@ -749,6 +764,11 @@ declare namespace tracer {
749
764
  */
750
765
  maxDepth?: number
751
766
  }
767
+
768
+ /**
769
+ * Configuration enabling LLM Observability. Enablement is superceded by the DD_LLMOBS_ENABLED environment variable.
770
+ */
771
+ llmobs?: llmobs.LLMObsEnableOptions
752
772
  }
753
773
 
754
774
  /**
@@ -1199,6 +1219,12 @@ declare namespace tracer {
1199
1219
  signature?: boolean;
1200
1220
  }
1201
1221
 
1222
+ /**
1223
+ * This plugin automatically patches the [avsc](https://github.com/mtth/avsc) module
1224
+ * to collect avro message schemas when Datastreams Monitoring is enabled.
1225
+ */
1226
+ interface avsc extends Integration {}
1227
+
1202
1228
  /**
1203
1229
  * This plugin automatically instruments the
1204
1230
  * [aws-sdk](https://github.com/aws/aws-sdk-js) module.
@@ -1237,6 +1263,12 @@ declare namespace tracer {
1237
1263
  [key: string]: boolean | Object | undefined;
1238
1264
  }
1239
1265
 
1266
+ /**
1267
+ * This plugin automatically instruments the
1268
+ * @azure/functions module.
1269
+ */
1270
+ interface azure_functions extends Instrumentation {}
1271
+
1240
1272
  /**
1241
1273
  * This plugin patches the [bunyan](https://github.com/trentm/node-bunyan)
1242
1274
  * to automatically inject trace identifiers in log records when the
@@ -1573,6 +1605,12 @@ declare namespace tracer {
1573
1605
  */
1574
1606
  interface kafkajs extends Instrumentation {}
1575
1607
 
1608
+ /**
1609
+ * This plugin automatically instruments the
1610
+ * [langchain](https://js.langchain.com/) module
1611
+ */
1612
+ interface langchain extends Instrumentation {}
1613
+
1576
1614
  /**
1577
1615
  * This plugin automatically instruments the
1578
1616
  * [ldapjs](https://github.com/ldapjs/node-ldapjs/) module.
@@ -1739,6 +1777,11 @@ declare namespace tracer {
1739
1777
  * on the tracer.
1740
1778
  */
1741
1779
  interface pino extends Integration {}
1780
+ /**
1781
+ * This plugin automatically patches the [protobufjs](https://protobufjs.github.io/protobuf.js/)
1782
+ * to collect protobuf message schemas when Datastreams Monitoring is enabled.
1783
+ */
1784
+ interface protobufjs extends Integration {}
1742
1785
 
1743
1786
  /**
1744
1787
  * This plugin automatically instruments the
@@ -2154,6 +2197,18 @@ declare namespace tracer {
2154
2197
  */
2155
2198
  maxContextOperations?: number,
2156
2199
 
2200
+ /**
2201
+ * Defines the pattern to ignore cookie names in the vulnerability hash calculation
2202
+ * @default ".{32,}"
2203
+ */
2204
+ cookieFilterPattern?: string,
2205
+
2206
+ /**
2207
+ * Defines the number of rows to taint in data coming from databases
2208
+ * @default 1
2209
+ */
2210
+ dbRowsToTaint?: number,
2211
+
2157
2212
  /**
2158
2213
  * Whether to enable vulnerability deduplication
2159
2214
  */
@@ -2180,6 +2235,331 @@ declare namespace tracer {
2180
2235
  */
2181
2236
  telemetryVerbosity?: string
2182
2237
  }
2238
+
2239
+ export namespace llmobs {
2240
+ export interface LLMObs {
2241
+
2242
+ /**
2243
+ * Whether or not LLM Observability is enabled.
2244
+ */
2245
+ enabled: boolean,
2246
+
2247
+ /**
2248
+ * Enable LLM Observability tracing.
2249
+ */
2250
+ enable (options: LLMObsEnableOptions): void,
2251
+
2252
+ /**
2253
+ * Disable LLM Observability tracing.
2254
+ */
2255
+ disable (): void,
2256
+
2257
+ /**
2258
+ * Instruments a function by automatically creating a span activated on its
2259
+ * scope.
2260
+ *
2261
+ * The span will automatically be finished when one of these conditions is
2262
+ * met:
2263
+ *
2264
+ * * The function returns a promise, in which case the span will finish when
2265
+ * the promise is resolved or rejected.
2266
+ * * The function takes a callback as its second parameter, in which case the
2267
+ * span will finish when that callback is called.
2268
+ * * The function doesn't accept a callback and doesn't return a promise, in
2269
+ * which case the span will finish at the end of the function execution.
2270
+ * @param fn The function to instrument.
2271
+ * @param options Optional LLM Observability span options.
2272
+ * @returns The return value of the function.
2273
+ */
2274
+ trace<T> (options: LLMObsNamedSpanOptions, fn: (span: tracer.Span, done: (error?: Error) => void) => T): T
2275
+
2276
+ /**
2277
+ * Wrap a function to automatically create a span activated on its
2278
+ * scope when it's called.
2279
+ *
2280
+ * The span will automatically be finished when one of these conditions is
2281
+ * met:
2282
+ *
2283
+ * * The function returns a promise, in which case the span will finish when
2284
+ * the promise is resolved or rejected.
2285
+ * * The function takes a callback as its last parameter, in which case the
2286
+ * span will finish when that callback is called.
2287
+ * * The function doesn't accept a callback and doesn't return a promise, in
2288
+ * which case the span will finish at the end of the function execution.
2289
+ * @param fn The function to instrument.
2290
+ * @param options Optional LLM Observability span options.
2291
+ * @returns A new function that wraps the provided function with span creation.
2292
+ */
2293
+ wrap<T = (...args: any[]) => any> (options: LLMObsNamelessSpanOptions, fn: T): T
2294
+
2295
+ /**
2296
+ * Decorate a function in a javascript runtime that supports function decorators.
2297
+ * Note that this is **not** supported in the Node.js runtime, but is in TypeScript.
2298
+ *
2299
+ * In TypeScript, this decorator is only supported in contexts where general TypeScript
2300
+ * function decorators are supported.
2301
+ *
2302
+ * @param options Optional LLM Observability span options.
2303
+ */
2304
+ decorate (options: llmobs.LLMObsNamelessSpanOptions): any
2305
+
2306
+ /**
2307
+ * Returns a representation of a span to export its span and trace IDs.
2308
+ * If no span is provided, the current LLMObs-type span will be used.
2309
+ * @param span Optional span to export.
2310
+ * @returns An object containing the span and trace IDs.
2311
+ */
2312
+ exportSpan (span?: tracer.Span): llmobs.ExportedLLMObsSpan
2313
+
2314
+
2315
+ /**
2316
+ * Sets inputs, outputs, tags, metadata, and metrics as provided for a given LLM Observability span.
2317
+ * Note that with the exception of tags, this method will override any existing values for the provided fields.
2318
+ *
2319
+ * For example:
2320
+ * ```javascript
2321
+ * llmobs.trace({ kind: 'llm', name: 'myLLM', modelName: 'gpt-4o', modelProvider: 'openai' }, () => {
2322
+ * llmobs.annotate({
2323
+ * inputData: [{ content: 'system prompt, role: 'system' }, { content: 'user prompt', role: 'user' }],
2324
+ * outputData: { content: 'response', role: 'ai' },
2325
+ * metadata: { temperature: 0.7 },
2326
+ * tags: { host: 'localhost' },
2327
+ * metrics: { inputTokens: 10, outputTokens: 20, totalTokens: 30 }
2328
+ * })
2329
+ * })
2330
+ * ```
2331
+ *
2332
+ * @param span The span to annotate (defaults to the current LLM Observability span if not provided)
2333
+ * @param options An object containing the inputs, outputs, tags, metadata, and metrics to set on the span.
2334
+ */
2335
+ annotate (options: llmobs.AnnotationOptions): void
2336
+ annotate (span: tracer.Span | undefined, options: llmobs.AnnotationOptions): void
2337
+
2338
+ /**
2339
+ * Submits a custom evalutation metric for a given span ID and trace ID.
2340
+ * @param spanContext The span context of the span to submit the evaluation metric for.
2341
+ * @param options An object containing the label, metric type, value, and tags of the evaluation metric.
2342
+ */
2343
+ submitEvaluation (spanContext: llmobs.ExportedLLMObsSpan, options: llmobs.EvaluationOptions): void
2344
+
2345
+ /**
2346
+ * Flushes any remaining spans and evaluation metrics to LLM Observability.
2347
+ */
2348
+ flush (): void
2349
+ }
2350
+
2351
+ interface EvaluationOptions {
2352
+ /**
2353
+ * The name of the evalutation metric
2354
+ */
2355
+ label: string,
2356
+
2357
+ /**
2358
+ * The type of evaluation metric, one of 'categorical' or 'score'
2359
+ */
2360
+ metricType: 'categorical' | 'score',
2361
+
2362
+ /**
2363
+ * The value of the evaluation metric.
2364
+ * Must be string for 'categorical' metrics and number for 'score' metrics.
2365
+ */
2366
+ value: string | number,
2367
+
2368
+ /**
2369
+ * An object of string key-value pairs to tag the evaluation metric with.
2370
+ */
2371
+ tags?: { [key: string]: any },
2372
+
2373
+ /**
2374
+ * The name of the ML application
2375
+ */
2376
+ mlApp?: string,
2377
+
2378
+ /**
2379
+ * The timestamp in milliseconds when the evaluation metric result was generated.
2380
+ */
2381
+ timestampMs?: number
2382
+ }
2383
+
2384
+ interface Document {
2385
+ /**
2386
+ * Document text
2387
+ */
2388
+ text?: string,
2389
+
2390
+ /**
2391
+ * Document name
2392
+ */
2393
+ name?: string,
2394
+
2395
+ /**
2396
+ * Document ID
2397
+ */
2398
+ id?: string,
2399
+
2400
+ /**
2401
+ * Score of the document retrieval as a source of ground truth
2402
+ */
2403
+ score?: number
2404
+ }
2405
+
2406
+ /**
2407
+ * Represents a single LLM chat model message
2408
+ */
2409
+ interface Message {
2410
+ /**
2411
+ * Content of the message.
2412
+ */
2413
+ content: string,
2414
+
2415
+ /**
2416
+ * Role of the message (ie system, user, ai)
2417
+ */
2418
+ role?: string,
2419
+
2420
+ /**
2421
+ * Tool calls of the message
2422
+ */
2423
+ toolCalls?: ToolCall[],
2424
+ }
2425
+
2426
+ /**
2427
+ * Represents a single tool call for an LLM chat model message
2428
+ */
2429
+ interface ToolCall {
2430
+ /**
2431
+ * Name of the tool
2432
+ */
2433
+ name?: string,
2434
+
2435
+ /**
2436
+ * Arguments passed to the tool
2437
+ */
2438
+ arguments?: { [key: string]: any },
2439
+
2440
+ /**
2441
+ * The tool ID
2442
+ */
2443
+ toolId?: string,
2444
+
2445
+ /**
2446
+ * The tool type
2447
+ */
2448
+ type?: string
2449
+ }
2450
+
2451
+ /**
2452
+ * Annotation options for LLM Observability spans.
2453
+ */
2454
+ interface AnnotationOptions {
2455
+ /**
2456
+ * A single input string, object, or a list of objects based on the span kind:
2457
+ * 1. LLM spans: accepts a string, or an object of the form {content: "...", role: "..."}, or a list of objects with the same signature.
2458
+ * 2. Embedding spans: accepts a string, list of strings, or an object of the form {text: "...", ...}, or a list of objects with the same signature.
2459
+ * 3. Other: any JSON serializable type
2460
+ */
2461
+ inputData?: string | Message | Message[] | Document | Document[] | { [key: string]: any },
2462
+
2463
+ /**
2464
+ * A single output string, object, or a list of objects based on the span kind:
2465
+ * 1. LLM spans: accepts a string, or an object of the form {content: "...", role: "..."}, or a list of objects with the same signature.
2466
+ * 2. Retrieval spans: An object containing any of the key value pairs {name: str, id: str, text: str, source: number} or a list of dictionaries with the same signature.
2467
+ * 3. Other: any JSON serializable type
2468
+ */
2469
+ outputData?: string | Message | Message[] | Document | Document[] | { [key: string]: any },
2470
+
2471
+ /**
2472
+ * Object of JSON serializable key-value metadata pairs relevant to the input/output operation described by the LLM Observability span.
2473
+ */
2474
+ metadata?: { [key: string]: any },
2475
+
2476
+ /**
2477
+ * Object of JSON seraliazable key-value metrics (number) pairs, such as `{input,output,total}Tokens`
2478
+ */
2479
+ metrics?: { [key: string]: number },
2480
+
2481
+ /**
2482
+ * Object of JSON serializable key-value tag pairs to set or update on the LLM Observability span regarding the span's context.
2483
+ */
2484
+ tags?: { [key: string]: any }
2485
+ }
2486
+
2487
+ /**
2488
+ * An object containing the span ID and trace ID of interest
2489
+ */
2490
+ interface ExportedLLMObsSpan {
2491
+ /**
2492
+ * Trace ID associated with the span of interest
2493
+ */
2494
+ traceId: string,
2495
+
2496
+ /**
2497
+ * Span ID associated with the span of interest
2498
+ */
2499
+ spanId: string,
2500
+ }
2501
+
2502
+ interface LLMObsSpanOptions extends SpanOptions {
2503
+ /**
2504
+ * LLM Observability span kind. One of `agent`, `workflow`, `task`, `tool`, `retrieval`, `embedding`, or `llm`.
2505
+ */
2506
+ kind: llmobs.spanKind,
2507
+
2508
+ /**
2509
+ * The ID of the underlying user session. Required for tracking sessions.
2510
+ */
2511
+ sessionId?: string,
2512
+
2513
+ /**
2514
+ * The name of the ML application that the agent is orchestrating.
2515
+ * If not provided, the default value will be set to mlApp provided during initalization, or `DD_LLMOBS_ML_APP`.
2516
+ */
2517
+ mlApp?: string,
2518
+
2519
+ /**
2520
+ * The name of the invoked LLM or embedding model. Only used on `llm` and `embedding` spans.
2521
+ */
2522
+ modelName?: string,
2523
+
2524
+ /**
2525
+ * The name of the invoked LLM or embedding model provider. Only used on `llm` and `embedding` spans.
2526
+ * If not provided for LLM or embedding spans, a default value of 'custom' will be set.
2527
+ */
2528
+ modelProvider?: string,
2529
+ }
2530
+
2531
+ interface LLMObsNamedSpanOptions extends LLMObsSpanOptions {
2532
+ /**
2533
+ * The name of the traced operation. This is a required option.
2534
+ */
2535
+ name: string,
2536
+ }
2537
+
2538
+ interface LLMObsNamelessSpanOptions extends LLMObsSpanOptions {
2539
+ /**
2540
+ * The name of the traced operation.
2541
+ */
2542
+ name?: string,
2543
+ }
2544
+
2545
+ /**
2546
+ * Options for enabling LLM Observability tracing.
2547
+ */
2548
+ interface LLMObsEnableOptions {
2549
+ /**
2550
+ * The name of your ML application.
2551
+ */
2552
+ mlApp?: string,
2553
+
2554
+ /**
2555
+ * Set to `true` to disbale sending data that requires a Datadog Agent.
2556
+ */
2557
+ agentlessEnabled?: boolean,
2558
+ }
2559
+
2560
+ /** @hidden */
2561
+ type spanKind = 'agent' | 'workflow' | 'task' | 'tool' | 'retrieval' | 'embedding' | 'llm'
2562
+ }
2183
2563
  }
2184
2564
 
2185
2565
  /**
package/init.js CHANGED
@@ -1,58 +1,9 @@
1
1
  'use strict'
2
2
 
3
- const path = require('path')
4
- const Module = require('module')
5
- const semver = require('semver')
6
- const log = require('./packages/dd-trace/src/log')
7
- const { isTrue } = require('./packages/dd-trace/src/util')
8
- const telemetry = require('./packages/dd-trace/src/telemetry/init-telemetry')
3
+ /* eslint-disable no-var */
9
4
 
10
- let initBailout = false
11
- let clobberBailout = false
12
- const forced = isTrue(process.env.DD_INJECT_FORCE)
5
+ var guard = require('./packages/dd-trace/src/guardrails')
13
6
 
14
- if (process.env.DD_INJECTION_ENABLED) {
15
- // If we're running via single-step install, and we're not in the app's
16
- // node_modules, then we should not initialize the tracer. This prevents
17
- // single-step-installed tracer from clobbering the manually-installed tracer.
18
- let resolvedInApp
19
- const entrypoint = process.argv[1]
20
- try {
21
- resolvedInApp = Module.createRequire(entrypoint).resolve('dd-trace')
22
- } catch (e) {
23
- // Ignore. If we can't resolve the module, we assume it's not in the app.
24
- }
25
- if (resolvedInApp) {
26
- const ourselves = path.join(__dirname, 'index.js')
27
- if (ourselves !== resolvedInApp) {
28
- clobberBailout = true
29
- }
30
- }
31
-
32
- // If we're running via single-step install, and the runtime doesn't match
33
- // the engines field in package.json, then we should not initialize the tracer.
34
- if (!clobberBailout) {
35
- const { engines } = require('./package.json')
36
- const version = process.versions.node
37
- if (!semver.satisfies(version, engines.node)) {
38
- initBailout = true
39
- telemetry([
40
- { name: 'abort', tags: ['reason:incompatible_runtime'] },
41
- { name: 'abort.runtime', tags: [] }
42
- ])
43
- log.info('Aborting application instrumentation due to incompatible_runtime.')
44
- log.info(`Found incompatible runtime nodejs ${version}, Supported runtimes: nodejs ${engines.node}.`)
45
- if (forced) {
46
- log.info('DD_INJECT_FORCE enabled, allowing unsupported runtimes and continuing.')
47
- }
48
- }
49
- }
50
- }
51
-
52
- if (!clobberBailout && (!initBailout || forced)) {
53
- const tracer = require('.')
54
- tracer.init()
55
- module.exports = tracer
56
- telemetry('complete', [`injection_forced:${forced && initBailout ? 'true' : 'false'}`])
57
- log.info('Application instrumentation bootstrapping complete')
58
- }
7
+ module.exports = guard(function () {
8
+ return require('.').init()
9
+ })