dd-trace 5.101.0 → 5.102.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 (140) hide show
  1. package/package.json +9 -7
  2. package/packages/datadog-instrumentations/src/aerospike.js +2 -2
  3. package/packages/datadog-instrumentations/src/ai.js +8 -8
  4. package/packages/datadog-instrumentations/src/amqplib.js +6 -7
  5. package/packages/datadog-instrumentations/src/anthropic.js +10 -10
  6. package/packages/datadog-instrumentations/src/apollo-server-core.js +3 -3
  7. package/packages/datadog-instrumentations/src/apollo-server.js +5 -5
  8. package/packages/datadog-instrumentations/src/avsc.js +6 -6
  9. package/packages/datadog-instrumentations/src/aws-sdk.js +151 -67
  10. package/packages/datadog-instrumentations/src/azure-durable-functions.js +8 -8
  11. package/packages/datadog-instrumentations/src/bluebird.js +2 -2
  12. package/packages/datadog-instrumentations/src/body-parser.js +2 -2
  13. package/packages/datadog-instrumentations/src/cassandra-driver.js +7 -7
  14. package/packages/datadog-instrumentations/src/child_process.js +12 -12
  15. package/packages/datadog-instrumentations/src/confluentinc-kafka-javascript.js +9 -9
  16. package/packages/datadog-instrumentations/src/connect.js +7 -7
  17. package/packages/datadog-instrumentations/src/cookie-parser.js +4 -4
  18. package/packages/datadog-instrumentations/src/cookie.js +2 -2
  19. package/packages/datadog-instrumentations/src/couchbase.js +16 -30
  20. package/packages/datadog-instrumentations/src/crypto.js +4 -4
  21. package/packages/datadog-instrumentations/src/cucumber.js +77 -16
  22. package/packages/datadog-instrumentations/src/dns.js +0 -3
  23. package/packages/datadog-instrumentations/src/elasticsearch.js +8 -11
  24. package/packages/datadog-instrumentations/src/express-mongo-sanitize.js +6 -6
  25. package/packages/datadog-instrumentations/src/express-session.js +4 -4
  26. package/packages/datadog-instrumentations/src/express.js +10 -11
  27. package/packages/datadog-instrumentations/src/fastify.js +2 -2
  28. package/packages/datadog-instrumentations/src/fs.js +14 -14
  29. package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +5 -7
  30. package/packages/datadog-instrumentations/src/google-genai.js +4 -4
  31. package/packages/datadog-instrumentations/src/grpc/server.js +2 -2
  32. package/packages/datadog-instrumentations/src/hapi.js +2 -2
  33. package/packages/datadog-instrumentations/src/helpers/callback-instrumentor.js +8 -8
  34. package/packages/datadog-instrumentations/src/helpers/promise.js +2 -2
  35. package/packages/datadog-instrumentations/src/hono.js +2 -2
  36. package/packages/datadog-instrumentations/src/http/client.js +6 -6
  37. package/packages/datadog-instrumentations/src/http/server.js +9 -9
  38. package/packages/datadog-instrumentations/src/jest.js +31 -31
  39. package/packages/datadog-instrumentations/src/kafkajs.js +9 -9
  40. package/packages/datadog-instrumentations/src/knex.js +17 -17
  41. package/packages/datadog-instrumentations/src/koa.js +12 -12
  42. package/packages/datadog-instrumentations/src/ldapjs.js +5 -5
  43. package/packages/datadog-instrumentations/src/light-my-request.js +2 -2
  44. package/packages/datadog-instrumentations/src/limitd-client.js +4 -4
  45. package/packages/datadog-instrumentations/src/lodash.js +4 -4
  46. package/packages/datadog-instrumentations/src/mariadb.js +13 -13
  47. package/packages/datadog-instrumentations/src/memcached.js +2 -2
  48. package/packages/datadog-instrumentations/src/microgateway-core.js +2 -2
  49. package/packages/datadog-instrumentations/src/mocha/common.js +3 -3
  50. package/packages/datadog-instrumentations/src/mocha/main.js +12 -10
  51. package/packages/datadog-instrumentations/src/mocha/utils.js +133 -16
  52. package/packages/datadog-instrumentations/src/mocha/worker.js +7 -5
  53. package/packages/datadog-instrumentations/src/mongodb-core.js +9 -22
  54. package/packages/datadog-instrumentations/src/mongodb.js +5 -5
  55. package/packages/datadog-instrumentations/src/mongoose.js +21 -21
  56. package/packages/datadog-instrumentations/src/mquery.js +5 -5
  57. package/packages/datadog-instrumentations/src/multer.js +4 -4
  58. package/packages/datadog-instrumentations/src/mysql.js +16 -16
  59. package/packages/datadog-instrumentations/src/mysql2.js +4 -4
  60. package/packages/datadog-instrumentations/src/net.js +14 -8
  61. package/packages/datadog-instrumentations/src/nyc.js +5 -5
  62. package/packages/datadog-instrumentations/src/openai.js +19 -19
  63. package/packages/datadog-instrumentations/src/oracledb.js +6 -6
  64. package/packages/datadog-instrumentations/src/passport-utils.js +5 -5
  65. package/packages/datadog-instrumentations/src/pg.js +15 -15
  66. package/packages/datadog-instrumentations/src/pino.js +6 -10
  67. package/packages/datadog-instrumentations/src/playwright.js +20 -15
  68. package/packages/datadog-instrumentations/src/protobufjs.js +16 -16
  69. package/packages/datadog-instrumentations/src/redis.js +1 -2
  70. package/packages/datadog-instrumentations/src/restify.js +2 -2
  71. package/packages/datadog-instrumentations/src/router.js +12 -12
  72. package/packages/datadog-instrumentations/src/stripe.js +12 -12
  73. package/packages/datadog-instrumentations/src/vitest.js +107 -26
  74. package/packages/datadog-instrumentations/src/winston.js +4 -4
  75. package/packages/datadog-instrumentations/src/ws.js +7 -7
  76. package/packages/datadog-plugin-aws-sdk/src/base.js +52 -4
  77. package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +19 -12
  78. package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +45 -35
  79. package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +33 -22
  80. package/packages/datadog-plugin-aws-sdk/src/services/sns.js +12 -13
  81. package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +73 -54
  82. package/packages/datadog-plugin-aws-sdk/src/services/stepfunctions.js +19 -17
  83. package/packages/datadog-plugin-aws-sdk/src/util.js +22 -0
  84. package/packages/datadog-plugin-child_process/src/scrub-cmd-params.js +6 -6
  85. package/packages/datadog-plugin-cucumber/src/index.js +4 -0
  86. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +1 -4
  87. package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +1 -5
  88. package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +3 -1
  89. package/packages/datadog-plugin-http/src/client.js +1 -5
  90. package/packages/datadog-plugin-jest/src/util.js +1 -2
  91. package/packages/datadog-plugin-mocha/src/index.js +4 -0
  92. package/packages/datadog-plugin-mongodb-core/src/index.js +2 -1
  93. package/packages/datadog-plugin-openai/src/tracing.js +12 -23
  94. package/packages/datadog-plugin-playwright/src/index.js +1 -1
  95. package/packages/datadog-plugin-vitest/src/index.js +8 -1
  96. package/packages/datadog-shimmer/src/shimmer.js +7 -1
  97. package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-password-rules.js +1 -1
  98. package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-secret-rules.js +81 -81
  99. package/packages/dd-trace/src/appsec/iast/security-controls/index.js +2 -2
  100. package/packages/dd-trace/src/appsec/iast/taint-tracking/plugins/kafka.js +2 -2
  101. package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +2 -2
  102. package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +2 -2
  103. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +2 -0
  104. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/index.js +1 -3
  105. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/utils.js +83 -48
  106. package/packages/dd-trace/src/appsec/index.js +21 -24
  107. package/packages/dd-trace/src/appsec/reporter.js +3 -1
  108. package/packages/dd-trace/src/appsec/rule_manager.js +4 -2
  109. package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +31 -16
  110. package/packages/dd-trace/src/config/git_properties.js +2 -2
  111. package/packages/dd-trace/src/datastreams/index.js +2 -1
  112. package/packages/dd-trace/src/datastreams/processor.js +1 -2
  113. package/packages/dd-trace/src/debugger/devtools_client/snapshot-pruner.js +1 -0
  114. package/packages/dd-trace/src/encode/0.4.js +757 -232
  115. package/packages/dd-trace/src/encode/0.5.js +13 -7
  116. package/packages/dd-trace/src/llmobs/plugins/ai/util.js +1 -2
  117. package/packages/dd-trace/src/llmobs/plugins/genai/util.js +6 -3
  118. package/packages/dd-trace/src/llmobs/sdk.js +24 -26
  119. package/packages/dd-trace/src/llmobs/span_processor.js +25 -5
  120. package/packages/dd-trace/src/llmobs/util.js +1 -0
  121. package/packages/dd-trace/src/msgpack/chunk.js +6 -3
  122. package/packages/dd-trace/src/openfeature/noop.js +40 -36
  123. package/packages/dd-trace/src/openfeature/writers/exposures.js +33 -52
  124. package/packages/dd-trace/src/opentelemetry/otlp/otlp_transformer_base.js +1 -2
  125. package/packages/dd-trace/src/opentelemetry/tracer.js +0 -22
  126. package/packages/dd-trace/src/opentracing/propagation/text_map_dsm.js +2 -11
  127. package/packages/dd-trace/src/plugins/util/ci.js +1 -1
  128. package/packages/dd-trace/src/plugins/util/git-cache.js +3 -5
  129. package/packages/dd-trace/src/plugins/util/test.js +19 -7
  130. package/packages/dd-trace/src/plugins/util/url.js +1 -3
  131. package/packages/dd-trace/src/plugins/util/user-provided-git.js +1 -1
  132. package/packages/dd-trace/src/plugins/util/web.js +5 -7
  133. package/packages/dd-trace/src/profiling/profilers/events.js +3 -23
  134. package/packages/dd-trace/src/profiling/profilers/wall.js +4 -5
  135. package/packages/dd-trace/src/runtime_metrics/index.js +2 -2
  136. package/packages/dd-trace/src/scope.js +3 -10
  137. package/packages/dd-trace/src/serverless.js +1 -4
  138. package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +7 -1
  139. package/packages/dd-trace/src/service-naming/schemas/v1/messaging.js +4 -0
  140. package/packages/dd-trace/src/tracer.js +7 -7
@@ -8,24 +8,24 @@ addHook({ name: 'mysql', file: 'lib/Connection.js', versions: ['>=2'] }, Connect
8
8
  const finishCh = channel('apm:mysql:query:finish')
9
9
  const errorCh = channel('apm:mysql:query:error')
10
10
 
11
- shimmer.wrap(Connection.prototype, 'query', query => function () {
11
+ shimmer.wrap(Connection.prototype, 'query', query => function (...args) {
12
12
  if (!startCh.hasSubscribers) {
13
- return query.apply(this, arguments)
13
+ return query.apply(this, args)
14
14
  }
15
15
 
16
- const sql = arguments[0].sql || arguments[0]
16
+ const sql = args[0].sql || args[0]
17
17
  const conf = this.config
18
18
  const ctx = { sql, conf }
19
19
 
20
20
  return startCh.runStores(ctx, () => {
21
- if (arguments[0].sql) {
22
- arguments[0].sql = ctx.sql
21
+ if (args[0].sql) {
22
+ args[0].sql = ctx.sql
23
23
  } else {
24
- arguments[0] = ctx.sql
24
+ args[0] = ctx.sql
25
25
  }
26
26
 
27
27
  try {
28
- const res = query.apply(this, arguments)
28
+ const res = query.apply(this, args)
29
29
 
30
30
  if (res._callback) {
31
31
  const cb = res._callback
@@ -63,8 +63,8 @@ addHook({ name: 'mysql', file: 'lib/Pool.js', versions: ['>=2'] }, Pool => {
63
63
  const finishPoolQueryCh = channel('datadog:mysql:pool:query:finish')
64
64
 
65
65
  shimmer.wrap(Pool.prototype, 'getConnection', getConnection => function (cb) {
66
- arguments[0] = function () {
67
- return connectionFinishCh.runStores(ctx, cb, this, ...arguments)
66
+ arguments[0] = function (...args) {
67
+ return connectionFinishCh.runStores(ctx, cb, this, ...args)
68
68
  }
69
69
 
70
70
  const ctx = {}
@@ -74,24 +74,24 @@ addHook({ name: 'mysql', file: 'lib/Pool.js', versions: ['>=2'] }, Pool => {
74
74
  return getConnection.apply(this, arguments)
75
75
  })
76
76
 
77
- shimmer.wrap(Pool.prototype, 'query', query => function () {
77
+ shimmer.wrap(Pool.prototype, 'query', query => function (...args) {
78
78
  if (!startPoolQueryCh.hasSubscribers) {
79
- return query.apply(this, arguments)
79
+ return query.apply(this, args)
80
80
  }
81
81
 
82
- const sql = arguments[0].sql || arguments[0]
82
+ const sql = args[0].sql || args[0]
83
83
  const ctx = { sql }
84
84
  const finish = () => finishPoolQueryCh.publish(ctx)
85
85
 
86
86
  return startPoolQueryCh.runStores(ctx, () => {
87
- const cb = arguments[arguments.length - 1]
87
+ const cb = args[args.length - 1]
88
88
  if (typeof cb === 'function') {
89
- arguments[arguments.length - 1] = shimmer.wrapFunction(cb, cb => function () {
90
- return finishPoolQueryCh.runStores(ctx, cb, this, ...arguments)
89
+ args[args.length - 1] = shimmer.wrapFunction(cb, cb => function (...args) {
90
+ return finishPoolQueryCh.runStores(ctx, cb, this, ...args)
91
91
  })
92
92
  }
93
93
 
94
- const retval = query.apply(this, arguments)
94
+ const retval = query.apply(this, args)
95
95
 
96
96
  if (retval && retval.then) {
97
97
  retval.then(finish).catch(finish)
@@ -145,8 +145,8 @@ function wrapConnection (Connection, version) {
145
145
 
146
146
  if (cached === onResult) return
147
147
 
148
- const wrapped = function () {
149
- return commandFinishCh.runStores(ctx, onResult, this, ...arguments)
148
+ const wrapped = function (...args) {
149
+ return commandFinishCh.runStores(ctx, onResult, this, ...args)
150
150
  }
151
151
 
152
152
  wrappedOnResult.set(cmd, wrapped)
@@ -289,8 +289,8 @@ function wrapPoolCluster (PoolCluster) {
289
289
  const startOuterQueryCh = channel('datadog:mysql2:outerquery:start')
290
290
  const wrappedPoolNamespaces = new WeakSet()
291
291
 
292
- shimmer.wrap(PoolCluster.prototype, 'of', of => function () {
293
- const poolNamespace = of.apply(this, arguments)
292
+ shimmer.wrap(PoolCluster.prototype, 'of', of => function (...args) {
293
+ const poolNamespace = of.apply(this, args)
294
294
 
295
295
  if (startOuterQueryCh.hasSubscribers && !wrappedPoolNamespaces.has(poolNamespace)) {
296
296
  shimmer.wrap(poolNamespace, 'query', query => function (sql, values, cb) {
@@ -21,16 +21,16 @@ addHook({ name: 'net' }, (net) => {
21
21
  // so that we don't miss the dns calls
22
22
  require('node:dns')
23
23
 
24
- shimmer.wrap(net.Socket.prototype, 'connect', connect => function () {
24
+ shimmer.wrap(net.Socket.prototype, 'connect', connect => function (...args) {
25
25
  if (!startICPCh.hasSubscribers || !startTCPCh.hasSubscribers) {
26
- return connect.apply(this, arguments)
26
+ return connect.apply(this, args)
27
27
  }
28
28
 
29
- const options = getOptions(arguments)
30
- const lastIndex = arguments.length - 1
31
- const callback = arguments[lastIndex]
29
+ const options = getOptions(args)
30
+ const lastIndex = args.length - 1
31
+ const callback = args[lastIndex]
32
32
 
33
- if (!options) return connect.apply(this, arguments)
33
+ if (!options) return connect.apply(this, args)
34
34
 
35
35
  const protocol = options.path ? 'ipc' : 'tcp'
36
36
  const startCh = protocol === 'ipc' ? startICPCh : startTCPCh
@@ -39,7 +39,7 @@ addHook({ name: 'net' }, (net) => {
39
39
  const ctx = { options }
40
40
 
41
41
  if (typeof callback === 'function') {
42
- arguments[lastIndex] = function (...args) {
42
+ args[lastIndex] = function (...args) {
43
43
  return finishCh.runStores(ctx, callback, this, ...args)
44
44
  }
45
45
  }
@@ -48,20 +48,26 @@ addHook({ name: 'net' }, (net) => {
48
48
  setupListeners(this, protocol, ctx, finishCh, errorCh)
49
49
 
50
50
  const emit = this.emit
51
+ let pendingReadyEvents = 2
51
52
  this.emit = shimmer.wrapFunction(emit, emit => function (eventName) {
52
53
  switch (eventName) {
53
54
  case 'ready':
54
55
  case 'connect':
56
+ if (--pendingReadyEvents === 0) this.emit = emit
55
57
  return readyCh.runStores(ctx, () => {
56
58
  return emit.apply(this, arguments)
57
59
  })
60
+ case 'error':
61
+ case 'close':
62
+ this.emit = emit
63
+ return emit.apply(this, arguments)
58
64
  default:
59
65
  return emit.apply(this, arguments)
60
66
  }
61
67
  })
62
68
 
63
69
  try {
64
- return connect.apply(this, arguments)
70
+ return connect.apply(this, args)
65
71
  } catch (err) {
66
72
  errorCh.publish(err)
67
73
 
@@ -17,7 +17,7 @@ addHook({
17
17
  setupSettingsCachePath()
18
18
 
19
19
  // `wrap` is an async function
20
- shimmer.wrap(nycPackage.prototype, 'wrap', wrap => function () {
20
+ shimmer.wrap(nycPackage.prototype, 'wrap', wrap => function (...args) {
21
21
  // Only relevant if the config `all` is set to true (for untested code coverage)
22
22
  try {
23
23
  if (JSON.parse(getEnvironmentVariable('NYC_CONFIG')).all) {
@@ -27,16 +27,16 @@ addHook({
27
27
  // ignore errors
28
28
  }
29
29
 
30
- return wrap.apply(this, arguments)
30
+ return wrap.apply(this, args)
31
31
  })
32
32
 
33
33
  // `report` is an async function, so we wait for it to complete before publishing
34
- shimmer.wrap(nycPackage.prototype, 'report', report => function () {
34
+ shimmer.wrap(nycPackage.prototype, 'report', report => function (...args) {
35
35
  if (!codeCoverageReportCh.hasSubscribers) {
36
- return report.apply(this, arguments)
36
+ return report.apply(this, args)
37
37
  }
38
38
  const nycInstance = this
39
- const reportPromise = report.apply(this, arguments)
39
+ const reportPromise = report.apply(this, args)
40
40
 
41
41
  if (reportPromise && typeof reportPromise.then === 'function') {
42
42
  // Return a new promise that waits for both the report AND the coverage upload
@@ -150,18 +150,18 @@ addHook({ name: 'openai', file: 'dist/api.js', versions: ['>=3.0.0 <4'] }, expor
150
150
  methodNames.shift() // remove leading 'constructor' method
151
151
 
152
152
  for (const methodName of methodNames) {
153
- shimmer.wrap(exports.OpenAIApi.prototype, methodName, fn => function () {
153
+ shimmer.wrap(exports.OpenAIApi.prototype, methodName, fn => function (...args) {
154
154
  if (!ch.start.hasSubscribers) {
155
- return fn.apply(this, arguments)
155
+ return fn.apply(this, args)
156
156
  }
157
157
 
158
158
  const ctx = {
159
159
  methodName,
160
- args: arguments,
160
+ args,
161
161
  basePath: this.basePath,
162
162
  }
163
163
 
164
- return ch.tracePromise(fn, ctx, this, ...arguments)
164
+ return ch.tracePromise(fn, ctx, this, ...args)
165
165
  })
166
166
  }
167
167
 
@@ -175,10 +175,10 @@ addHook({ name: 'openai', file: 'dist/api.js', versions: ['>=3.0.0 <4'] }, expor
175
175
  */
176
176
  function wrapStreamIterator (response, options, ctx) {
177
177
  return function (itr) {
178
- return function () {
179
- const iterator = itr.apply(this, arguments)
180
- shimmer.wrap(iterator, 'next', next => function () {
181
- return next.apply(this, arguments)
178
+ return function (...args) {
179
+ const iterator = itr.apply(this, args)
180
+ shimmer.wrap(iterator, 'next', next => function (...args) {
181
+ return next.apply(this, args)
182
182
  .then(res => {
183
183
  const { done, value: chunk } = res
184
184
  onStreamedChunkCh.publish({ ctx, chunk, done })
@@ -215,38 +215,38 @@ for (const extension of extensions) {
215
215
  const targetPrototype = exports[targetClass].prototype
216
216
 
217
217
  for (const methodName of methods) {
218
- shimmer.wrap(targetPrototype, methodName, methodFn => function () {
218
+ shimmer.wrap(targetPrototype, methodName, methodFn => function (...args) {
219
219
  if (!ch.start.hasSubscribers) {
220
- return methodFn.apply(this, arguments)
220
+ return methodFn.apply(this, args)
221
221
  }
222
222
 
223
223
  // The OpenAI library lets you set `stream: true` on the options arg to any method
224
224
  // However, we only want to handle streamed responses in specific cases
225
225
  // chat.completions and completions
226
- const stream = streamedResponse && getOption(arguments, 'stream', false)
226
+ const stream = streamedResponse && getOption(args, 'stream', false)
227
227
 
228
228
  const client = this._client || this.client
229
229
 
230
230
  const ctx = {
231
231
  methodName: `${baseResource}.${methodName}`,
232
- args: arguments,
232
+ args,
233
233
  basePath: client.baseURL,
234
234
  }
235
235
 
236
236
  return ch.start.runStores(ctx, () => {
237
- const apiProm = methodFn.apply(this, arguments)
237
+ const apiProm = methodFn.apply(this, args)
238
238
 
239
239
  if (baseResource === 'chat.completions' && typeof apiProm._thenUnwrap === 'function') {
240
240
  // this should only ever be invoked from a client.beta.chat.completions.parse call
241
- shimmer.wrap(apiProm, '_thenUnwrap', origApiPromThenUnwrap => function () {
241
+ shimmer.wrap(apiProm, '_thenUnwrap', origApiPromThenUnwrap => function (...args) {
242
242
  // TODO(sam.brenner): I wonder if we can patch the APIPromise prototype instead, although
243
243
  // we might not have access to everything we need...
244
244
 
245
245
  // this is a new apipromise instance
246
- const unwrappedPromise = origApiPromThenUnwrap.apply(this, arguments)
246
+ const unwrappedPromise = origApiPromThenUnwrap.apply(this, args)
247
247
 
248
- shimmer.wrap(unwrappedPromise, 'parse', origApiPromParse => function () {
249
- const parsedPromise = origApiPromParse.apply(this, arguments)
248
+ shimmer.wrap(unwrappedPromise, 'parse', origApiPromParse => function (...args) {
249
+ const parsedPromise = origApiPromParse.apply(this, args)
250
250
  .then(body => Promise.all([this.responsePromise, body]))
251
251
 
252
252
  return handleUnwrappedAPIPromise(parsedPromise, ctx, stream)
@@ -258,8 +258,8 @@ for (const extension of extensions) {
258
258
 
259
259
  // wrapping `parse` avoids problematic wrapping of `then` when trying to call
260
260
  // `withResponse` in userland code after. This way, we can return the whole `APIPromise`
261
- shimmer.wrap(apiProm, 'parse', origApiPromParse => function () {
262
- const parsedPromise = origApiPromParse.apply(this, arguments)
261
+ shimmer.wrap(apiProm, 'parse', origApiPromParse => function (...args) {
262
+ const parsedPromise = origApiPromParse.apply(this, args)
263
263
  .then(body => Promise.all([this.responsePromise, body]))
264
264
 
265
265
  return handleUnwrappedAPIPromise(parsedPromise, ctx, stream)
@@ -137,21 +137,21 @@ addHook({ name: 'oracledb', versions: ['>=5'], file: 'lib/oracledb.js' }, oracle
137
137
  }
138
138
  })
139
139
  shimmer.wrap(oracledb.Pool.prototype, 'getConnection', getConnection => {
140
- return function wrappedGetConnection () {
140
+ return function wrappedGetConnection (...args) {
141
141
  let callback
142
- if (typeof arguments[arguments.length - 1] === 'function') {
143
- callback = arguments[arguments.length - 1]
142
+ if (typeof args[args.length - 1] === 'function') {
143
+ callback = args[args.length - 1]
144
144
  }
145
145
  if (callback) {
146
- arguments[arguments.length - 1] = shimmer.wrapFunction(callback, callback => (err, connection) => {
146
+ args[args.length - 1] = shimmer.wrapFunction(callback, callback => (err, connection) => {
147
147
  if (connection) {
148
148
  connectionAttributes.set(connection, poolAttributes.get(this))
149
149
  }
150
150
  callback(err, connection)
151
151
  })
152
- getConnection.apply(this, arguments)
152
+ getConnection.apply(this, args)
153
153
  } else {
154
- return getConnection.apply(this, arguments).then((connection) => {
154
+ return getConnection.apply(this, args).then((connection) => {
155
155
  connectionAttributes.set(connection, poolAttributes.get(this))
156
156
  return connection
157
157
  })
@@ -40,15 +40,15 @@ function wrapVerify (verify) {
40
40
  }
41
41
 
42
42
  function wrapStrategy (Strategy) {
43
- return function wrappedStrategy () {
43
+ return function wrappedStrategy (...args) {
44
44
  // verify function can be either the first or second argument
45
- if (typeof arguments[0] === 'function') {
46
- arguments[0] = wrapVerify(arguments[0])
45
+ if (typeof args[0] === 'function') {
46
+ args[0] = wrapVerify(args[0])
47
47
  } else {
48
- arguments[1] = wrapVerify(arguments[1])
48
+ args[1] = wrapVerify(args[1])
49
49
  }
50
50
 
51
- return Strategy.apply(this, arguments)
51
+ return Strategy.apply(this, args)
52
52
  }
53
53
  }
54
54
 
@@ -31,16 +31,16 @@ addHook({ name: 'pg', versions: ['>=8.0.3'] }, pg => {
31
31
  })
32
32
 
33
33
  function wrapQuery (query) {
34
- return function () {
34
+ return function (...args) {
35
35
  if (!startCh.hasSubscribers) {
36
- return query.apply(this, arguments)
36
+ return query.apply(this, args)
37
37
  }
38
38
 
39
39
  const processId = this.processID
40
40
 
41
- const pgQuery = arguments[0] !== null && typeof arguments[0] === 'object'
42
- ? arguments[0]
43
- : { text: arguments[0] }
41
+ const pgQuery = args[0] !== null && typeof args[0] === 'object'
42
+ ? args[0]
43
+ : { text: args[0] }
44
44
 
45
45
  const textPropObj = pgQuery.cursor ?? pgQuery
46
46
  const textProp = Object.getOwnPropertyDescriptor(textPropObj, 'text')
@@ -80,7 +80,7 @@ function wrapQuery (query) {
80
80
 
81
81
  // Based on: https://github.com/brianc/node-postgres/blob/54eb0fa216aaccd727765641e7d1cf5da2bc483d/packages/pg/lib/client.js#L510
82
82
  const reusingQuery = typeof pgQuery.submit === 'function'
83
- const callback = arguments[arguments.length - 1]
83
+ const callback = args[args.length - 1]
84
84
 
85
85
  finish(error)
86
86
 
@@ -109,9 +109,9 @@ function wrapQuery (query) {
109
109
  return Promise.reject(error)
110
110
  }
111
111
 
112
- arguments[0] = pgQuery
112
+ args[0] = pgQuery
113
113
 
114
- const retval = query.apply(this, arguments)
114
+ const retval = query.apply(this, args)
115
115
 
116
116
  const deperecated = Object.hasOwn(this, '_activeQuery')
117
117
  const queryQueue = deperecated ? this._queryQueue : this.queryQueue
@@ -153,18 +153,18 @@ const finish = (ctx) => {
153
153
  finishPoolQueryCh.publish(ctx)
154
154
  }
155
155
  function wrapPoolQuery (query) {
156
- return function () {
156
+ return function (...args) {
157
157
  if (!startPoolQueryCh.hasSubscribers) {
158
- return query.apply(this, arguments)
158
+ return query.apply(this, args)
159
159
  }
160
160
 
161
- const pgQuery = arguments[0] !== null && typeof arguments[0] === 'object' ? arguments[0] : { text: arguments[0] }
161
+ const pgQuery = args[0] !== null && typeof args[0] === 'object' ? args[0] : { text: args[0] }
162
162
  const abortController = new AbortController()
163
163
 
164
164
  const ctx = { query: pgQuery, abortController }
165
165
 
166
166
  return startPoolQueryCh.runStores(ctx, () => {
167
- const cb = arguments[arguments.length - 1]
167
+ const cb = args[args.length - 1]
168
168
 
169
169
  if (abortController.signal.aborted) {
170
170
  const error = abortController.signal.reason || new Error('Aborted')
@@ -179,13 +179,13 @@ function wrapPoolQuery (query) {
179
179
  }
180
180
 
181
181
  if (typeof cb === 'function') {
182
- arguments[arguments.length - 1] = shimmer.wrapFunction(cb, cb => function () {
182
+ args[args.length - 1] = shimmer.wrapFunction(cb, cb => function (...args) {
183
183
  finish(ctx)
184
- return cb.apply(this, arguments)
184
+ return cb.apply(this, args)
185
185
  })
186
186
  }
187
187
 
188
- const retval = query.apply(this, arguments)
188
+ const retval = query.apply(this, args)
189
189
 
190
190
  if (retval?.then) {
191
191
  retval.then(() => {
@@ -7,8 +7,8 @@ const {
7
7
  } = require('./helpers/instrument')
8
8
 
9
9
  function wrapPino (symbol, wrapper, pino) {
10
- return function pinoWithTrace () {
11
- const instance = pino.apply(this, arguments)
10
+ return function pinoWithTrace (...args) {
11
+ const instance = pino.apply(this, args)
12
12
 
13
13
  Object.defineProperty(instance, symbol, {
14
14
  configurable: true,
@@ -46,8 +46,8 @@ function wrapPrettifyObject (prettifyObject) {
46
46
 
47
47
  function wrapPrettyFactory (prettyFactory) {
48
48
  const ch = channel('apm:pino:log')
49
- return function prettyFactoryWithTrace () {
50
- const pretty = prettyFactory.apply(this, arguments)
49
+ return function prettyFactoryWithTrace (...args) {
50
+ const pretty = prettyFactory.apply(this, args)
51
51
  return function prettyWithTrace (obj) {
52
52
  const payload = { message: obj }
53
53
  ch.publish(payload)
@@ -60,17 +60,13 @@ function wrapPrettyFactory (prettyFactory) {
60
60
  addHook({ name: 'pino', versions: ['2 - 3', '4'], patchDefault: true }, (pino) => {
61
61
  const asJsonSym = (pino.symbols && pino.symbols.asJsonSym) || 'asJson'
62
62
 
63
- const wrapped = shimmer.wrapFunction(pino, pino => wrapPino(asJsonSym, wrapAsJson, pino))
64
-
65
- return wrapped
63
+ return shimmer.wrapFunction(pino, pino => wrapPino(asJsonSym, wrapAsJson, pino))
66
64
  })
67
65
 
68
66
  addHook({ name: 'pino', versions: ['>=5 <6.8.0'], patchDefault: true }, (pino) => {
69
67
  const asJsonSym = ((pino.default || pino)?.symbols.asJsonSym) || 'asJson'
70
68
 
71
- const wrapped = shimmer.wrapFunction(pino, pino => wrapPino(asJsonSym, wrapAsJson, pino.default || pino))
72
-
73
- return wrapped
69
+ return shimmer.wrapFunction(pino, pino => wrapPino(asJsonSym, wrapAsJson, pino.default || pino))
74
70
  })
75
71
 
76
72
  addHook({ name: 'pino', versions: ['>=6.8.0'], patchDefault: false }, (pino) => {
@@ -79,6 +79,7 @@ let testManagementTests = {}
79
79
  let isImpactedTestsEnabled = false
80
80
  let modifiedFiles = {}
81
81
  let quarantinedButNotAttemptToFixFqns = new Set()
82
+ let testsReportedInGenerateSummary = new Set()
82
83
  const newTestsWithDynamicNames = new Set()
83
84
  const attemptToFixExecutions = new Map()
84
85
  const loggedAttemptToFixTests = new Set()
@@ -574,9 +575,9 @@ function testEndHandler ({
574
575
  }
575
576
 
576
577
  function dispatcherRunWrapper (run) {
577
- return function () {
578
+ return function (...args) {
578
579
  remainingTestsByFile = getTestsBySuiteFromTestsById(this._testById)
579
- return run.apply(this, arguments)
580
+ return run.apply(this, args)
580
581
  }
581
582
  }
582
583
 
@@ -604,9 +605,9 @@ function dispatcherRunWrapperNew (run) {
604
605
 
605
606
  function dispatcherHook (dispatcherExport) {
606
607
  shimmer.wrap(dispatcherExport.Dispatcher.prototype, 'run', dispatcherRunWrapper)
607
- shimmer.wrap(dispatcherExport.Dispatcher.prototype, '_createWorker', createWorker => function () {
608
+ shimmer.wrap(dispatcherExport.Dispatcher.prototype, '_createWorker', createWorker => function (...args) {
608
609
  const dispatcher = this
609
- const worker = createWorker.apply(this, arguments)
610
+ const worker = createWorker.apply(this, args)
610
611
  const projects = getProjectsFromDispatcher(dispatcher)
611
612
  sessionProjects = projects
612
613
 
@@ -645,9 +646,9 @@ function dispatcherHook (dispatcherExport) {
645
646
 
646
647
  function dispatcherHookNew (dispatcherExport, runWrapper) {
647
648
  shimmer.wrap(dispatcherExport.Dispatcher.prototype, 'run', runWrapper)
648
- shimmer.wrap(dispatcherExport.Dispatcher.prototype, '_createWorker', createWorker => function () {
649
+ shimmer.wrap(dispatcherExport.Dispatcher.prototype, '_createWorker', createWorker => function (...args) {
649
650
  const dispatcher = this
650
- const worker = createWorker.apply(this, arguments)
651
+ const worker = createWorker.apply(this, args)
651
652
  const projects = getProjectsFromDispatcher(dispatcher)
652
653
  sessionProjects = projects
653
654
 
@@ -661,8 +662,11 @@ function dispatcherHookNew (dispatcherExport, runWrapper) {
661
662
  const test = getTestByTestId(dispatcher, testId)
662
663
 
663
664
  const isTimeout = status === 'timedOut'
664
- const shouldCreateTestSpan = test.expectedStatus === 'skipped'
665
665
  const testStatus = STATUS_TO_TEST_STATUS[status]
666
+ const shouldCreateTestSpan = test.expectedStatus === 'skipped'
667
+ if (shouldCreateTestSpan && !testToCtx.has(test)) {
668
+ testBeginHandler(test, getBrowserNameFromProjects(projects, test), true)
669
+ }
666
670
  testEndHandler(
667
671
  {
668
672
  test,
@@ -835,15 +839,16 @@ function runAllTestsWrapper (runAllTests, playwrightVersion) {
835
839
  // there were tests that did not go through `testBegin` or `testEnd`,
836
840
  // because they were skipped
837
841
  for (const test of tests) {
842
+ const alreadyReported = testsReportedInGenerateSummary.has(test)
838
843
  const browser = getBrowserNameFromProjects(projects, test)
839
- testBeginHandler(test, browser, true)
844
+ testBeginHandler(test, browser, !alreadyReported)
840
845
  testEndHandler({
841
846
  test,
842
847
  annotations: [],
843
848
  testStatus: 'skip',
844
849
  error: null,
845
850
  isTimeout: false,
846
- shouldCreateTestSpan: true,
851
+ shouldCreateTestSpan: !alreadyReported,
847
852
  projects,
848
853
  })
849
854
  }
@@ -894,6 +899,7 @@ function runAllTestsWrapper (runAllTests, playwrightVersion) {
894
899
  startedSuites = []
895
900
  remainingTestsByFile = {}
896
901
  quarantinedButNotAttemptToFixFqns = new Set()
902
+ testsReportedInGenerateSummary = new Set()
897
903
 
898
904
  // TODO: we can trick playwright into thinking the session passed by returning
899
905
  // 'passed' here. We might be able to use this for both EFD and Test Management tests.
@@ -1144,7 +1150,7 @@ addHook({
1144
1150
  }
1145
1151
 
1146
1152
  // We need to proxy the createRootSuite function because the function is not configurable
1147
- const proxy = new Proxy(loadUtilsPackage, {
1153
+ return new Proxy(loadUtilsPackage, {
1148
1154
  get (target, prop) {
1149
1155
  if (prop === 'createRootSuite') {
1150
1156
  return newCreateRootSuite
@@ -1152,8 +1158,6 @@ addHook({
1152
1158
  return target[prop]
1153
1159
  },
1154
1160
  })
1155
-
1156
- return proxy
1157
1161
  })
1158
1162
 
1159
1163
  // main process hook
@@ -1419,12 +1423,13 @@ addHook({
1419
1423
  })
1420
1424
 
1421
1425
  function generateSummaryWrapper (generateSummary) {
1422
- return function () {
1426
+ return function (...args) {
1423
1427
  for (const test of this.suite.allTests()) {
1424
1428
  // https://github.com/microsoft/playwright/blob/bf92ffecff6f30a292b53430dbaee0207e0c61ad/packages/playwright/src/reporters/base.ts#L279
1425
1429
  const didNotRun = test.outcome() === 'skipped' &&
1426
1430
  (!test.results.length || test.expectedStatus !== 'skipped')
1427
- if (didNotRun) {
1431
+ if (didNotRun && !testsReportedInGenerateSummary.has(test)) {
1432
+ testsReportedInGenerateSummary.add(test)
1428
1433
  const {
1429
1434
  _requireFile: testSuiteAbsolutePath,
1430
1435
  location: {
@@ -1451,7 +1456,7 @@ function generateSummaryWrapper (generateSummary) {
1451
1456
  })
1452
1457
  }
1453
1458
  }
1454
- return generateSummary.apply(this, arguments)
1459
+ return generateSummary.apply(this, args)
1455
1460
  }
1456
1461
  }
1457
1462
 
@@ -9,23 +9,23 @@ const deserializeChannel = dc.channel('apm:protobufjs:deserialize-end')
9
9
 
10
10
  function wrapSerialization (messageClass) {
11
11
  if (messageClass?.encode) {
12
- shimmer.wrap(messageClass, 'encode', original => function () {
12
+ shimmer.wrap(messageClass, 'encode', original => function (...args) {
13
13
  if (!serializeChannel.hasSubscribers) {
14
- return original.apply(this, arguments)
14
+ return original.apply(this, args)
15
15
  }
16
16
  serializeChannel.publish({ messageClass: this })
17
- return original.apply(this, arguments)
17
+ return original.apply(this, args)
18
18
  })
19
19
  }
20
20
  }
21
21
 
22
22
  function wrapDeserialization (messageClass) {
23
23
  if (messageClass?.decode) {
24
- shimmer.wrap(messageClass, 'decode', original => function () {
24
+ shimmer.wrap(messageClass, 'decode', original => function (...args) {
25
25
  if (!deserializeChannel.hasSubscribers) {
26
- return original.apply(this, arguments)
26
+ return original.apply(this, args)
27
27
  }
28
- const result = original.apply(this, arguments)
28
+ const result = original.apply(this, args)
29
29
  deserializeChannel.publish({ messageClass: result })
30
30
  return result
31
31
  })
@@ -34,8 +34,8 @@ function wrapDeserialization (messageClass) {
34
34
 
35
35
  function wrapSetup (messageClass) {
36
36
  if (messageClass?.setup) {
37
- shimmer.wrap(messageClass, 'setup', original => function () {
38
- const result = original.apply(this, arguments)
37
+ shimmer.wrap(messageClass, 'setup', original => function (...args) {
38
+ const result = original.apply(this, args)
39
39
 
40
40
  wrapSerialization(messageClass)
41
41
  wrapDeserialization(messageClass)
@@ -74,8 +74,8 @@ function wrapReflection (protobuf) {
74
74
  ]
75
75
 
76
76
  for (const method of reflectionMethods) {
77
- shimmer.wrap(method.target, method.name, original => function () {
78
- const result = original.apply(this, arguments)
77
+ shimmer.wrap(method.target, method.name, original => function (...args) {
78
+ const result = original.apply(this, args)
79
79
  if (result.nested) {
80
80
  for (const type in result.nested) {
81
81
  wrapSetup(result.nested[type])
@@ -97,8 +97,8 @@ addHook({
97
97
  name: 'protobufjs',
98
98
  versions: ['>=6.8.0'],
99
99
  }, protobuf => {
100
- shimmer.wrap(protobuf.Root.prototype, 'load', original => function () {
101
- const result = original.apply(this, arguments)
100
+ shimmer.wrap(protobuf.Root.prototype, 'load', original => function (...args) {
101
+ const result = original.apply(this, args)
102
102
  if (isPromise(result)) {
103
103
  return result.then(root => {
104
104
  wrapProtobufClasses(root)
@@ -110,14 +110,14 @@ addHook({
110
110
  return result
111
111
  })
112
112
 
113
- shimmer.wrap(protobuf.Root.prototype, 'loadSync', original => function () {
114
- const root = original.apply(this, arguments)
113
+ shimmer.wrap(protobuf.Root.prototype, 'loadSync', original => function (...args) {
114
+ const root = original.apply(this, args)
115
115
  wrapProtobufClasses(root)
116
116
  return root
117
117
  })
118
118
 
119
- shimmer.wrap(protobuf, 'Type', Original => function () {
120
- const typeInstance = new Original(...arguments)
119
+ shimmer.wrap(protobuf, 'Type', Original => function (...args) {
120
+ const typeInstance = new Original(...args)
121
121
  wrapSetup(typeInstance)
122
122
  return typeInstance
123
123
  })