dd-trace 5.58.0 → 5.59.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 (165) hide show
  1. package/LICENSE-3rdparty.csv +1 -0
  2. package/ci/cypress/after-run.js +2 -0
  3. package/ci/cypress/after-spec.js +2 -0
  4. package/ci/cypress/plugin.js +2 -0
  5. package/ci/cypress/polyfills.js +2 -0
  6. package/ci/cypress/support.js +2 -0
  7. package/ci/init.js +2 -0
  8. package/index.d.ts +7 -0
  9. package/init.js +0 -2
  10. package/initialize.mjs +2 -0
  11. package/package.json +36 -7
  12. package/packages/datadog-code-origin/index.js +14 -9
  13. package/packages/datadog-instrumentations/src/apollo.js +7 -10
  14. package/packages/datadog-instrumentations/src/avsc.js +2 -0
  15. package/packages/datadog-instrumentations/src/child_process.js +21 -42
  16. package/packages/datadog-instrumentations/src/cucumber.js +10 -8
  17. package/packages/datadog-instrumentations/src/cypress.js +2 -0
  18. package/packages/datadog-instrumentations/src/fastify.js +19 -1
  19. package/packages/datadog-instrumentations/src/helpers/hooks.js +1 -0
  20. package/packages/datadog-instrumentations/src/helpers/register.js +1 -1
  21. package/packages/datadog-instrumentations/src/hono.js +102 -0
  22. package/packages/datadog-instrumentations/src/langchain.js +21 -0
  23. package/packages/datadog-instrumentations/src/mocha/common.js +2 -0
  24. package/packages/datadog-instrumentations/src/mocha.js +2 -0
  25. package/packages/datadog-instrumentations/src/nyc.js +2 -0
  26. package/packages/datadog-instrumentations/src/orchestrion-config/index.js +32 -0
  27. package/packages/datadog-instrumentations/src/playwright.js +5 -1
  28. package/packages/datadog-instrumentations/src/protobufjs.js +2 -0
  29. package/packages/datadog-instrumentations/src/selenium.js +2 -0
  30. package/packages/datadog-instrumentations/src/vitest.js +2 -0
  31. package/packages/datadog-plugin-avsc/src/index.js +2 -0
  32. package/packages/datadog-plugin-avsc/src/schema_iterator.js +2 -0
  33. package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/index.js +2 -0
  34. package/packages/datadog-plugin-child_process/src/index.js +30 -10
  35. package/packages/datadog-plugin-cypress/src/after-run.js +2 -0
  36. package/packages/datadog-plugin-cypress/src/after-spec.js +2 -0
  37. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +8 -3
  38. package/packages/datadog-plugin-cypress/src/index.js +2 -0
  39. package/packages/datadog-plugin-cypress/src/plugin.js +2 -0
  40. package/packages/datadog-plugin-cypress/src/support.js +4 -2
  41. package/packages/datadog-plugin-google-cloud-vertexai/src/utils.js +2 -0
  42. package/packages/datadog-plugin-graphql/src/utils.js +2 -0
  43. package/packages/datadog-plugin-hono/src/index.js +28 -0
  44. package/packages/datadog-plugin-jest/src/index.js +2 -0
  45. package/packages/datadog-plugin-jest/src/util.js +2 -0
  46. package/packages/datadog-plugin-kafkajs/src/batch-consumer.js +2 -0
  47. package/packages/datadog-plugin-langchain/src/tracing.js +36 -4
  48. package/packages/datadog-plugin-nyc/src/index.js +2 -0
  49. package/packages/datadog-plugin-oracledb/src/connection-parser.js +2 -0
  50. package/packages/datadog-plugin-protobufjs/src/index.js +2 -0
  51. package/packages/datadog-plugin-protobufjs/src/schema_iterator.js +2 -0
  52. package/packages/datadog-plugin-selenium/src/index.js +2 -0
  53. package/packages/datadog-plugin-vitest/src/index.js +2 -0
  54. package/packages/dd-trace/src/appsec/iast/iast-context.js +5 -1
  55. package/packages/dd-trace/src/appsec/iast/index.js +2 -0
  56. package/packages/dd-trace/src/appsec/iast/overhead-controller.js +1 -1
  57. package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter-esm.mjs +0 -2
  58. package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +2 -0
  59. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-regex.js +2 -0
  60. package/packages/dd-trace/src/appsec/iast/vulnerabilities.js +2 -0
  61. package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +3 -3
  62. package/packages/dd-trace/src/appsec/rasp/fs-plugin.js +18 -11
  63. package/packages/dd-trace/src/appsec/rasp/utils.js +1 -1
  64. package/packages/dd-trace/src/appsec/recommended.json +88 -2
  65. package/packages/dd-trace/src/appsec/reporter.js +7 -7
  66. package/packages/dd-trace/src/appsec/stack_trace.js +11 -11
  67. package/packages/dd-trace/src/appsec/telemetry/common.js +1 -1
  68. package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +2 -2
  69. package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +3 -3
  70. package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +2 -0
  71. package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +3 -1
  72. package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +2 -0
  73. package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +2 -0
  74. package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +2 -0
  75. package/packages/dd-trace/src/ci-visibility/telemetry.js +2 -0
  76. package/packages/dd-trace/src/ci-visibility/test-api-manual/test-api-manual-plugin.js +2 -0
  77. package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +7 -3
  78. package/packages/dd-trace/src/config.js +4 -0
  79. package/packages/dd-trace/src/config_stable.js +2 -0
  80. package/packages/dd-trace/src/datastreams/checkpointer.js +2 -0
  81. package/packages/dd-trace/src/datastreams/context.js +2 -0
  82. package/packages/dd-trace/src/datastreams/encoding.js +2 -0
  83. package/packages/dd-trace/src/datastreams/fnv.js +2 -0
  84. package/packages/dd-trace/src/datastreams/pathway.js +11 -9
  85. package/packages/dd-trace/src/datastreams/processor.js +8 -7
  86. package/packages/dd-trace/src/datastreams/schemas/schema.js +2 -0
  87. package/packages/dd-trace/src/datastreams/schemas/schema_builder.js +45 -36
  88. package/packages/dd-trace/src/datastreams/schemas/schema_sampler.js +2 -0
  89. package/packages/dd-trace/src/datastreams/writer.js +2 -0
  90. package/packages/dd-trace/src/debugger/devtools_client/index.js +12 -4
  91. package/packages/dd-trace/src/debugger/devtools_client/inspector_promises_polyfill.js +2 -0
  92. package/packages/dd-trace/src/debugger/devtools_client/remote_config.js +8 -5
  93. package/packages/dd-trace/src/debugger/devtools_client/snapshot/symbols.js +1 -1
  94. package/packages/dd-trace/src/debugger/index.js +36 -9
  95. package/packages/dd-trace/src/encode/tags-processors.js +2 -0
  96. package/packages/dd-trace/src/exporters/common/agent-info-exporter.js +2 -0
  97. package/packages/dd-trace/src/exporters/common/util.js +2 -0
  98. package/packages/dd-trace/src/exporters/span-stats/index.js +2 -0
  99. package/packages/dd-trace/src/exporters/span-stats/writer.js +2 -0
  100. package/packages/dd-trace/src/external-logger/src/index.js +2 -0
  101. package/packages/dd-trace/src/git_metadata_tagger.js +2 -0
  102. package/packages/dd-trace/src/git_properties.js +2 -0
  103. package/packages/dd-trace/src/guardrails/index.js +3 -4
  104. package/packages/dd-trace/src/guardrails/log.js +2 -2
  105. package/packages/dd-trace/src/guardrails/telemetry.js +16 -14
  106. package/packages/dd-trace/src/guardrails/util.js +0 -2
  107. package/packages/dd-trace/src/llmobs/plugins/bedrockruntime.js +2 -0
  108. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/index.js +5 -0
  109. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/tool.js +15 -0
  110. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/vectorstore.js +36 -0
  111. package/packages/dd-trace/src/llmobs/plugins/langchain/index.js +47 -4
  112. package/packages/dd-trace/src/llmobs/tagger.js +10 -1
  113. package/packages/dd-trace/src/noop/dogstatsd.js +2 -0
  114. package/packages/dd-trace/src/opentracing/propagation/text_map_dsm.js +2 -0
  115. package/packages/dd-trace/src/payload-tagging/config/index.js +2 -0
  116. package/packages/dd-trace/src/payload-tagging/index.js +2 -0
  117. package/packages/dd-trace/src/payload-tagging/tagging.js +2 -0
  118. package/packages/dd-trace/src/plugins/apollo.js +2 -0
  119. package/packages/dd-trace/src/plugins/ci_plugin.js +8 -3
  120. package/packages/dd-trace/src/plugins/index.js +1 -0
  121. package/packages/dd-trace/src/plugins/util/ci.js +2 -0
  122. package/packages/dd-trace/src/plugins/util/env.js +2 -0
  123. package/packages/dd-trace/src/plugins/util/git.js +40 -5
  124. package/packages/dd-trace/src/plugins/util/inferred_proxy.js +2 -0
  125. package/packages/dd-trace/src/plugins/util/llm.js +2 -0
  126. package/packages/dd-trace/src/plugins/util/serverless.js +2 -0
  127. package/packages/dd-trace/src/plugins/util/stacktrace.js +178 -50
  128. package/packages/dd-trace/src/plugins/util/tags.js +17 -1
  129. package/packages/dd-trace/src/plugins/util/test.js +9 -4
  130. package/packages/dd-trace/src/plugins/util/url.js +2 -0
  131. package/packages/dd-trace/src/plugins/util/user-provided-git.js +2 -0
  132. package/packages/dd-trace/src/profiling/exporters/event_serializer.js +4 -0
  133. package/packages/dd-trace/src/profiling/profiler.js +89 -70
  134. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns.js +2 -0
  135. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_lookup.js +2 -0
  136. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_lookupservice.js +2 -0
  137. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_resolve.js +2 -0
  138. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_reverse.js +2 -0
  139. package/packages/dd-trace/src/profiling/profilers/event_plugins/event.js +2 -0
  140. package/packages/dd-trace/src/profiling/profilers/event_plugins/fs.js +2 -0
  141. package/packages/dd-trace/src/profiling/profilers/event_plugins/net.js +2 -0
  142. package/packages/dd-trace/src/profiling/profilers/events.js +2 -0
  143. package/packages/dd-trace/src/profiling/webspan-utils.js +2 -0
  144. package/packages/dd-trace/src/remote_config/capabilities.js +3 -1
  145. package/packages/dd-trace/src/remote_config/index.js +4 -0
  146. package/packages/dd-trace/src/service-naming/index.js +2 -0
  147. package/packages/dd-trace/src/service-naming/schemas/definition.js +2 -0
  148. package/packages/dd-trace/src/service-naming/schemas/util.js +2 -0
  149. package/packages/dd-trace/src/service-naming/schemas/v0/graphql.js +2 -0
  150. package/packages/dd-trace/src/service-naming/schemas/v0/index.js +2 -0
  151. package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +2 -0
  152. package/packages/dd-trace/src/service-naming/schemas/v0/serverless.js +2 -0
  153. package/packages/dd-trace/src/service-naming/schemas/v0/storage.js +2 -0
  154. package/packages/dd-trace/src/service-naming/schemas/v0/web.js +2 -0
  155. package/packages/dd-trace/src/service-naming/schemas/v1/graphql.js +2 -0
  156. package/packages/dd-trace/src/service-naming/schemas/v1/index.js +2 -0
  157. package/packages/dd-trace/src/service-naming/schemas/v1/messaging.js +2 -0
  158. package/packages/dd-trace/src/service-naming/schemas/v1/serverless.js +2 -0
  159. package/packages/dd-trace/src/service-naming/schemas/v1/storage.js +2 -0
  160. package/packages/dd-trace/src/service-naming/schemas/v1/web.js +2 -0
  161. package/packages/dd-trace/src/span_stats.js +2 -0
  162. package/packages/dd-trace/src/supported-configurations.json +2 -0
  163. package/packages/dd-trace/src/telemetry/send-data.js +2 -0
  164. package/register.js +4 -0
  165. package/version.js +0 -3
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const { addHook, channel } = require('./helpers/instrument')
2
4
  const shimmer = require('../../datadog-shimmer')
3
5
  const { getEnvironmentVariable } = require('../../dd-trace/src/config-helper')
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  module.exports = `
2
4
  version: 1
3
5
  dc_module: dc-polyfill
@@ -51,4 +53,34 @@ instrumentations:
51
53
  class: Embeddings
52
54
  operator: traceSync
53
55
  channel_name: "Embeddings_constructor"
56
+ - module_name: "@langchain/core"
57
+ version_range: ">=0.1.0"
58
+ file_path: dist/tools/index.js
59
+ function_query:
60
+ name: invoke
61
+ type: method
62
+ kind: async
63
+ class: StructuredTool
64
+ operator: tracePromise
65
+ channel_name: "Tool_invoke"
66
+ - module_name: "@langchain/core"
67
+ version_range: ">=0.1.0"
68
+ file_path: dist/vectorstores.js
69
+ function_query:
70
+ name: similaritySearch
71
+ type: method
72
+ kind: async
73
+ class: VectorStore
74
+ operator: tracePromise
75
+ channel_name: "VectorStore_similaritySearch"
76
+ - module_name: "@langchain/core"
77
+ version_range: ">=0.1.0"
78
+ file_path: dist/vectorstores.js
79
+ function_query:
80
+ name: similaritySearchWithScore
81
+ type: method
82
+ kind: async
83
+ class: VectorStore
84
+ operator: tracePromise
85
+ channel_name: "VectorStore_similaritySearchWithScore"
54
86
  `
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const satisfies = require('semifies')
2
4
 
3
5
  const { addHook, channel } = require('./helpers/instrument')
@@ -335,7 +337,9 @@ function testEndHandler (test, annotations, testStatus, error, isTimeout, isMain
335
337
  testStatuses.push(testStatus)
336
338
  }
337
339
 
338
- if (testStatuses.length === testManagementAttemptToFixRetries + 1) {
340
+ const testProperties = getTestProperties(test)
341
+
342
+ if (testStatuses.length === testManagementAttemptToFixRetries + 1 && testProperties.attemptToFix) {
339
343
  if (testStatuses.includes('fail')) {
340
344
  test._ddHasFailedAttemptToFixRetries = true
341
345
  }
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const shimmer = require('../../datadog-shimmer')
2
4
  const { addHook } = require('./helpers/instrument')
3
5
 
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const { addHook, channel } = require('./helpers/instrument')
2
4
  const shimmer = require('../../datadog-shimmer')
3
5
 
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const { addHook, channel } = require('./helpers/instrument')
2
4
  const shimmer = require('../../datadog-shimmer')
3
5
  const log = require('../../dd-trace/src/log')
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const SchemaPlugin = require('../../dd-trace/src/plugins/schema')
2
4
  const SchemaExtractor = require('./schema_iterator')
3
5
 
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const AVRO = 'avro'
2
4
  const {
3
5
  SCHEMA_DEFINITION,
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const CompositePlugin = require('../../../../dd-trace/src/plugins/composite')
2
4
  const BedrockRuntimeTracing = require('./tracing')
3
5
  const BedrockRuntimeLLMObsPlugin = require('../../../../dd-trace/src/llmobs/plugins/bedrockruntime')
@@ -35,7 +35,9 @@ class ChildProcessPlugin extends TracingPlugin {
35
35
  return this._tracer
36
36
  }
37
37
 
38
- start ({ command, shell }) {
38
+ start (ctx) {
39
+ const { command, shell } = ctx
40
+
39
41
  if (typeof command !== 'string') {
40
42
  return
41
43
  }
@@ -58,10 +60,13 @@ class ChildProcessPlugin extends TracingPlugin {
58
60
  resource: (shell === true) ? 'sh' : cmdFields[0],
59
61
  type: 'system',
60
62
  meta
61
- })
63
+ }, ctx)
64
+
65
+ return ctx.currentStore
62
66
  }
63
67
 
64
- end ({ result, error }) {
68
+ end (ctx) {
69
+ const { result, error } = ctx
65
70
  let exitCode
66
71
 
67
72
  if (result !== undefined) {
@@ -74,17 +79,32 @@ class ChildProcessPlugin extends TracingPlugin {
74
79
  exitCode = error?.status || error?.code || 0
75
80
  }
76
81
 
77
- this.activeSpan?.setTag('cmd.exit_code', `${exitCode}`)
78
- this.activeSpan?.finish()
82
+ const span = ctx.currentStore?.span || this.activeSpan
83
+
84
+ span?.setTag('cmd.exit_code', `${exitCode}`)
85
+ span?.finish()
86
+
87
+ return ctx.parentStore
79
88
  }
80
89
 
81
- error (error) {
82
- this.addError(error)
90
+ error (ctx) {
91
+ const { error } = ctx
92
+
93
+ const span = ctx.currentStore?.span || this.activeSpan
94
+ this.addError(error, span)
95
+
96
+ return ctx.parentStore
83
97
  }
84
98
 
85
- asyncEnd ({ result }) {
86
- this.activeSpan?.setTag('cmd.exit_code', `${result}`)
87
- this.activeSpan?.finish()
99
+ asyncEnd (ctx) {
100
+ const { result } = ctx
101
+
102
+ const span = ctx.currentStore?.span || this.activeSpan
103
+
104
+ span?.setTag('cmd.exit_code', `${result}`)
105
+ span?.finish()
106
+
107
+ return ctx.parentStore
88
108
  }
89
109
  }
90
110
 
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const cypressPlugin = require('./cypress-plugin')
2
4
 
3
5
  module.exports = cypressPlugin.afterRun.bind(cypressPlugin)
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const cypressPlugin = require('./cypress-plugin')
2
4
 
3
5
  module.exports = cypressPlugin.afterSpec.bind(cypressPlugin)
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const {
2
4
  TEST_STATUS,
3
5
  TEST_IS_RUM_ACTIVE,
@@ -76,7 +78,8 @@ const {
76
78
  GIT_TAG,
77
79
  GIT_PULL_REQUEST_BASE_BRANCH_SHA,
78
80
  GIT_COMMIT_HEAD_SHA,
79
- GIT_PULL_REQUEST_BASE_BRANCH
81
+ GIT_PULL_REQUEST_BASE_BRANCH,
82
+ GIT_COMMIT_HEAD_MESSAGE
80
83
  } = require('../../dd-trace/src/plugins/util/tags')
81
84
  const {
82
85
  OS_VERSION,
@@ -238,7 +241,8 @@ class CypressPlugin {
238
241
  [GIT_COMMIT_MESSAGE]: commitMessage,
239
242
  [GIT_TAG]: tag,
240
243
  [GIT_PULL_REQUEST_BASE_BRANCH_SHA]: pullRequestBaseSha,
241
- [GIT_COMMIT_HEAD_SHA]: commitHeadSha
244
+ [GIT_COMMIT_HEAD_SHA]: commitHeadSha,
245
+ [GIT_COMMIT_HEAD_MESSAGE]: commitHeadMessage
242
246
  } = this.testEnvironmentMetadata
243
247
 
244
248
  this.repositoryRoot = repositoryRoot || process.cwd()
@@ -258,7 +262,8 @@ class CypressPlugin {
258
262
  commitMessage,
259
263
  tag,
260
264
  pullRequestBaseSha,
261
- commitHeadSha
265
+ commitHeadSha,
266
+ commitHeadMessage
262
267
  }
263
268
  this.finishedTestsByFile = {}
264
269
  this.testStatuses = {}
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const Plugin = require('../../dd-trace/src/plugins/plugin')
2
4
 
3
5
  // Cypress plugin does not patch any library. This is just a placeholder to
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const NoopTracer = require('../../dd-trace/src/noop/tracer')
2
4
  const cypressPlugin = require('./cypress-plugin')
3
5
  const satisfies = require('semifies')
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  let isEarlyFlakeDetectionEnabled = false
2
4
  let isKnownTestsEnabled = false
3
5
  let knownTestsForSuite = []
@@ -28,8 +30,8 @@ function isNewTest (test) {
28
30
  }
29
31
 
30
32
  function getTestProperties (testName) {
31
- // We neeed to do it in this way because of compatibility with older versions as '?' is not supported in older
32
- // versions of Cypress
33
+ // TODO: Use optional chaining when we drop support for older Cypress versions, which will happen when dd-trace@5 is
34
+ // EoL. Until then, this files needs to support Node.js 16.
33
35
  const properties = testManagementTests[testName] && testManagementTests[testName].properties || {}
34
36
 
35
37
  const { attempt_to_fix: isAttemptToFix, disabled: isDisabled, quarantined: isQuarantined } = properties
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  function extractModel (instance) {
2
4
  const model = instance.model || instance.resourcePath || instance.publisherModelEndpoint
3
5
  return model?.split('/').pop()
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  function extractErrorIntoSpanEvent (config, span, exc) {
2
4
  const attributes = {}
3
5
 
@@ -0,0 +1,28 @@
1
+ 'use strict'
2
+
3
+ const RouterPlugin = require('../../datadog-plugin-router/src')
4
+ const web = require('../../dd-trace/src/plugins/util/web')
5
+
6
+ class HonoPlugin extends RouterPlugin {
7
+ static get id () {
8
+ return 'hono'
9
+ }
10
+
11
+ constructor (...args) {
12
+ super(...args)
13
+
14
+ this.addSub('apm:hono:request:handle', ({ req }) => {
15
+ this.setFramework(req, 'hono', this.config)
16
+ })
17
+
18
+ this.addSub('apm:hono:request:route', ({ req, route }) => {
19
+ web.setRoute(req, route)
20
+ })
21
+
22
+ this.addSub('apm:hono:request:error', ({ req, error }) => {
23
+ web.addError(req, error)
24
+ })
25
+ }
26
+ }
27
+
28
+ module.exports = HonoPlugin
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const CiPlugin = require('../../dd-trace/src/plugins/ci_plugin')
2
4
  const { storage } = require('../../datadog-core')
3
5
  const { getEnvironmentVariable } = require('../../dd-trace/src/config-helper')
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const { readFileSync } = require('fs')
2
4
  const { parse, extract } = require('jest-docblock')
3
5
 
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const ConsumerPlugin = require('../../dd-trace/src/plugins/consumer')
2
4
  const { getMessageSize } = require('../../dd-trace/src/datastreams')
3
5
  const { convertToTextMap } = require('./utils')
@@ -40,9 +40,14 @@ class BaseLangChainTracingPlugin extends TracingPlugin {
40
40
 
41
41
  // Runnable interfaces have an `lc_namespace` property
42
42
  const ns = ctx.self.lc_namespace || ctx.namespace
43
- const resource = ctx.resource = [...ns, ctx.self.constructor.name].join('.')
44
43
 
45
- const handler = this.handlers[type]
44
+ const resourceParts = [...ns, ctx.self.constructor.name]
45
+ if (type === 'tool') {
46
+ resourceParts.push(ctx.instance.name)
47
+ }
48
+ const resource = ctx.resource = resourceParts.join('.')
49
+
50
+ const handler = this.handlers[type] || this.handlers.default
46
51
 
47
52
  const instance = ctx.instance
48
53
  const apiKey = handler.extractApiKey(instance)
@@ -78,7 +83,7 @@ class BaseLangChainTracingPlugin extends TracingPlugin {
78
83
 
79
84
  const { type } = ctx
80
85
 
81
- const handler = this.handlers[type]
86
+ const handler = this.handlers[type] || this.handlers.default
82
87
  const tags = handler.getSpanEndTags(ctx, span) || {}
83
88
 
84
89
  span.addTags(tags)
@@ -139,11 +144,38 @@ class EmbeddingsEmbedDocumentsPlugin extends BaseLangChainTracingPlugin {
139
144
  }
140
145
  }
141
146
 
147
+ class ToolInvokePlugin extends BaseLangChainTracingPlugin {
148
+ static get id () { return 'langchain_tool_invoke' }
149
+ static get lcType () { return 'tool' }
150
+ static get prefix () {
151
+ return 'tracing:orchestrion:@langchain/core:Tool_invoke'
152
+ }
153
+ }
154
+
155
+ class VectorStoreSimilaritySearchPlugin extends BaseLangChainTracingPlugin {
156
+ static get id () { return 'langchain_vectorstore_similarity_search' }
157
+ static get lcType () { return 'similarity_search' }
158
+ static get prefix () {
159
+ return 'tracing:orchestrion:@langchain/core:VectorStore_similaritySearch'
160
+ }
161
+ }
162
+
163
+ class VectorStoreSimilaritySearchWithScorePlugin extends BaseLangChainTracingPlugin {
164
+ static get id () { return 'langchain_vectorstore_similarity_search_with_score' }
165
+ static get lcType () { return 'similarity_search' }
166
+ static get prefix () {
167
+ return 'tracing:orchestrion:@langchain/core:VectorStore_similaritySearchWithScore'
168
+ }
169
+ }
170
+
142
171
  module.exports = [
143
172
  RunnableSequenceInvokePlugin,
144
173
  RunnableSequenceBatchPlugin,
145
174
  BaseChatModelGeneratePlugin,
146
175
  BaseLLMGeneratePlugin,
147
176
  EmbeddingsEmbedQueryPlugin,
148
- EmbeddingsEmbedDocumentsPlugin
177
+ EmbeddingsEmbedDocumentsPlugin,
178
+ ToolInvokePlugin,
179
+ VectorStoreSimilaritySearchPlugin,
180
+ VectorStoreSimilaritySearchWithScorePlugin
149
181
  ]
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const CiPlugin = require('../../dd-trace/src/plugins/ci_plugin')
2
4
 
3
5
  class NycPlugin extends CiPlugin {
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const { URL } = require('url')
2
4
  const log = require('../../dd-trace/src/log')
3
5
 
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const SchemaPlugin = require('../../dd-trace/src/plugins/schema')
2
4
  const SchemaExtractor = require('./schema_iterator')
3
5
 
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const PROTOBUF = 'protobuf'
2
4
  const {
3
5
  SCHEMA_DEFINITION,
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const CiPlugin = require('../../dd-trace/src/plugins/ci_plugin')
2
4
  const { storage } = require('../../datadog-core')
3
5
 
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const CiPlugin = require('../../dd-trace/src/plugins/ci_plugin')
2
4
  const { storage } = require('../../datadog-core')
3
5
  const { getEnvironmentVariable } = require('../../dd-trace/src/config-helper')
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const IAST_CONTEXT_KEY = Symbol('_dd.iast.context')
2
4
  const IAST_TRANSACTION_ID = Symbol('_dd.iast.transactionId')
3
5
 
@@ -52,7 +54,9 @@ function cleanIastContext (store, context, iastContext) {
52
54
  context[IAST_CONTEXT_KEY] = null
53
55
  }
54
56
  if (iastContext) {
55
- Object.keys(iastContext).forEach(key => delete iastContext[key])
57
+ if (typeof iastContext === 'object') { // eslint-disable-line eslint-rules/eslint-safe-typeof-object
58
+ Object.keys(iastContext).forEach(key => delete iastContext[key])
59
+ }
56
60
  return true
57
61
  }
58
62
  return false
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const vulnerabilityReporter = require('./vulnerability-reporter')
2
4
  const { enableAllAnalyzers, disableAllAnalyzers } = require('./analyzers')
3
5
  const web = require('../../plugins/util/web')
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const LRUCache = require('lru-cache')
3
+ const { LRUCache } = require('lru-cache')
4
4
  const web = require('../../plugins/util/web')
5
5
  const vulnerabilities = require('./vulnerabilities')
6
6
 
@@ -1,5 +1,3 @@
1
- 'use strict'
2
-
3
1
  import path from 'path'
4
2
  import { URL } from 'url'
5
3
  import { getName } from '../telemetry/verbosity.js'
@@ -1,5 +1,7 @@
1
1
  'use strict'
2
2
 
3
+ /* eslint n/no-unsupported-features/node-builtins: ['error', { ignores: ['module.register'] }] */
4
+
3
5
  const Module = require('module')
4
6
  const { pathToFileURL } = require('url')
5
7
  const { MessageChannel } = require('worker_threads')
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  // eslint-disable-next-line @stylistic/max-len
2
4
  const DEFAULT_IAST_REDACTION_NAME_PATTERN = '(?:p(?:ass)?w(?:or)?d|pass(?:_?phrase)?|secret|(?:api_?|private_?|public_?|access_?|secret_?)key(?:_?id)?|token|consumer_?(?:id|key|secret)|sign(?:ed|ature)?|auth(?:entication|orization)?|(?:sur|last)name|user(?:name)?|address|e?mail)'
3
5
  // eslint-disable-next-line @stylistic/max-len
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  module.exports = {
2
4
  COMMAND_INJECTION: 'COMMAND_INJECTION',
3
5
  CODE_INJECTION: 'CODE_INJECTION',
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const LRU = require('lru-cache')
3
+ const { LRUCache } = require('lru-cache')
4
4
  const vulnerabilitiesFormatter = require('./vulnerabilities-formatter')
5
5
  const { IAST_ENABLED_TAG_KEY, IAST_JSON_TAG_KEY } = require('./tags')
6
6
  const { keepTrace } = require('../../priority_sampler')
@@ -10,7 +10,7 @@ const { ASM } = require('../../standalone/product')
10
10
 
11
11
  const VULNERABILITIES_KEY = 'vulnerabilities'
12
12
  const VULNERABILITY_HASHES_MAX_SIZE = 1000
13
- const VULNERABILITY_HASHES = new LRU({ max: VULNERABILITY_HASHES_MAX_SIZE })
13
+ const VULNERABILITY_HASHES = new LRUCache({ max: VULNERABILITY_HASHES_MAX_SIZE })
14
14
  const RESET_VULNERABILITY_CACHE_INTERVAL = 60 * 60 * 1000 // 1 hour
15
15
 
16
16
  let tracer
@@ -114,7 +114,7 @@ function isDuplicatedVulnerability (vulnerability) {
114
114
  }
115
115
 
116
116
  function getVulnerabilityCallSiteFrames () {
117
- return getCallsiteFrames(stackTraceMaxDepth)
117
+ return getCallsiteFrames(stackTraceMaxDepth, getVulnerabilityCallSiteFrames)
118
118
  }
119
119
 
120
120
  function replaceCallSiteFromSourceMap (callsite) {
@@ -14,25 +14,31 @@ const enabledFor = {
14
14
 
15
15
  let fsPlugin
16
16
 
17
- function enterWith (fsProps, store = storage('legacy').getStore()) {
17
+ function getStoreToStart (fsProps, store = storage('legacy').getStore()) {
18
18
  if (store && !store.fs?.opExcluded) {
19
- storage('legacy').enterWith({
19
+ return {
20
20
  ...store,
21
21
  fs: {
22
22
  ...store.fs,
23
23
  ...fsProps,
24
24
  parentStore: store
25
25
  }
26
- })
26
+ }
27
27
  }
28
+
29
+ return store
28
30
  }
29
31
 
30
32
  class AppsecFsPlugin extends Plugin {
31
33
  enable () {
32
- this.addSub('apm:fs:operation:start', this._onFsOperationStart)
33
- this.addSub('apm:fs:operation:finish', this._onFsOperationFinishOrRenderEnd)
34
- this.addSub('tracing:datadog:express:response:render:start', this._onResponseRenderStart)
35
- this.addSub('tracing:datadog:express:response:render:end', this._onFsOperationFinishOrRenderEnd)
34
+ this.addBind('apm:fs:operation:start', this._onFsOperationStart)
35
+ this.addBind('apm:fs:operation:finish', this._onFsOperationFinishOrRenderEnd)
36
+ this.addBind('tracing:datadog:express:response:render:start', this._onResponseRenderStart)
37
+ this.addBind('tracing:datadog:express:response:render:end', this._onFsOperationFinishOrRenderEnd)
38
+ // TODO Remove this when dc-polyfill is fixed&updated
39
+ // hack to node 18 and early 20.x
40
+ // with dc-polyfill addBind is not enough to force a channel.hasSubscribers === true
41
+ this.addSub('tracing:datadog:express:response:render:start', () => {})
36
42
 
37
43
  super.configure(true)
38
44
  }
@@ -44,19 +50,20 @@ class AppsecFsPlugin extends Plugin {
44
50
  _onFsOperationStart () {
45
51
  const store = storage('legacy').getStore()
46
52
  if (store) {
47
- enterWith({ root: store.fs?.root === undefined }, store)
53
+ return getStoreToStart({ root: store.fs?.root === undefined }, store)
48
54
  }
49
55
  }
50
56
 
51
57
  _onResponseRenderStart () {
52
- enterWith({ opExcluded: true })
58
+ return getStoreToStart({ opExcluded: true })
53
59
  }
54
60
 
55
61
  _onFsOperationFinishOrRenderEnd () {
56
62
  const store = storage('legacy').getStore()
57
- if (store?.fs?.parentStore) {
58
- storage('legacy').enterWith(store.fs.parentStore)
63
+ if (store?.fs) {
64
+ return store.fs.parentStore
59
65
  }
66
+ return store
60
67
  }
61
68
  }
62
69
 
@@ -41,7 +41,7 @@ function handleResult (result, req, res, abortController, config, raspRule) {
41
41
  const ruleTriggered = !!result?.events?.length
42
42
 
43
43
  if (generateStackTraceAction && enabled && canReportStackTrace(rootSpan, maxStackTraces)) {
44
- const frames = getCallsiteFrames(maxDepth)
44
+ const frames = getCallsiteFrames(maxDepth, handleResult)
45
45
 
46
46
  reportStackTrace(
47
47
  rootSpan,