dd-trace 5.57.1 → 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 (206) hide show
  1. package/LICENSE-3rdparty.csv +3 -1
  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 +1 -6
  10. package/initialize.mjs +2 -0
  11. package/package.json +40 -9
  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/azure-functions.js +1 -1
  16. package/packages/datadog-instrumentations/src/child_process.js +22 -43
  17. package/packages/datadog-instrumentations/src/cucumber.js +10 -8
  18. package/packages/datadog-instrumentations/src/cypress.js +2 -0
  19. package/packages/datadog-instrumentations/src/fastify.js +19 -1
  20. package/packages/datadog-instrumentations/src/graphql.js +9 -0
  21. package/packages/datadog-instrumentations/src/helpers/hooks.js +1 -0
  22. package/packages/datadog-instrumentations/src/helpers/register.js +2 -2
  23. package/packages/datadog-instrumentations/src/hono.js +102 -0
  24. package/packages/datadog-instrumentations/src/jest.js +1 -1
  25. package/packages/datadog-instrumentations/src/langchain.js +21 -0
  26. package/packages/datadog-instrumentations/src/mocha/common.js +2 -0
  27. package/packages/datadog-instrumentations/src/mocha.js +2 -0
  28. package/packages/datadog-instrumentations/src/mysql2.js +6 -6
  29. package/packages/datadog-instrumentations/src/next.js +3 -1
  30. package/packages/datadog-instrumentations/src/nyc.js +2 -0
  31. package/packages/datadog-instrumentations/src/oracledb.js +24 -2
  32. package/packages/datadog-instrumentations/src/orchestrion-config/index.js +32 -0
  33. package/packages/datadog-instrumentations/src/playwright.js +5 -1
  34. package/packages/datadog-instrumentations/src/protobufjs.js +2 -0
  35. package/packages/datadog-instrumentations/src/selenium.js +2 -0
  36. package/packages/datadog-instrumentations/src/tedious.js +12 -17
  37. package/packages/datadog-instrumentations/src/vitest.js +2 -0
  38. package/packages/datadog-plugin-avsc/src/index.js +2 -0
  39. package/packages/datadog-plugin-avsc/src/schema_iterator.js +2 -0
  40. package/packages/datadog-plugin-aws-sdk/src/base.js +51 -1
  41. package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/index.js +2 -0
  42. package/packages/datadog-plugin-child_process/src/index.js +30 -10
  43. package/packages/datadog-plugin-child_process/src/scrub-cmd-params.js +1 -1
  44. package/packages/datadog-plugin-cypress/src/after-run.js +2 -0
  45. package/packages/datadog-plugin-cypress/src/after-spec.js +2 -0
  46. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +8 -3
  47. package/packages/datadog-plugin-cypress/src/index.js +2 -0
  48. package/packages/datadog-plugin-cypress/src/plugin.js +2 -0
  49. package/packages/datadog-plugin-cypress/src/support.js +21 -25
  50. package/packages/datadog-plugin-google-cloud-vertexai/src/utils.js +2 -0
  51. package/packages/datadog-plugin-graphql/src/tools/index.js +0 -2
  52. package/packages/datadog-plugin-graphql/src/tools/signature.js +0 -2
  53. package/packages/datadog-plugin-graphql/src/tools/transforms.js +0 -2
  54. package/packages/datadog-plugin-graphql/src/utils.js +2 -0
  55. package/packages/datadog-plugin-hono/src/index.js +28 -0
  56. package/packages/datadog-plugin-http/src/client.js +3 -4
  57. package/packages/datadog-plugin-http2/src/client.js +9 -8
  58. package/packages/datadog-plugin-jest/src/index.js +2 -0
  59. package/packages/datadog-plugin-jest/src/util.js +2 -0
  60. package/packages/datadog-plugin-kafkajs/src/batch-consumer.js +2 -0
  61. package/packages/datadog-plugin-langchain/src/handlers/chain.js +1 -1
  62. package/packages/datadog-plugin-langchain/src/handlers/language_models/chat_model.js +1 -1
  63. package/packages/datadog-plugin-langchain/src/handlers/language_models/llm.js +1 -1
  64. package/packages/datadog-plugin-langchain/src/tracing.js +36 -4
  65. package/packages/datadog-plugin-nyc/src/index.js +2 -0
  66. package/packages/datadog-plugin-oracledb/src/connection-parser.js +37 -0
  67. package/packages/datadog-plugin-oracledb/src/index.js +15 -17
  68. package/packages/datadog-plugin-protobufjs/src/index.js +2 -0
  69. package/packages/datadog-plugin-protobufjs/src/schema_iterator.js +2 -0
  70. package/packages/datadog-plugin-selenium/src/index.js +2 -0
  71. package/packages/datadog-plugin-tedious/src/index.js +10 -9
  72. package/packages/datadog-plugin-vitest/src/index.js +2 -0
  73. package/packages/dd-trace/src/appsec/iast/analyzers/injection-analyzer.js +6 -4
  74. package/packages/dd-trace/src/appsec/iast/analyzers/ssrf-analyzer.js +9 -0
  75. package/packages/dd-trace/src/appsec/iast/iast-context.js +5 -1
  76. package/packages/dd-trace/src/appsec/iast/index.js +2 -0
  77. package/packages/dd-trace/src/appsec/iast/overhead-controller.js +1 -1
  78. package/packages/dd-trace/src/appsec/iast/taint-tracking/operations-taint-object.js +5 -2
  79. package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter-esm.mjs +0 -2
  80. package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +2 -0
  81. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-regex.js +2 -0
  82. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/index.js +1 -0
  83. package/packages/dd-trace/src/appsec/iast/vulnerabilities.js +2 -0
  84. package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +3 -3
  85. package/packages/dd-trace/src/appsec/rasp/fs-plugin.js +18 -11
  86. package/packages/dd-trace/src/appsec/rasp/utils.js +1 -1
  87. package/packages/dd-trace/src/appsec/recommended.json +88 -2
  88. package/packages/dd-trace/src/appsec/reporter.js +68 -14
  89. package/packages/dd-trace/src/appsec/rule_manager.js +63 -171
  90. package/packages/dd-trace/src/appsec/sdk/track_event.js +3 -5
  91. package/packages/dd-trace/src/appsec/stack_trace.js +11 -11
  92. package/packages/dd-trace/src/appsec/telemetry/common.js +2 -2
  93. package/packages/dd-trace/src/appsec/telemetry/index.js +8 -0
  94. package/packages/dd-trace/src/appsec/telemetry/waf.js +5 -3
  95. package/packages/dd-trace/src/appsec/waf/diagnostics.js +15 -0
  96. package/packages/dd-trace/src/appsec/waf/index.js +47 -6
  97. package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +2 -2
  98. package/packages/dd-trace/src/appsec/waf/waf_manager.js +22 -12
  99. package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +3 -3
  100. package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +2 -0
  101. package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +3 -1
  102. package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +2 -0
  103. package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +2 -0
  104. package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +2 -0
  105. package/packages/dd-trace/src/ci-visibility/telemetry.js +2 -0
  106. package/packages/dd-trace/src/ci-visibility/test-api-manual/test-api-manual-plugin.js +2 -0
  107. package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +7 -3
  108. package/packages/dd-trace/src/config.js +15 -4
  109. package/packages/dd-trace/src/config_stable.js +2 -0
  110. package/packages/dd-trace/src/constants.js +1 -2
  111. package/packages/dd-trace/src/datastreams/checkpointer.js +2 -0
  112. package/packages/dd-trace/src/datastreams/context.js +2 -0
  113. package/packages/dd-trace/src/datastreams/encoding.js +2 -0
  114. package/packages/dd-trace/src/datastreams/fnv.js +2 -0
  115. package/packages/dd-trace/src/datastreams/pathway.js +11 -9
  116. package/packages/dd-trace/src/datastreams/processor.js +8 -7
  117. package/packages/dd-trace/src/datastreams/schemas/schema.js +2 -0
  118. package/packages/dd-trace/src/datastreams/schemas/schema_builder.js +45 -36
  119. package/packages/dd-trace/src/datastreams/schemas/schema_sampler.js +2 -0
  120. package/packages/dd-trace/src/datastreams/writer.js +2 -0
  121. package/packages/dd-trace/src/debugger/devtools_client/index.js +12 -4
  122. package/packages/dd-trace/src/debugger/devtools_client/inspector_promises_polyfill.js +2 -0
  123. package/packages/dd-trace/src/debugger/devtools_client/remote_config.js +8 -5
  124. package/packages/dd-trace/src/debugger/devtools_client/snapshot/symbols.js +1 -1
  125. package/packages/dd-trace/src/debugger/index.js +36 -9
  126. package/packages/dd-trace/src/encode/tags-processors.js +2 -0
  127. package/packages/dd-trace/src/exporters/common/agent-info-exporter.js +2 -0
  128. package/packages/dd-trace/src/exporters/common/request.js +1 -1
  129. package/packages/dd-trace/src/exporters/common/util.js +2 -0
  130. package/packages/dd-trace/src/exporters/span-stats/index.js +2 -0
  131. package/packages/dd-trace/src/exporters/span-stats/writer.js +2 -0
  132. package/packages/dd-trace/src/external-logger/src/index.js +2 -0
  133. package/packages/dd-trace/src/git_metadata_tagger.js +2 -0
  134. package/packages/dd-trace/src/git_properties.js +2 -0
  135. package/packages/dd-trace/src/guardrails/index.js +3 -4
  136. package/packages/dd-trace/src/guardrails/log.js +2 -2
  137. package/packages/dd-trace/src/guardrails/telemetry.js +16 -14
  138. package/packages/dd-trace/src/guardrails/util.js +0 -2
  139. package/packages/dd-trace/src/heap_snapshots.js +58 -0
  140. package/packages/dd-trace/src/llmobs/noop.js +1 -1
  141. package/packages/dd-trace/src/llmobs/plugins/bedrockruntime.js +2 -0
  142. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/index.js +5 -0
  143. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/tool.js +15 -0
  144. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/vectorstore.js +36 -0
  145. package/packages/dd-trace/src/llmobs/plugins/langchain/index.js +47 -4
  146. package/packages/dd-trace/src/llmobs/span_processor.js +1 -1
  147. package/packages/dd-trace/src/llmobs/tagger.js +10 -1
  148. package/packages/dd-trace/src/log/log.js +1 -1
  149. package/packages/dd-trace/src/noop/dogstatsd.js +2 -0
  150. package/packages/dd-trace/src/opentracing/propagation/text_map_dsm.js +2 -0
  151. package/packages/dd-trace/src/opentracing/span.js +1 -1
  152. package/packages/dd-trace/src/payload-tagging/config/index.js +2 -0
  153. package/packages/dd-trace/src/payload-tagging/index.js +3 -1
  154. package/packages/dd-trace/src/payload-tagging/tagging.js +4 -2
  155. package/packages/dd-trace/src/plugins/apollo.js +2 -0
  156. package/packages/dd-trace/src/plugins/ci_plugin.js +8 -3
  157. package/packages/dd-trace/src/plugins/index.js +1 -0
  158. package/packages/dd-trace/src/plugins/outbound.js +7 -0
  159. package/packages/dd-trace/src/plugins/util/ci.js +2 -0
  160. package/packages/dd-trace/src/plugins/util/env.js +2 -0
  161. package/packages/dd-trace/src/plugins/util/git.js +40 -5
  162. package/packages/dd-trace/src/plugins/util/inferred_proxy.js +2 -0
  163. package/packages/dd-trace/src/plugins/util/llm.js +2 -0
  164. package/packages/dd-trace/src/plugins/util/serverless.js +2 -0
  165. package/packages/dd-trace/src/plugins/util/stacktrace.js +178 -50
  166. package/packages/dd-trace/src/plugins/util/tags.js +17 -1
  167. package/packages/dd-trace/src/plugins/util/test.js +9 -4
  168. package/packages/dd-trace/src/plugins/util/url.js +2 -0
  169. package/packages/dd-trace/src/plugins/util/user-provided-git.js +2 -0
  170. package/packages/dd-trace/src/profiling/exporters/event_serializer.js +4 -0
  171. package/packages/dd-trace/src/profiling/profiler.js +89 -70
  172. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns.js +2 -0
  173. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_lookup.js +2 -0
  174. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_lookupservice.js +2 -0
  175. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_resolve.js +2 -0
  176. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_reverse.js +2 -0
  177. package/packages/dd-trace/src/profiling/profilers/event_plugins/event.js +2 -0
  178. package/packages/dd-trace/src/profiling/profilers/event_plugins/fs.js +2 -0
  179. package/packages/dd-trace/src/profiling/profilers/event_plugins/net.js +2 -0
  180. package/packages/dd-trace/src/profiling/profilers/events.js +2 -0
  181. package/packages/dd-trace/src/profiling/profilers/wall.js +2 -2
  182. package/packages/dd-trace/src/profiling/webspan-utils.js +2 -0
  183. package/packages/dd-trace/src/proxy.js +4 -0
  184. package/packages/dd-trace/src/remote_config/capabilities.js +3 -1
  185. package/packages/dd-trace/src/remote_config/index.js +4 -0
  186. package/packages/dd-trace/src/service-naming/index.js +2 -0
  187. package/packages/dd-trace/src/service-naming/schemas/definition.js +4 -9
  188. package/packages/dd-trace/src/service-naming/schemas/util.js +2 -0
  189. package/packages/dd-trace/src/service-naming/schemas/v0/graphql.js +2 -0
  190. package/packages/dd-trace/src/service-naming/schemas/v0/index.js +2 -0
  191. package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +2 -0
  192. package/packages/dd-trace/src/service-naming/schemas/v0/serverless.js +2 -0
  193. package/packages/dd-trace/src/service-naming/schemas/v0/storage.js +2 -0
  194. package/packages/dd-trace/src/service-naming/schemas/v0/web.js +2 -0
  195. package/packages/dd-trace/src/service-naming/schemas/v1/graphql.js +2 -0
  196. package/packages/dd-trace/src/service-naming/schemas/v1/index.js +2 -0
  197. package/packages/dd-trace/src/service-naming/schemas/v1/messaging.js +2 -0
  198. package/packages/dd-trace/src/service-naming/schemas/v1/serverless.js +2 -0
  199. package/packages/dd-trace/src/service-naming/schemas/v1/storage.js +4 -1
  200. package/packages/dd-trace/src/service-naming/schemas/v1/web.js +2 -0
  201. package/packages/dd-trace/src/span_stats.js +2 -0
  202. package/packages/dd-trace/src/supported-configurations.json +5 -0
  203. package/packages/dd-trace/src/telemetry/send-data.js +2 -0
  204. package/register.js +4 -0
  205. package/version.js +0 -3
  206. package/packages/dd-trace/src/payload-tagging/jsonpath-plus.js +0 -2094
@@ -0,0 +1,102 @@
1
+ 'use strict'
2
+
3
+ const shimmer = require('../../datadog-shimmer')
4
+ const {
5
+ addHook,
6
+ channel
7
+ } = require('./helpers/instrument')
8
+
9
+ const routeChannel = channel('apm:hono:request:route')
10
+ const handleChannel = channel('apm:hono:request:handle')
11
+ const errorChannel = channel('apm:hono:request:error')
12
+
13
+ function wrapFetch (fetch) {
14
+ return function (request, env, executionCtx) {
15
+ handleChannel.publish({ req: env.incoming })
16
+ return fetch.apply(this, arguments)
17
+ }
18
+ }
19
+
20
+ function wrapCompose (compose) {
21
+ return function (middleware, onError, onNotFound) {
22
+ const instrumentedOnError = (...args) => {
23
+ const [error, context] = args
24
+ const req = context.env.incoming
25
+ errorChannel.publish({ req, error })
26
+ return onError(...args)
27
+ }
28
+
29
+ const instrumentedMiddlewares = middleware.map(h => {
30
+ const [[fn, meta], params] = h
31
+
32
+ // TODO: handle middleware instrumentation
33
+ const instrumentedFn = (...args) => {
34
+ const context = args[0]
35
+ const req = context.env.incoming
36
+ const route = meta.path
37
+ routeChannel.publish({
38
+ req,
39
+ route
40
+ })
41
+ return fn(...args)
42
+ }
43
+ return [[instrumentedFn, meta], params]
44
+ })
45
+ return compose.apply(this, [instrumentedMiddlewares, instrumentedOnError, onNotFound])
46
+ }
47
+ }
48
+
49
+ addHook({
50
+ name: 'hono',
51
+ versions: ['>=4'],
52
+ file: 'dist/hono.js'
53
+ }, hono => {
54
+ class Hono extends hono.Hono {
55
+ constructor (...args) {
56
+ super(...args)
57
+ shimmer.wrap(this, 'fetch', wrapFetch)
58
+ }
59
+ }
60
+
61
+ hono.Hono = Hono
62
+
63
+ return hono
64
+ })
65
+
66
+ addHook({
67
+ name: 'hono',
68
+ versions: ['>=4'],
69
+ file: 'dist/cjs/hono.js'
70
+ }, hono => {
71
+ class Hono extends hono.Hono {
72
+ constructor (...args) {
73
+ super(...args)
74
+ shimmer.wrap(this, 'fetch', wrapFetch)
75
+ }
76
+ }
77
+
78
+ return Object.create(hono, {
79
+ Hono: {
80
+ get () {
81
+ return Hono
82
+ },
83
+ enumerable: true,
84
+ }
85
+ })
86
+ })
87
+
88
+ addHook({
89
+ name: 'hono',
90
+ versions: ['>=4'],
91
+ file: 'dist/cjs/compose.js'
92
+ }, Compose => {
93
+ return shimmer.wrap(Compose, 'compose', wrapCompose, { replaceGetter: true })
94
+ })
95
+
96
+ addHook({
97
+ name: 'hono',
98
+ versions: ['>=4'],
99
+ file: 'dist/compose.js'
100
+ }, Compose => {
101
+ return shimmer.wrap(Compose, 'compose', wrapCompose)
102
+ })
@@ -1071,7 +1071,7 @@ function jestAdapterWrapper (jestAdapter, jestVersion) {
1071
1071
  const adapter = jestAdapter.default ?? jestAdapter
1072
1072
  const newAdapter = shimmer.wrapFunction(adapter, adapter => function () {
1073
1073
  const environment = arguments[2]
1074
- if (!environment) {
1074
+ if (!environment || !environment.testEnvironmentOptions) {
1075
1075
  return adapter.apply(this, arguments)
1076
1076
  }
1077
1077
  testSuiteStartCh.publish({
@@ -53,6 +53,27 @@ for (const extension of extensions) {
53
53
  return exports
54
54
  })
55
55
 
56
+ addHook({ name: '@langchain/core', file: `dist/tools/index.${extension}`, versions: ['>=0.1'] }, exports => {
57
+ if (extension === 'cjs') {
58
+ wrap(exports.StructuredTool.prototype, 'invoke', 'orchestrion:@langchain/core:Tool_invoke')
59
+ }
60
+ return exports
61
+ })
62
+
63
+ addHook({ name: '@langchain/core', file: `dist/vectorstores.${extension}`, versions: ['>=0.1'] }, exports => {
64
+ if (extension === 'cjs') {
65
+ wrap(
66
+ exports.VectorStore.prototype, 'similaritySearch', 'orchestrion:@langchain/core:VectorStore_similaritySearch'
67
+ )
68
+ wrap(
69
+ exports.VectorStore.prototype, 'similaritySearchWithScore',
70
+ 'orchestrion:@langchain/core:VectorStore_similaritySearchWithScore'
71
+ )
72
+ }
73
+
74
+ return exports
75
+ })
76
+
56
77
  addHook({ name: '@langchain/core', file: `dist/embeddings.${extension}`, versions: ['>=0.1'] }, exports => {
57
78
  if (extension === 'cjs') {
58
79
  shimmer.wrap(exports, 'Embeddings', Embeddings => {
@@ -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 { getCallSites } = require('../../../dd-trace/src/plugins/util/stacktrace')
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const { getEnvironmentVariable } = require('../../dd-trace/src/config-helper')
2
4
 
3
5
  if (getEnvironmentVariable('MOCHA_WORKER_ID')) {
@@ -35,7 +35,7 @@ function wrapConnection (Connection, version) {
35
35
  shimmer.wrap(Connection.prototype, 'query', query => function (sql, values, cb) {
36
36
  if (!startOuterQueryCh.hasSubscribers) return query.apply(this, arguments)
37
37
 
38
- if (typeof sql === 'object') sql = sql?.sql
38
+ if (sql !== null && typeof sql === 'object') sql = sql.sql
39
39
 
40
40
  if (!sql) return query.apply(this, arguments)
41
41
 
@@ -76,7 +76,7 @@ function wrapConnection (Connection, version) {
76
76
  shimmer.wrap(Connection.prototype, 'execute', execute => function (sql, values, cb) {
77
77
  if (!startOuterQueryCh.hasSubscribers) return execute.apply(this, arguments)
78
78
 
79
- if (typeof sql === 'object') sql = sql?.sql
79
+ if (sql !== null && typeof sql === 'object') sql = sql.sql
80
80
 
81
81
  if (!sql) return execute.apply(this, arguments)
82
82
 
@@ -167,7 +167,7 @@ function wrapPool (Pool, version) {
167
167
  shimmer.wrap(Pool.prototype, 'query', query => function (sql, values, cb) {
168
168
  if (!startOuterQueryCh.hasSubscribers) return query.apply(this, arguments)
169
169
 
170
- if (typeof sql === 'object') sql = sql?.sql
170
+ if (sql !== null && typeof sql === 'object') sql = sql.sql
171
171
 
172
172
  if (!sql) return query.apply(this, arguments)
173
173
 
@@ -206,7 +206,7 @@ function wrapPool (Pool, version) {
206
206
  shimmer.wrap(Pool.prototype, 'execute', execute => function (sql, values, cb) {
207
207
  if (!startOuterQueryCh.hasSubscribers) return execute.apply(this, arguments)
208
208
 
209
- if (typeof sql === 'object') sql = sql?.sql
209
+ if (sql !== null && typeof sql === 'object') sql = sql.sql
210
210
 
211
211
  if (!sql) return execute.apply(this, arguments)
212
212
 
@@ -239,7 +239,7 @@ function wrapPoolCluster (PoolCluster) {
239
239
 
240
240
  if (startOuterQueryCh.hasSubscribers && !wrappedPoolNamespaces.has(poolNamespace)) {
241
241
  shimmer.wrap(poolNamespace, 'query', query => function (sql, values, cb) {
242
- if (typeof sql === 'object') sql = sql?.sql
242
+ if (sql !== null && typeof sql === 'object') sql = sql.sql
243
243
 
244
244
  if (!sql) return query.apply(this, arguments)
245
245
 
@@ -274,7 +274,7 @@ function wrapPoolCluster (PoolCluster) {
274
274
  })
275
275
 
276
276
  shimmer.wrap(poolNamespace, 'execute', execute => function (sql, values, cb) {
277
- if (typeof sql === 'object') sql = sql?.sql
277
+ if (sql !== null && typeof sql === 'object') sql = sql.sql
278
278
 
279
279
  if (!sql) return execute.apply(this, arguments)
280
280
 
@@ -51,7 +51,9 @@ function wrapHandleApiRequest (handleApiRequest) {
51
51
  function wrapHandleApiRequestWithMatch (handleApiRequest) {
52
52
  return function (req, res, query, match) {
53
53
  return instrument(req, res, () => {
54
- const page = (match !== null && typeof match === 'object' && typeof match.definition === 'object')
54
+ const page = (
55
+ match !== null && typeof match === 'object' && match.definition !== null && typeof match.definition === 'object'
56
+ )
55
57
  ? match.definition.pathname
56
58
  : undefined
57
59
 
@@ -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')
@@ -38,12 +38,34 @@ addHook({ name: 'oracledb', versions: ['>=5'] }, oracledb => {
38
38
  }
39
39
 
40
40
  return new AsyncResource('apm:oracledb:inner-scope').runInAsyncScope(() => {
41
+ // The connAttrs are used to pass through the argument to the potential
42
+ // serviceName method a user might have passed through as well as parsing
43
+ // the connection string in v5.
41
44
  const connAttrs = connectionAttributes.get(this)
42
- startChannel.publish({ query: dbQuery, connAttrs })
45
+
46
+ const details = typeof this.hostName === 'string' ? this : this._impl
47
+
48
+ let hostname
49
+ let port
50
+ let dbInstance
51
+
52
+ if (details) {
53
+ dbInstance = details.serviceName
54
+ hostname = details.hostName ?? details.nscon?.ntAdapter?.hostName
55
+ port = String(details.port ?? details.nscon?.ntAdapter?.port ?? '')
56
+ }
57
+
58
+ startChannel.publish({
59
+ query: dbQuery,
60
+ connAttrs,
61
+ dbInstance,
62
+ port,
63
+ hostname,
64
+ })
43
65
  try {
44
66
  let result = execute.apply(this, arguments)
45
67
 
46
- if (result && typeof result.then === 'function') {
68
+ if (typeof result?.then === 'function') {
47
69
  result = result.then(
48
70
  x => {
49
71
  finish()
@@ -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
 
@@ -2,8 +2,7 @@
2
2
 
3
3
  const {
4
4
  channel,
5
- addHook,
6
- AsyncResource
5
+ addHook
7
6
  } = require('./helpers/instrument')
8
7
  const shimmer = require('../../datadog-shimmer')
9
8
 
@@ -22,30 +21,26 @@ addHook({ name: 'tedious', versions: ['>=1.0.0'] }, tedious => {
22
21
  return makeRequest.apply(this, arguments)
23
22
  }
24
23
 
25
- const callbackResource = new AsyncResource('bound-anonymous-fn')
26
- const asyncResource = new AsyncResource('bound-anonymous-fn')
27
-
28
24
  const connectionConfig = this.config
25
+ const ctx = { queryOrProcedure, connectionConfig }
29
26
 
30
- return asyncResource.runInAsyncScope(() => {
31
- const payload = { queryOrProcedure, connectionConfig }
32
- startCh.publish(payload)
33
- queryParent[queryField] = payload.sql
27
+ return startCh.runStores(ctx, () => {
28
+ queryParent[queryField] = ctx.sql
34
29
 
35
- const cb = callbackResource.bind(request.callback, request)
36
- request.callback = asyncResource.bind(function (error) {
30
+ const cb = request.callback
31
+ request.callback = function (error, ...args) {
37
32
  if (error) {
38
- errorCh.publish(error)
33
+ ctx.error = error
34
+ errorCh.publish(ctx)
39
35
  }
40
- finishCh.publish()
41
-
42
- return cb.apply(this, arguments)
43
- }, null, request)
36
+ return finishCh.runStores(ctx, cb, this, error, ...args)
37
+ }
44
38
 
45
39
  try {
46
40
  return makeRequest.apply(this, arguments)
47
41
  } catch (error) {
48
- errorCh.publish(error)
42
+ ctx.error = error
43
+ errorCh.publish(ctx)
49
44
 
50
45
  throw error
51
46
  }
@@ -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,
@@ -73,9 +73,25 @@ class BaseAwsSdkPlugin extends ClientPlugin {
73
73
  span.addTags(requestTags)
74
74
  }
75
75
 
76
+ this.enter(span)
76
77
  const store = storage('legacy').getStore()
77
78
 
78
- this.enter(span, store)
79
+ const peerServerlessStorage = storage('peerServerless')
80
+ if (!this._tracerConfig?._isInServerlessEnvironment()) return
81
+
82
+ // Try to resolve the hostname immediately; if not possible, keep enough
83
+ // information so the region callback can resolve it later.
84
+ const hostname = getHostname({ awsParams: request.params, awsService }, awsRegion)
85
+ const peerServerlessStore = {}
86
+ peerServerlessStorage.enterWith(peerServerlessStore)
87
+
88
+ if (hostname) {
89
+ span.setTag('peer.service', hostname)
90
+ peerServerlessStore.peerHostname = hostname
91
+ } else {
92
+ store.awsParams = request.params
93
+ store.awsService = awsService
94
+ }
79
95
  })
80
96
 
81
97
  this.addSub(`apm:aws:request:region:${this.serviceIdentifier}`, region => {
@@ -85,6 +101,17 @@ class BaseAwsSdkPlugin extends ClientPlugin {
85
101
  if (!span) return
86
102
  span.setTag('aws.region', region)
87
103
  span.setTag('region', region)
104
+
105
+ if (!this._tracerConfig?._isInServerlessEnvironment()) return
106
+
107
+ const hostname = getHostname(store, region)
108
+ if (!hostname) return
109
+
110
+ span.setTag('peer.service', hostname)
111
+ const peerServerlessStore = storage('peerServerless').getStore()
112
+ if (peerServerlessStore) {
113
+ peerServerlessStore.peerHostname = hostname
114
+ }
88
115
  })
89
116
 
90
117
  this.addSub(`apm:aws:request:complete:${this.serviceIdentifier}`, ({ response, cbExists = false }) => {
@@ -243,4 +270,27 @@ function getHooks (config) {
243
270
  return { request }
244
271
  }
245
272
 
273
+ function getHostname (store, region) {
274
+ if (!store) return
275
+ if (!region) return
276
+ const { awsParams, awsService } = store
277
+ switch (awsService) {
278
+ case 'EventBridge':
279
+ return `events.${region}.amazonaws.com`
280
+ case 'SQS':
281
+ return `sqs.${region}.amazonaws.com`
282
+ case 'SNS':
283
+ return `sns.${region}.amazonaws.com`
284
+ case 'Kinesis':
285
+ return `kinesis.${region}.amazonaws.com`
286
+ case 'DynamoDBDocument':
287
+ case 'DynamoDB':
288
+ return `dynamodb.${region}.amazonaws.com`
289
+ case 'S3':
290
+ return awsParams?.Bucket
291
+ ? `${awsParams.Bucket}.s3.${region}.amazonaws.com`
292
+ : `s3.${region}.amazonaws.com`
293
+ }
294
+ }
295
+
246
296
  module.exports = BaseAwsSdkPlugin
@@ -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
 
@@ -63,7 +63,7 @@ function scrubChildProcessCmd (expression) {
63
63
 
64
64
  if (token === null) {
65
65
  continue
66
- } else if (typeof token === 'object') {
66
+ } else if (typeof token === 'object') { // eslint-disable-line eslint-rules/eslint-safe-typeof-object
67
67
  if (token.pattern) {
68
68
  result.push(token.pattern)
69
69
  } else if (token.op) {
@@ -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')