dd-trace 5.7.0 → 5.9.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 (116) hide show
  1. package/LICENSE-3rdparty.csv +0 -1
  2. package/ci/init.js +3 -3
  3. package/index.d.ts +35 -0
  4. package/package.json +4 -5
  5. package/packages/datadog-esbuild/index.js +2 -2
  6. package/packages/datadog-instrumentations/src/apollo-server.js +1 -1
  7. package/packages/datadog-instrumentations/src/apollo.js +103 -0
  8. package/packages/datadog-instrumentations/src/aws-sdk.js +4 -1
  9. package/packages/datadog-instrumentations/src/cassandra-driver.js +1 -1
  10. package/packages/datadog-instrumentations/src/cucumber.js +6 -2
  11. package/packages/datadog-instrumentations/src/fs.js +0 -1
  12. package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +1 -1
  13. package/packages/datadog-instrumentations/src/helpers/hooks.js +57 -56
  14. package/packages/datadog-instrumentations/src/helpers/instrument.js +2 -2
  15. package/packages/datadog-instrumentations/src/http/client.js +1 -0
  16. package/packages/datadog-instrumentations/src/jest.js +12 -13
  17. package/packages/datadog-instrumentations/src/kafkajs.js +2 -1
  18. package/packages/datadog-instrumentations/src/ldapjs.js +2 -1
  19. package/packages/datadog-instrumentations/src/mocha.js +1 -1
  20. package/packages/datadog-instrumentations/src/mongodb-core.js +4 -6
  21. package/packages/datadog-instrumentations/src/net.js +1 -1
  22. package/packages/datadog-instrumentations/src/passport-utils.js +1 -0
  23. package/packages/datadog-instrumentations/src/playwright.js +158 -7
  24. package/packages/datadog-instrumentations/src/rhea.js +5 -2
  25. package/packages/datadog-instrumentations/src/tedious.js +1 -1
  26. package/packages/datadog-plugin-apollo/src/gateway/execute.js +12 -0
  27. package/packages/datadog-plugin-apollo/src/gateway/fetch.js +36 -0
  28. package/packages/datadog-plugin-apollo/src/gateway/index.js +36 -0
  29. package/packages/datadog-plugin-apollo/src/gateway/plan.js +12 -0
  30. package/packages/datadog-plugin-apollo/src/gateway/postprocessing.js +12 -0
  31. package/packages/datadog-plugin-apollo/src/gateway/request.js +124 -0
  32. package/packages/datadog-plugin-apollo/src/gateway/validate.js +25 -0
  33. package/packages/datadog-plugin-apollo/src/index.js +15 -0
  34. package/packages/datadog-plugin-aws-sdk/src/base.js +3 -3
  35. package/packages/datadog-plugin-aws-sdk/src/services/cloudwatchlogs.js +1 -1
  36. package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +2 -2
  37. package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +1 -1
  38. package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +1 -1
  39. package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +1 -1
  40. package/packages/datadog-plugin-aws-sdk/src/services/redshift.js +1 -1
  41. package/packages/datadog-plugin-aws-sdk/src/services/s3.js +1 -1
  42. package/packages/datadog-plugin-aws-sdk/src/services/sns.js +1 -1
  43. package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +2 -2
  44. package/packages/datadog-plugin-child_process/src/index.js +1 -1
  45. package/packages/datadog-plugin-couchbase/src/index.js +2 -1
  46. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +1 -0
  47. package/packages/datadog-plugin-fetch/src/index.js +1 -1
  48. package/packages/datadog-plugin-graphql/src/resolve.js +1 -1
  49. package/packages/datadog-plugin-grpc/src/client.js +2 -2
  50. package/packages/datadog-plugin-grpc/src/server.js +2 -2
  51. package/packages/datadog-plugin-http/src/client.js +2 -2
  52. package/packages/datadog-plugin-http2/src/client.js +4 -3
  53. package/packages/datadog-plugin-jest/src/index.js +1 -0
  54. package/packages/datadog-plugin-kafkajs/src/consumer.js +1 -1
  55. package/packages/datadog-plugin-kafkajs/src/producer.js +1 -1
  56. package/packages/datadog-plugin-next/src/index.js +1 -1
  57. package/packages/datadog-plugin-openai/src/index.js +4 -4
  58. package/packages/datadog-plugin-playwright/src/index.js +16 -3
  59. package/packages/datadog-plugin-rhea/src/consumer.js +1 -1
  60. package/packages/datadog-plugin-rhea/src/producer.js +1 -1
  61. package/packages/datadog-plugin-router/src/index.js +1 -1
  62. package/packages/datadog-plugin-tedious/src/index.js +1 -1
  63. package/packages/dd-trace/src/appsec/blocking.js +1 -1
  64. package/packages/dd-trace/src/appsec/iast/analyzers/analyzers.js +17 -17
  65. package/packages/dd-trace/src/appsec/iast/analyzers/cookie-analyzer.js +1 -0
  66. package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-secrets-rules.js +132 -132
  67. package/packages/dd-trace/src/appsec/iast/analyzers/hsts-header-missing-analyzer.js +1 -0
  68. package/packages/dd-trace/src/appsec/iast/analyzers/nosql-injection-mongodb-analyzer.js +1 -1
  69. package/packages/dd-trace/src/appsec/iast/overhead-controller.js +2 -1
  70. package/packages/dd-trace/src/appsec/iast/taint-tracking/index.js +3 -3
  71. package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +4 -4
  72. package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +1 -1
  73. package/packages/dd-trace/src/appsec/iast/telemetry/namespaces.js +27 -18
  74. package/packages/dd-trace/src/appsec/iast/telemetry/span-tags.js +1 -1
  75. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/sql-sensitive-analyzer.js +1 -1
  76. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/utils.js +7 -4
  77. package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +2 -2
  78. package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +0 -1
  79. package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +2 -1
  80. package/packages/dd-trace/src/ci-visibility/test-api-manual/test-api-manual-plugin.js +1 -0
  81. package/packages/dd-trace/src/config.js +13 -13
  82. package/packages/dd-trace/src/datastreams/pathway.js +1 -1
  83. package/packages/dd-trace/src/datastreams/processor.js +15 -15
  84. package/packages/dd-trace/src/encode/agentless-ci-visibility.js +2 -2
  85. package/packages/dd-trace/src/encode/coverage-ci-visibility.js +1 -1
  86. package/packages/dd-trace/src/exporters/common/request.js +1 -0
  87. package/packages/dd-trace/src/exporters/span-stats/writer.js +0 -1
  88. package/packages/dd-trace/src/external-logger/src/index.js +5 -5
  89. package/packages/dd-trace/src/opentelemetry/span.js +2 -0
  90. package/packages/dd-trace/src/opentracing/propagation/text_map.js +1 -1
  91. package/packages/dd-trace/src/opentracing/span.js +1 -1
  92. package/packages/dd-trace/src/plugin_manager.js +1 -2
  93. package/packages/dd-trace/src/plugins/apollo.js +52 -0
  94. package/packages/dd-trace/src/plugins/ci_plugin.js +2 -1
  95. package/packages/dd-trace/src/plugins/composite.js +4 -4
  96. package/packages/dd-trace/src/plugins/database.js +1 -0
  97. package/packages/dd-trace/src/plugins/index.js +44 -43
  98. package/packages/dd-trace/src/plugins/plugin.js +1 -1
  99. package/packages/dd-trace/src/plugins/tracing.js +9 -6
  100. package/packages/dd-trace/src/plugins/util/test.js +2 -1
  101. package/packages/dd-trace/src/plugins/util/web.js +4 -4
  102. package/packages/dd-trace/src/profiling/config.js +1 -1
  103. package/packages/dd-trace/src/profiling/loggers/console.js +1 -1
  104. package/packages/dd-trace/src/profiling/profilers/events.js +79 -82
  105. package/packages/dd-trace/src/proxy.js +2 -0
  106. package/packages/dd-trace/src/runtime_metrics.js +8 -5
  107. package/packages/dd-trace/src/serverless.js +3 -2
  108. package/packages/dd-trace/src/service-naming/schemas/v0/web.js +24 -0
  109. package/packages/dd-trace/src/service-naming/schemas/v1/storage.js +0 -1
  110. package/packages/dd-trace/src/service-naming/schemas/v1/web.js +24 -0
  111. package/packages/dd-trace/src/span_processor.js +2 -2
  112. package/packages/dd-trace/src/span_stats.js +1 -1
  113. package/packages/dd-trace/src/telemetry/dependencies.js +4 -5
  114. package/packages/dd-trace/src/telemetry/index.js +12 -13
  115. package/packages/dd-trace/src/telemetry/send-data.js +0 -1
  116. package/packages/dd-trace/src/util.js +7 -7
@@ -48,7 +48,6 @@ dev,eslint-config-standard,MIT,Copyright Feross Aboukhadijeh
48
48
  dev,eslint-plugin-import,MIT,Copyright 2015 Ben Mosher
49
49
  dev,eslint-plugin-mocha,MIT,Copyright 2014 Mathias Schreck
50
50
  dev,eslint-plugin-n,MIT,Copyright 2015 Toru Nagashima
51
- dev,eslint-plugin-node,MIT,Copyright 2015 Toru Nagashima
52
51
  dev,eslint-plugin-promise,ISC,jden and other contributors
53
52
  dev,eslint-plugin-standard,MIT,Copyright 2015 Jamund Ferguson
54
53
  dev,express,MIT,Copyright 2009-2014 TJ Holowaychuk 2013-2014 Roman Shtylman 2014-2015 Douglas Christopher Wilson
package/ci/init.js CHANGED
@@ -20,9 +20,9 @@ if (isAgentlessEnabled) {
20
20
  exporter: 'datadog'
21
21
  }
22
22
  } else {
23
- console.error(`DD_CIVISIBILITY_AGENTLESS_ENABLED is set, \
24
- but neither DD_API_KEY nor DATADOG_API_KEY are set in your environment, \
25
- so dd-trace will not be initialized.`)
23
+ console.error('DD_CIVISIBILITY_AGENTLESS_ENABLED is set, but neither ' +
24
+ 'DD_API_KEY nor DATADOG_API_KEY are set in your environment, so ' +
25
+ 'dd-trace will not be initialized.')
26
26
  shouldInit = false
27
27
  }
28
28
  } else {
package/index.d.ts CHANGED
@@ -137,8 +137,10 @@ interface Tracer extends opentracing.Tracer {
137
137
  // is doesn't need to be exported for Tracer
138
138
  /** @hidden */
139
139
  interface Plugins {
140
+ "aerospike": tracer.plugins.aerospike;
140
141
  "amqp10": tracer.plugins.amqp10;
141
142
  "amqplib": tracer.plugins.amqplib;
143
+ "apollo": tracer.plugins.apollo;
142
144
  "aws-sdk": tracer.plugins.aws_sdk;
143
145
  "bunyan": tracer.plugins.bunyan;
144
146
  "cassandra-driver": tracer.plugins.cassandra_driver;
@@ -1098,6 +1100,12 @@ declare namespace tracer {
1098
1100
  meta?: boolean;
1099
1101
  }
1100
1102
 
1103
+ /**
1104
+ * This plugin automatically instruments the
1105
+ * [aerospike](https://github.com/aerospike/aerospike-client-nodejs) for module versions >= v3.16.2.
1106
+ */
1107
+ interface aerospike extends Instrumentation {}
1108
+
1101
1109
  /**
1102
1110
  * This plugin automatically instruments the
1103
1111
  * [amqp10](https://github.com/noodlefrenzy/node-amqp10) module.
@@ -1110,6 +1118,33 @@ declare namespace tracer {
1110
1118
  */
1111
1119
  interface amqplib extends Instrumentation {}
1112
1120
 
1121
+ /**
1122
+ * Currently this plugin automatically instruments
1123
+ * [@apollo/gateway](https://github.com/apollographql/federation) for module versions >= v2.3.0.
1124
+ * This module uses graphql operations to service requests & thus generates graphql spans.
1125
+ * We recommend disabling the graphql plugin if you only want to trace @apollo/gateway
1126
+ */
1127
+ interface apollo extends Instrumentation {
1128
+ /**
1129
+ * Whether to include the source of the operation within the query as a tag
1130
+ * on every span. This may contain sensitive information and should only be
1131
+ * enabled if sensitive data is always sent as variables and not in the
1132
+ * query text.
1133
+ *
1134
+ * @default false
1135
+ */
1136
+ source?: boolean;
1137
+
1138
+ /**
1139
+ * Whether to enable signature calculation for the resource name. This can
1140
+ * be disabled if your apollo/gateway operations always have a name. Note that when
1141
+ * disabled all queries will need to be named for this to work properly.
1142
+ *
1143
+ * @default true
1144
+ */
1145
+ signature?: boolean;
1146
+ }
1147
+
1113
1148
  /**
1114
1149
  * This plugin automatically instruments the
1115
1150
  * [aws-sdk](https://github.com/aws/aws-sdk-js) module.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dd-trace",
3
- "version": "5.7.0",
3
+ "version": "5.9.0",
4
4
  "description": "Datadog APM tracing client for JavaScript",
5
5
  "main": "index.js",
6
6
  "typings": "index.d.ts",
@@ -73,7 +73,7 @@
73
73
  "@datadog/native-iast-rewriter": "2.3.0",
74
74
  "@datadog/native-iast-taint-tracking": "1.7.0",
75
75
  "@datadog/native-metrics": "^2.0.0",
76
- "@datadog/pprof": "5.1.0",
76
+ "@datadog/pprof": "5.2.0",
77
77
  "@datadog/sketches-js": "^2.1.0",
78
78
  "@opentelemetry/api": "^1.0.0",
79
79
  "@opentelemetry/core": "^1.14.0",
@@ -95,7 +95,7 @@
95
95
  "node-abort-controller": "^3.1.1",
96
96
  "opentracing": ">=0.12.1",
97
97
  "path-to-regexp": "^0.1.2",
98
- "pprof-format": "^2.0.7",
98
+ "pprof-format": "^2.1.0",
99
99
  "protobufjs": "^7.2.5",
100
100
  "retry": "^0.13.1",
101
101
  "semver": "^7.5.4",
@@ -116,11 +116,10 @@
116
116
  "dotenv": "16.3.1",
117
117
  "esbuild": "0.16.12",
118
118
  "eslint": "^8.23.0",
119
- "eslint-config-standard": "^11.0.0-beta.0",
119
+ "eslint-config-standard": "^17.1.0",
120
120
  "eslint-plugin-import": "^2.8.0",
121
121
  "eslint-plugin-mocha": "^10.1.0",
122
122
  "eslint-plugin-n": "^15.7.0",
123
- "eslint-plugin-node": "^5.2.1",
124
123
  "eslint-plugin-promise": "^3.6.0",
125
124
  "eslint-plugin-standard": "^3.0.1",
126
125
  "express": "^4.18.2",
@@ -89,7 +89,7 @@ module.exports.setup = function (build) {
89
89
 
90
90
  let pathToPackageJson
91
91
  try {
92
- pathToPackageJson = require.resolve(`${extracted.pkg}/package.json`, { paths: [ args.resolveDir ] })
92
+ pathToPackageJson = require.resolve(`${extracted.pkg}/package.json`, { paths: [args.resolveDir] })
93
93
  } catch (err) {
94
94
  if (err.code === 'MODULE_NOT_FOUND') {
95
95
  if (!internal) {
@@ -173,7 +173,7 @@ function dotFriendlyResolve (path, directory) {
173
173
  path = '../'
174
174
  }
175
175
 
176
- return require.resolve(path, { paths: [ directory ] })
176
+ return require.resolve(path, { paths: [directory] })
177
177
  }
178
178
 
179
179
  /**
@@ -37,7 +37,7 @@ function wrapExecuteHTTPGraphQLRequest (originalExecuteHTTPGraphQLRequest) {
37
37
  })
38
38
 
39
39
  resolve({
40
- headers: headers,
40
+ headers,
41
41
  status: abortData.statusCode,
42
42
  body: {
43
43
  kind: 'complete',
@@ -0,0 +1,103 @@
1
+ const {
2
+ addHook,
3
+ channel
4
+ } = require('./helpers/instrument')
5
+ const shimmer = require('../../datadog-shimmer')
6
+ const tracingChannel = require('dc-polyfill').tracingChannel
7
+
8
+ const CHANNELS = {
9
+ 'gateway.request': tracingChannel('apm:apollo:gateway:request'),
10
+ 'gateway.plan': tracingChannel('apm:apollo:gateway:plan'),
11
+ 'gateway.validate': tracingChannel('apm:apollo:gateway:validate'),
12
+ 'gateway.execute': tracingChannel('apm:apollo:gateway:execute'),
13
+ 'gateway.fetch': tracingChannel('apm:apollo:gateway:fetch'),
14
+ 'gateway.postprocessing': tracingChannel('apm:apollo:gateway:postprocessing')
15
+ }
16
+
17
+ const generalErrorCh = channel('apm:apollo:gateway:general:error')
18
+
19
+ function wrapExecutor (executor) {
20
+ return function (...args) {
21
+ const channel = CHANNELS['gateway.request']
22
+ const ctx = { requestContext: args[0], gateway: this }
23
+
24
+ return channel.tracePromise(executor, ctx, this, ...args)
25
+ }
26
+ }
27
+
28
+ function wrapApolloGateway (ApolloGateway) {
29
+ class ApolloGatewayWrapper extends ApolloGateway {
30
+ constructor (...args) {
31
+ super(...args)
32
+ shimmer.wrap(this, 'executor', wrapExecutor)
33
+ }
34
+ }
35
+ return ApolloGatewayWrapper
36
+ }
37
+
38
+ function wrapRecordExceptions (recordExceptions) {
39
+ return function wrappedRecordExceptions (...args) {
40
+ const errors = args[1]
41
+ // only the last exception in the array of exceptions will be reported on the span,
42
+ // this is mimicking apollo-gateways internal instrumentation
43
+ // TODO: should we consider a mechanism to report all exceptions? since this method aggregates all exceptions
44
+ // where as a span can only have one exception set on it at a time
45
+ generalErrorCh.publish({ error: errors[errors.length - 1] })
46
+ return recordExceptions.apply(this, args)
47
+ }
48
+ }
49
+
50
+ function wrapStartActiveSpan (startActiveSpan) {
51
+ return function (...args) {
52
+ const firstArg = args[0]
53
+ const cb = args[args.length - 1]
54
+ if (typeof firstArg !== 'string' || typeof cb !== 'function') return startActiveSpan.apply(this, args)
55
+
56
+ const method = CHANNELS[firstArg]
57
+ let ctx = {}
58
+ if (firstArg === 'gateway.fetch') {
59
+ ctx = { attributes: args[1].attributes }
60
+ }
61
+
62
+ switch (firstArg) {
63
+ case 'gateway.plan' :
64
+ case 'gateway.validate': {
65
+ args[args.length - 1] = function (...callbackArgs) {
66
+ return method.traceSync(cb, ctx, this, ...callbackArgs)
67
+ }
68
+ break
69
+ }
70
+ // Patch `executor` instead so the requestContext can be captured.
71
+ case 'gateway.request':
72
+ break
73
+ case 'gateway.execute':
74
+ case 'gateway.postprocessing' :
75
+ case 'gateway.fetch': {
76
+ args[args.length - 1] = function (...callbackArgs) {
77
+ return method.tracePromise(cb, ctx, this, ...callbackArgs)
78
+ }
79
+ break
80
+ }
81
+ }
82
+ return startActiveSpan.apply(this, args)
83
+ }
84
+ }
85
+
86
+ addHook({ name: '@apollo/gateway', file: 'dist/utilities/opentelemetry.js', versions: ['>=2.3.0'] },
87
+ (obj) => {
88
+ const newTracerObj = Object.create(obj.tracer)
89
+ shimmer.wrap(newTracerObj, 'startActiveSpan', wrapStartActiveSpan)
90
+ obj.tracer = newTracerObj
91
+ return obj
92
+ })
93
+
94
+ addHook({ name: '@apollo/gateway', file: 'dist/utilities/opentelemetry.js', versions: ['>=2.6.0'] },
95
+ (obj) => {
96
+ shimmer.wrap(obj, 'recordExceptions', wrapRecordExceptions)
97
+ return obj
98
+ })
99
+
100
+ addHook({ name: '@apollo/gateway', versions: ['>=2.3.0'] }, (gateway) => {
101
+ shimmer.wrap(gateway, 'ApolloGateway', wrapApolloGateway)
102
+ return gateway
103
+ })
@@ -111,6 +111,7 @@ function wrapSmithySend (send) {
111
111
  }
112
112
 
113
113
  function wrapCb (cb, serviceName, request, ar) {
114
+ // eslint-disable-next-line n/handle-callback-err
114
115
  return function wrappedCb (err, response) {
115
116
  const obj = { request, response }
116
117
  return ar.runInAsyncScope(() => {
@@ -163,7 +164,9 @@ function getChannelSuffix (name) {
163
164
  's3',
164
165
  'sns',
165
166
  'sqs'
166
- ].includes(name) ? name : 'default'
167
+ ].includes(name)
168
+ ? name
169
+ : 'default'
167
170
  }
168
171
 
169
172
  addHook({ name: '@smithy/smithy-client', versions: ['>=1.0.3'] }, smithy => {
@@ -10,7 +10,7 @@ const shimmer = require('../../datadog-shimmer')
10
10
  const startCh = channel('apm:cassandra-driver:query:start')
11
11
  const finishCh = channel('apm:cassandra-driver:query:finish')
12
12
  const errorCh = channel('apm:cassandra-driver:query:error')
13
- const connectCh = channel(`apm:cassandra-driver:query:connect`)
13
+ const connectCh = channel('apm:cassandra-driver:query:connect')
14
14
 
15
15
  addHook({ name: 'cassandra-driver', versions: ['>=3.0.0'] }, cassandra => {
16
16
  shimmer.wrap(cassandra.Client.prototype, 'batch', batch => function (queries, options, callback) {
@@ -132,7 +132,8 @@ function wrapRun (pl, isLatestVersion) {
132
132
  promise.finally(() => {
133
133
  const result = this.getWorstStepResult()
134
134
  const { status, skipReason, errorMessage } = isLatestVersion
135
- ? getStatusFromResultLatest(result) : getStatusFromResult(result)
135
+ ? getStatusFromResultLatest(result)
136
+ : getStatusFromResult(result)
136
137
 
137
138
  if (lastStatusByPickleId.has(this.pickle.id)) {
138
139
  lastStatusByPickleId.get(this.pickle.id).push(status)
@@ -177,7 +178,8 @@ function wrapRun (pl, isLatestVersion) {
177
178
 
178
179
  promise.then((result) => {
179
180
  const { status, skipReason, errorMessage } = isLatestVersion
180
- ? getStatusFromResultLatest(result) : getStatusFromResult(result)
181
+ ? getStatusFromResultLatest(result)
182
+ : getStatusFromResult(result)
181
183
 
182
184
  testFinishCh.publish({ isStep: true, status, skipReason, errorMessage })
183
185
  })
@@ -290,6 +292,8 @@ function getWrappedStart (start, frameworkVersion) {
290
292
  const knownTestsResponse = await knownTestsPromise
291
293
  if (!knownTestsResponse.err) {
292
294
  knownTests = knownTestsResponse.knownTests
295
+ } else {
296
+ isEarlyFlakeDetectionEnabled = false
293
297
  }
294
298
  }
295
299
 
@@ -1,4 +1,3 @@
1
-
2
1
  'use strict'
3
2
 
4
3
  const {
@@ -11,7 +11,7 @@ const requestStartCh = channel('apm:google-cloud-pubsub:request:start')
11
11
  const requestFinishCh = channel('apm:google-cloud-pubsub:request:finish')
12
12
  const requestErrorCh = channel('apm:google-cloud-pubsub:request:error')
13
13
 
14
- const receiveStartCh = channel(`apm:google-cloud-pubsub:receive:start`)
14
+ const receiveStartCh = channel('apm:google-cloud-pubsub:receive:start')
15
15
  const receiveFinishCh = channel('apm:google-cloud-pubsub:receive:finish')
16
16
  const receiveErrorCh = channel('apm:google-cloud-pubsub:receive:error')
17
17
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  module.exports = {
4
4
  '@apollo/server': () => require('../apollo-server'),
5
+ '@apollo/gateway': () => require('../apollo'),
5
6
  'apollo-server-core': () => require('../apollo-server-core'),
6
7
  '@aws-sdk/smithy-client': () => require('../aws-sdk'),
7
8
  '@cucumber/cucumber': () => require('../cucumber'),
@@ -22,62 +23,62 @@ module.exports = {
22
23
  '@opentelemetry/sdk-trace-node': () => require('../otel-sdk-trace'),
23
24
  '@redis/client': () => require('../redis'),
24
25
  '@smithy/smithy-client': () => require('../aws-sdk'),
25
- 'aerospike': () => require('../aerospike'),
26
- 'amqp10': () => require('../amqp10'),
27
- 'amqplib': () => require('../amqplib'),
26
+ aerospike: () => require('../aerospike'),
27
+ amqp10: () => require('../amqp10'),
28
+ amqplib: () => require('../amqplib'),
28
29
  'aws-sdk': () => require('../aws-sdk'),
29
- 'bluebird': () => require('../bluebird'),
30
+ bluebird: () => require('../bluebird'),
30
31
  'body-parser': () => require('../body-parser'),
31
- 'bunyan': () => require('../bunyan'),
32
+ bunyan: () => require('../bunyan'),
32
33
  'cassandra-driver': () => require('../cassandra-driver'),
33
- 'child_process': () => require('../child_process'),
34
- 'connect': () => require('../connect'),
35
- 'cookie': () => require('../cookie'),
34
+ child_process: () => require('../child_process'),
35
+ connect: () => require('../connect'),
36
+ cookie: () => require('../cookie'),
36
37
  'cookie-parser': () => require('../cookie-parser'),
37
- 'couchbase': () => require('../couchbase'),
38
- 'crypto': () => require('../crypto'),
39
- 'cypress': () => require('../cypress'),
40
- 'dns': () => require('../dns'),
41
- 'elasticsearch': () => require('../elasticsearch'),
42
- 'express': () => require('../express'),
38
+ couchbase: () => require('../couchbase'),
39
+ crypto: () => require('../crypto'),
40
+ cypress: () => require('../cypress'),
41
+ dns: () => require('../dns'),
42
+ elasticsearch: () => require('../elasticsearch'),
43
+ express: () => require('../express'),
43
44
  'express-mongo-sanitize': () => require('../express-mongo-sanitize'),
44
- 'fastify': () => require('../fastify'),
45
+ fastify: () => require('../fastify'),
45
46
  'find-my-way': () => require('../find-my-way'),
46
- 'fs': () => require('../fs'),
47
+ fs: () => require('../fs'),
47
48
  'generic-pool': () => require('../generic-pool'),
48
- 'graphql': () => require('../graphql'),
49
- 'grpc': () => require('../grpc'),
50
- 'hapi': () => require('../hapi'),
51
- 'http': () => require('../http'),
52
- 'http2': () => require('../http2'),
53
- 'https': () => require('../http'),
54
- 'ioredis': () => require('../ioredis'),
49
+ graphql: () => require('../graphql'),
50
+ grpc: () => require('../grpc'),
51
+ hapi: () => require('../hapi'),
52
+ http: () => require('../http'),
53
+ http2: () => require('../http2'),
54
+ https: () => require('../http'),
55
+ ioredis: () => require('../ioredis'),
55
56
  'jest-circus': () => require('../jest'),
56
57
  'jest-config': () => require('../jest'),
57
58
  'jest-environment-node': () => require('../jest'),
58
59
  'jest-environment-jsdom': () => require('../jest'),
59
60
  'jest-jasmine2': () => require('../jest'),
60
61
  'jest-worker': () => require('../jest'),
61
- 'knex': () => require('../knex'),
62
- 'koa': () => require('../koa'),
62
+ knex: () => require('../knex'),
63
+ koa: () => require('../koa'),
63
64
  'koa-router': () => require('../koa'),
64
- 'kafkajs': () => require('../kafkajs'),
65
- 'ldapjs': () => require('../ldapjs'),
65
+ kafkajs: () => require('../kafkajs'),
66
+ ldapjs: () => require('../ldapjs'),
66
67
  'limitd-client': () => require('../limitd-client'),
67
- 'mariadb': () => require('../mariadb'),
68
- 'memcached': () => require('../memcached'),
68
+ mariadb: () => require('../mariadb'),
69
+ memcached: () => require('../memcached'),
69
70
  'microgateway-core': () => require('../microgateway-core'),
70
- 'mocha': () => require('../mocha'),
71
+ mocha: () => require('../mocha'),
71
72
  'mocha-each': () => require('../mocha'),
72
- 'moleculer': () => require('../moleculer'),
73
- 'mongodb': () => require('../mongodb'),
73
+ moleculer: () => require('../moleculer'),
74
+ mongodb: () => require('../mongodb'),
74
75
  'mongodb-core': () => require('../mongodb-core'),
75
- 'mongoose': () => require('../mongoose'),
76
- 'mquery': () => require('../mquery'),
77
- 'mysql': () => require('../mysql'),
78
- 'mysql2': () => require('../mysql2'),
79
- 'net': () => require('../net'),
80
- 'next': () => require('../next'),
76
+ mongoose: () => require('../mongoose'),
77
+ mquery: () => require('../mquery'),
78
+ mysql: () => require('../mysql'),
79
+ mysql2: () => require('../mysql2'),
80
+ net: () => require('../net'),
81
+ next: () => require('../next'),
81
82
  'node:child_process': () => require('../child_process'),
82
83
  'node:crypto': () => require('../crypto'),
83
84
  'node:dns': () => require('../dns'),
@@ -85,26 +86,26 @@ module.exports = {
85
86
  'node:http2': () => require('../http2'),
86
87
  'node:https': () => require('../http'),
87
88
  'node:net': () => require('../net'),
88
- 'oracledb': () => require('../oracledb'),
89
- 'openai': () => require('../openai'),
90
- 'paperplane': () => require('../paperplane'),
89
+ oracledb: () => require('../oracledb'),
90
+ openai: () => require('../openai'),
91
+ paperplane: () => require('../paperplane'),
91
92
  'passport-http': () => require('../passport-http'),
92
93
  'passport-local': () => require('../passport-local'),
93
- 'pg': () => require('../pg'),
94
- 'pino': () => require('../pino'),
94
+ pg: () => require('../pg'),
95
+ pino: () => require('../pino'),
95
96
  'pino-pretty': () => require('../pino'),
96
- 'playwright': () => require('../playwright'),
97
+ playwright: () => require('../playwright'),
97
98
  'promise-js': () => require('../promise-js'),
98
- 'promise': () => require('../promise'),
99
- 'q': () => require('../q'),
100
- 'qs': () => require('../qs'),
101
- 'redis': () => require('../redis'),
102
- 'restify': () => require('../restify'),
103
- 'rhea': () => require('../rhea'),
104
- 'router': () => require('../router'),
105
- 'sharedb': () => require('../sharedb'),
106
- 'sequelize': () => require('../sequelize'),
107
- 'tedious': () => require('../tedious'),
108
- 'when': () => require('../when'),
109
- 'winston': () => require('../winston')
99
+ promise: () => require('../promise'),
100
+ q: () => require('../q'),
101
+ qs: () => require('../qs'),
102
+ redis: () => require('../redis'),
103
+ restify: () => require('../restify'),
104
+ rhea: () => require('../rhea'),
105
+ router: () => require('../router'),
106
+ sharedb: () => require('../sharedb'),
107
+ sequelize: () => require('../sequelize'),
108
+ tedious: () => require('../tedious'),
109
+ when: () => require('../when'),
110
+ winston: () => require('../winston')
110
111
  }
@@ -56,13 +56,13 @@ if (semver.satisfies(process.versions.node, '>=17.8.0')) {
56
56
  bound = this.runInAsyncScope.bind(this, fn, thisArg)
57
57
  }
58
58
  Object.defineProperties(bound, {
59
- 'length': {
59
+ length: {
60
60
  configurable: true,
61
61
  enumerable: false,
62
62
  value: fn.length,
63
63
  writable: false
64
64
  },
65
- 'asyncResource': {
65
+ asyncResource: {
66
66
  configurable: true,
67
67
  enumerable: true,
68
68
  value: this,
@@ -155,6 +155,7 @@ function patch (http, methodName) {
155
155
  try {
156
156
  return urlToOptions(new url.URL(inputURL))
157
157
  } catch (e) {
158
+ // eslint-disable-next-line n/no-deprecated-api
158
159
  return url.parse(inputURL)
159
160
  }
160
161
  } else if (inputURL instanceof url.URL) {
@@ -10,7 +10,7 @@ const {
10
10
  getTestLineStart,
11
11
  getTestSuitePath,
12
12
  getTestParametersString,
13
- EFD_STRING,
13
+ addEfdStringToTestName,
14
14
  removeEfdStringFromTestName
15
15
  } = require('../../dd-trace/src/plugins/util/test')
16
16
  const {
@@ -63,11 +63,11 @@ let hasFilteredSkippableSuites = false
63
63
  const sessionAsyncResource = new AsyncResource('bound-anonymous-fn')
64
64
 
65
65
  const specStatusToTestStatus = {
66
- 'pending': 'skip',
67
- 'disabled': 'skip',
68
- 'todo': 'skip',
69
- 'passed': 'pass',
70
- 'failed': 'fail'
66
+ pending: 'skip',
67
+ disabled: 'skip',
68
+ todo: 'skip',
69
+ passed: 'pass',
70
+ failed: 'fail'
71
71
  }
72
72
 
73
73
  const asyncResources = new WeakMap()
@@ -101,10 +101,6 @@ function getTestEnvironmentOptions (config) {
101
101
  return {}
102
102
  }
103
103
 
104
- function getEfdTestName (testName, numAttempt) {
105
- return `${EFD_STRING} (#${numAttempt}): ${testName}`
106
- }
107
-
108
104
  function getWrappedEnvironment (BaseEnvironment, jestVersion) {
109
105
  return class DatadogEnvironment extends BaseEnvironment {
110
106
  constructor (config, context) {
@@ -156,7 +152,8 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
156
152
  // we use its describe block to get the full name
157
153
  getTestNameFromAddTestEvent (event, state) {
158
154
  const describeSuffix = getJestTestName(state.currentDescribeBlock)
159
- return removeEfdStringFromTestName(`${describeSuffix} ${event.testName}`).trim()
155
+ const fullTestName = describeSuffix ? `${describeSuffix} ${event.testName}` : event.testName
156
+ return removeEfdStringFromTestName(fullTestName)
160
157
  }
161
158
 
162
159
  async handleTestEvent (event, state) {
@@ -197,7 +194,6 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
197
194
  retriedTestsToNumAttempts.set(originalTestName, numEfdRetry + 1)
198
195
  }
199
196
  }
200
-
201
197
  asyncResource.runInAsyncScope(() => {
202
198
  testStartCh.publish({
203
199
  name: removeEfdStringFromTestName(testName),
@@ -223,7 +219,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
223
219
  retriedTestsToNumAttempts.set(testName, 0)
224
220
  for (let retryIndex = 0; retryIndex < earlyFlakeDetectionNumRetries; retryIndex++) {
225
221
  if (this.global.test) {
226
- this.global.test(getEfdTestName(event.testName, retryIndex), event.fn, event.timeout)
222
+ this.global.test(addEfdStringToTestName(event.testName, retryIndex), event.fn, event.timeout)
227
223
  } else {
228
224
  log.error('Early flake detection could not retry test because global.test is undefined')
229
225
  }
@@ -405,6 +401,9 @@ function cliWrapper (cli, jestVersion) {
405
401
  const { err, knownTests: receivedKnownTests } = await knownTestsPromise
406
402
  if (!err) {
407
403
  knownTests = receivedKnownTests
404
+ } else {
405
+ // We disable EFD if there has been an error in the known tests request
406
+ isEarlyFlakeDetectionEnabled = false
408
407
  }
409
408
  } catch (err) {
410
409
  log.error(err)
@@ -38,7 +38,8 @@ addHook({ name: 'kafkajs', file: 'src/index.js', versions: ['>=1.4'] }, (BaseKaf
38
38
  constructor (options) {
39
39
  super(options)
40
40
  this._brokers = (options.brokers && typeof options.brokers !== 'function')
41
- ? options.brokers.join(',') : undefined
41
+ ? options.brokers.join(',')
42
+ : undefined
42
43
  }
43
44
  }
44
45
 
@@ -76,8 +76,9 @@ addHook({ name: 'ldapjs', versions: ['>=2'] }, ldapjs => {
76
76
  const callbackIndex = getCallbackArgIndex(arguments)
77
77
  if (callbackIndex > -1) {
78
78
  const callback = arguments[callbackIndex]
79
+ // eslint-disable-next-line n/handle-callback-err
79
80
  arguments[callbackIndex] = shimmer.wrap(callback, function (err, corkedEmitter) {
80
- if (typeof corkedEmitter === 'object' && typeof corkedEmitter['on'] === 'function') {
81
+ if (typeof corkedEmitter === 'object' && typeof corkedEmitter.on === 'function') {
81
82
  wrapEmitter(corkedEmitter)
82
83
  }
83
84
  callback.apply(this, arguments)
@@ -483,7 +483,7 @@ addHook({
483
483
  */
484
484
  shimmer.wrap(Mocha.prototype, 'run', run => function () {
485
485
  if (this.options.parallel) {
486
- log.warn(`Unable to initialize CI Visibility because Mocha is running in parallel mode.`)
486
+ log.warn('Unable to initialize CI Visibility because Mocha is running in parallel mode.')
487
487
  return run.apply(this, arguments)
488
488
  }
489
489
 
@@ -7,9 +7,9 @@ const {
7
7
  } = require('./helpers/instrument')
8
8
  const shimmer = require('../../datadog-shimmer')
9
9
 
10
- const startCh = channel(`apm:mongodb:query:start`)
11
- const finishCh = channel(`apm:mongodb:query:finish`)
12
- const errorCh = channel(`apm:mongodb:query:error`)
10
+ const startCh = channel('apm:mongodb:query:start')
11
+ const finishCh = channel('apm:mongodb:query:finish')
12
+ const errorCh = channel('apm:mongodb:query:error')
13
13
 
14
14
  addHook({ name: 'mongodb-core', versions: ['2 - 3.1.9'] }, Server => {
15
15
  const serverProto = Server.Server.prototype
@@ -197,7 +197,7 @@ function instrumentPromise (operation, command, ctx, args, server, ns, ops, opti
197
197
 
198
198
  const promise = command.apply(ctx, args)
199
199
 
200
- promise.then(function (res) {
200
+ return promise.then(function (res) {
201
201
  finishCh.publish()
202
202
  return res
203
203
  }, function (err) {
@@ -206,7 +206,5 @@ function instrumentPromise (operation, command, ctx, args, server, ns, ops, opti
206
206
 
207
207
  return Promise.reject(err)
208
208
  })
209
-
210
- return promise
211
209
  })
212
210
  }