dd-trace 6.0.0-pre-2b43d31 → 6.0.0-pre-c26eac4

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dd-trace",
3
- "version": "6.0.0-pre-2b43d31",
3
+ "version": "6.0.0-pre-c26eac4",
4
4
  "description": "Datadog APM tracing client for JavaScript",
5
5
  "main": "index.js",
6
6
  "typings": "index.d.ts",
@@ -44,11 +44,14 @@ const knownTestsCh = channel('ci:jest:known-tests')
44
44
 
45
45
  const itrSkippedSuitesCh = channel('ci:jest:itr:skipped-suites')
46
46
 
47
+ // Message sent by jest's main process to workers to run a test suite (=test file)
48
+ // https://github.com/jestjs/jest/blob/1d682f21c7a35da4d3ab3a1436a357b980ebd0fa/packages/jest-worker/src/types.ts#L37
49
+ const CHILD_MESSAGE_CALL = 1
47
50
  // Maximum time we'll wait for the tracer to flush
48
51
  const FLUSH_TIMEOUT = 10000
49
52
 
50
53
  let skippableSuites = []
51
- let knownTests = []
54
+ let knownTests = {}
52
55
  let isCodeCoverageEnabled = false
53
56
  let isSuitesSkippingEnabled = false
54
57
  let isUserCodeCoverageEnabled = false
@@ -123,9 +126,12 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
123
126
  this.isEarlyFlakeDetectionEnabled = this.testEnvironmentOptions._ddIsEarlyFlakeDetectionEnabled
124
127
 
125
128
  if (this.isEarlyFlakeDetectionEnabled) {
129
+ const hasKnownTests = !!knownTests.jest
126
130
  earlyFlakeDetectionNumRetries = this.testEnvironmentOptions._ddEarlyFlakeDetectionNumRetries
127
131
  try {
128
- this.knownTestsForThisSuite = this.getKnownTestsForSuite(this.testEnvironmentOptions._ddKnownTests)
132
+ this.knownTestsForThisSuite = hasKnownTests
133
+ ? (knownTests.jest[this.testSuite] || [])
134
+ : this.getKnownTestsForSuite(this.testEnvironmentOptions._ddKnownTests)
129
135
  } catch (e) {
130
136
  // If there has been an error parsing the tests, we'll disable Early Flake Deteciton
131
137
  this.isEarlyFlakeDetectionEnabled = false
@@ -145,7 +151,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
145
151
  if (typeof knownTestsForSuite === 'string') {
146
152
  knownTestsForSuite = JSON.parse(knownTestsForSuite)
147
153
  }
148
- return knownTestsForSuite.jest?.[this.testSuite] || []
154
+ return knownTestsForSuite
149
155
  }
150
156
 
151
157
  // Add the `add_test` event we don't have the test object yet, so
@@ -619,7 +625,6 @@ function configureTestEnvironment (readConfigsResult) {
619
625
  // because `jestAdapterWrapper` runs in a different process. We have to go through `testEnvironmentOptions`
620
626
  configs.forEach(config => {
621
627
  config.testEnvironmentOptions._ddTestCodeCoverageEnabled = isCodeCoverageEnabled
622
- config.testEnvironmentOptions._ddKnownTests = knownTests
623
628
  })
624
629
 
625
630
  isUserCodeCoverageEnabled = !!readConfigsResult.globalConfig.collectCoverage
@@ -795,6 +800,38 @@ addHook({
795
800
  file: 'build/workers/ChildProcessWorker.js'
796
801
  }, (childProcessWorker) => {
797
802
  const ChildProcessWorker = childProcessWorker.default
803
+ shimmer.wrap(ChildProcessWorker.prototype, 'send', send => function (request) {
804
+ if (!isEarlyFlakeDetectionEnabled) {
805
+ return send.apply(this, arguments)
806
+ }
807
+ const [type] = request
808
+ // eslint-disable-next-line
809
+ // https://github.com/jestjs/jest/blob/1d682f21c7a35da4d3ab3a1436a357b980ebd0fa/packages/jest-worker/src/workers/ChildProcessWorker.ts#L424
810
+ if (type === CHILD_MESSAGE_CALL) {
811
+ // This is the message that the main process sends to the worker to run a test suite (=test file).
812
+ // In here we modify the config.testEnvironmentOptions to include the known tests for the suite.
813
+ // This way the suite only knows about the tests that are part of it.
814
+ const args = request[request.length - 1]
815
+ if (args.length > 1) {
816
+ return send.apply(this, arguments)
817
+ }
818
+ if (!args[0]?.config) {
819
+ return send.apply(this, arguments)
820
+ }
821
+ const [{ globalConfig, config, path: testSuiteAbsolutePath }] = args
822
+ const testSuite = getTestSuitePath(testSuiteAbsolutePath, globalConfig.rootDir || process.cwd())
823
+ const suiteKnownTests = knownTests.jest?.[testSuite] || []
824
+ args[0].config = {
825
+ ...config,
826
+ testEnvironmentOptions: {
827
+ ...config.testEnvironmentOptions,
828
+ _ddKnownTests: suiteKnownTests
829
+ }
830
+ }
831
+ }
832
+
833
+ return send.apply(this, arguments)
834
+ })
798
835
  shimmer.wrap(ChildProcessWorker.prototype, '_onMessage', _onMessage => function () {
799
836
  const [code, data] = arguments[0]
800
837
  if (code === JEST_WORKER_TRACE_PAYLOAD_CODE) { // datadog trace payload
@@ -21,7 +21,7 @@ function finish (err) {
21
21
  finishChannel.publish(undefined)
22
22
  }
23
23
 
24
- addHook({ name: 'oracledb', versions: ['5'] }, oracledb => {
24
+ addHook({ name: 'oracledb', versions: ['>=5'] }, oracledb => {
25
25
  shimmer.wrap(oracledb.Connection.prototype, 'execute', execute => {
26
26
  return function wrappedExecute (dbQuery, ...args) {
27
27
  if (!startChannel.hasSubscribers) {
@@ -20,11 +20,15 @@ const EXCLUDED_LOCATIONS = getNodeModulesPaths(
20
20
  'pusher/lib/utils.js',
21
21
  'redlock/dist/cjs',
22
22
  'sqreen/lib/package-reader/index.js',
23
- 'ws/lib/websocket-server.js'
23
+ 'ws/lib/websocket-server.js',
24
+ 'google-gax/build/src/grpc.js',
25
+ 'cookie-signature/index.js'
24
26
  )
25
27
 
26
28
  const EXCLUDED_PATHS_FROM_STACK = [
27
- path.join('node_modules', 'object-hash', path.sep)
29
+ path.join('node_modules', 'object-hash', path.sep),
30
+ path.join('node_modules', 'aws-sdk', 'lib', 'util.js'),
31
+ path.join('node_modules', 'keygrip', path.sep)
28
32
  ]
29
33
  class WeakHashAnalyzer extends Analyzer {
30
34
  constructor () {