dd-trace 5.50.0 → 5.51.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dd-trace",
3
- "version": "5.50.0",
3
+ "version": "5.51.0",
4
4
  "description": "Datadog APM tracing client for JavaScript",
5
5
  "main": "index.js",
6
6
  "typings": "index.d.ts",
@@ -54,7 +54,6 @@
54
54
  "test:integration:selenium": "mocha --timeout 60000 -r \"packages/dd-trace/test/setup/core.js\" \"integration-tests/selenium/*.spec.js\"",
55
55
  "test:integration:vitest": "mocha --timeout 60000 -r \"packages/dd-trace/test/setup/core.js\" \"integration-tests/vitest/*.spec.js\"",
56
56
  "test:integration:profiler": "mocha --timeout 180000 -r \"packages/dd-trace/test/setup/core.js\" \"integration-tests/profiler/*.spec.js\"",
57
- "test:integration:serverless": "mocha --timeout 60000 -r \"packages/dd-trace/test/setup/core.js\" \"integration-tests/serverless/*.spec.js\"",
58
57
  "test:integration:plugins": "mocha -r \"packages/dd-trace/test/setup/mocha.js\" \"packages/datadog-plugin-@($(echo $PLUGINS))/test/integration-test/**/*.spec.js\"",
59
58
  "test:unit:plugins": "mocha -r \"packages/dd-trace/test/setup/mocha.js\" \"packages/datadog-instrumentations/test/@($(echo $PLUGINS)).spec.js\" \"packages/datadog-plugin-@($(echo $PLUGINS))/test/**/*.spec.js\" --exclude \"packages/datadog-plugin-@($(echo $PLUGINS))/test/integration-test/**/*.spec.js\"",
60
59
  "test:shimmer": "mocha 'packages/datadog-shimmer/test/**/*.spec.js'",
@@ -115,7 +115,16 @@ for (const packageName of names) {
115
115
  continue
116
116
  }
117
117
  if (typeof namesAndSuccesses[`${name}@${version}`] === 'undefined') {
118
- namesAndSuccesses[`${name}@${version}`] = false
118
+ // TODO If `file` is present, we might elsewhere instrument the result of the module
119
+ // for a version range that actually matches, so we can't assume that we're _not_
120
+ // going to instrument that. However, the way the data model around instrumentation
121
+ // works, we can't know either way just yet, so to avoid false positives, we'll just
122
+ // ignore this if there is a `file` in the hook. The thing to do here is rework
123
+ // everything so that we can be sure that there are _no_ instrumentations that it
124
+ // could match.
125
+ if (!file) {
126
+ namesAndSuccesses[`${name}@${version}`] = false
127
+ }
119
128
  }
120
129
 
121
130
  if (matchVersion(version, versions)) {
@@ -81,6 +81,7 @@ const sessionAsyncResource = new AsyncResource('bound-anonymous-fn')
81
81
 
82
82
  const asyncResources = new WeakMap()
83
83
  const originalTestFns = new WeakMap()
84
+ const originalHookFns = new WeakMap()
84
85
  const retriedTestsToNumAttempts = new Map()
85
86
  const newTestsTestStatuses = new Map()
86
87
  const attemptToFixRetriedTestsStatuses = new Map()
@@ -154,7 +155,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
154
155
  const hasKnownTests = !!knownTests?.jest
155
156
  earlyFlakeDetectionNumRetries = this.testEnvironmentOptions._ddEarlyFlakeDetectionNumRetries
156
157
  this.knownTestsForThisSuite = hasKnownTests
157
- ? (knownTests?.jest[this.testSuite] || [])
158
+ ? (knownTests?.jest?.[this.testSuite] || [])
158
159
  : this.getKnownTestsForSuite(this.testEnvironmentOptions._ddKnownTests)
159
160
  } catch (e) {
160
161
  // If there has been an error parsing the tests, we'll disable Early Flake Deteciton
@@ -172,10 +173,10 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
172
173
 
173
174
  if (this.isTestManagementTestsEnabled) {
174
175
  try {
175
- const hasTestManagementTests = !!testManagementTests.jest
176
+ const hasTestManagementTests = !!testManagementTests?.jest
176
177
  testManagementAttemptToFixRetries = this.testEnvironmentOptions._ddTestManagementAttemptToFixRetries
177
178
  this.testManagementTestsForThisSuite = hasTestManagementTests
178
- ? this.getTestManagementTestsForSuite(testManagementTests.jest.suites?.[this.testSuite]?.tests)
179
+ ? this.getTestManagementTestsForSuite(testManagementTests?.jest?.suites?.[this.testSuite]?.tests)
179
180
  : this.getTestManagementTestsForSuite(this.testEnvironmentOptions._ddTestManagementTests)
180
181
  } catch (e) {
181
182
  log.error('Error parsing test management tests', e)
@@ -351,6 +352,15 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
351
352
  isDisabled,
352
353
  isQuarantined
353
354
  })
355
+ for (const hook of event.test.parent.hooks) {
356
+ let hookFn = hook.fn
357
+ if (!originalHookFns.has(hook)) {
358
+ originalHookFns.set(hook, hookFn)
359
+ } else {
360
+ hookFn = originalHookFns.get(hook)
361
+ }
362
+ hook.fn = asyncResource.bind(hookFn)
363
+ }
354
364
  originalTestFns.set(event.test, event.test.fn)
355
365
  event.test.fn = asyncResource.bind(event.test.fn)
356
366
  })
@@ -1186,7 +1196,7 @@ addHook({
1186
1196
  const testSuite = getTestSuitePath(testSuiteAbsolutePath, globalConfig.rootDir || process.cwd())
1187
1197
  const suiteKnownTests = knownTests?.jest?.[testSuite] || []
1188
1198
 
1189
- const suiteTestManagementTests = testManagementTests.jest?.suites?.[testSuite]?.tests || {}
1199
+ const suiteTestManagementTests = testManagementTests?.jest?.suites?.[testSuite]?.tests || {}
1190
1200
 
1191
1201
  args[0].config = {
1192
1202
  ...config,