dd-trace 5.14.0 → 5.14.1
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 +1 -1
- package/packages/datadog-esbuild/index.js +1 -31
- package/packages/datadog-instrumentations/src/check_require_cache.js +41 -0
- package/packages/datadog-instrumentations/src/helpers/hooks.js +0 -1
- package/packages/datadog-instrumentations/src/helpers/register.js +7 -1
- package/packages/datadog-instrumentations/src/jest.js +0 -48
- package/packages/datadog-instrumentations/src/utils/src/extract-package-and-module-path.js +33 -0
- package/packages/dd-trace/src/plugins/index.js +0 -1
package/package.json
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
const instrumentations = require('../datadog-instrumentations/src/helpers/instrumentations.js')
|
|
6
6
|
const hooks = require('../datadog-instrumentations/src/helpers/hooks.js')
|
|
7
|
+
const extractPackageAndModulePath = require('../datadog-instrumentations/src/utils/src/extract-package-and-module-path')
|
|
7
8
|
|
|
8
9
|
for (const hook of Object.values(hooks)) {
|
|
9
10
|
hook()
|
|
@@ -21,7 +22,6 @@ for (const instrumentation of Object.values(instrumentations)) {
|
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
const NM = 'node_modules/'
|
|
25
25
|
const INSTRUMENTED = Object.keys(instrumentations)
|
|
26
26
|
const RAW_BUILTINS = require('module').builtinModules
|
|
27
27
|
const CHANNEL = 'dd-trace:bundler:load'
|
|
@@ -181,33 +181,3 @@ function dotFriendlyResolve (path, directory) {
|
|
|
181
181
|
|
|
182
182
|
return require.resolve(path, { paths: [directory] })
|
|
183
183
|
}
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* For a given full path to a module,
|
|
187
|
-
* return the package name it belongs to and the local path to the module
|
|
188
|
-
* input: '/foo/node_modules/@co/stuff/foo/bar/baz.js'
|
|
189
|
-
* output: { pkg: '@co/stuff', path: 'foo/bar/baz.js' }
|
|
190
|
-
*/
|
|
191
|
-
function extractPackageAndModulePath (fullPath) {
|
|
192
|
-
const nm = fullPath.lastIndexOf(NM)
|
|
193
|
-
if (nm < 0) {
|
|
194
|
-
return { pkg: null, path: null }
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
const subPath = fullPath.substring(nm + NM.length)
|
|
198
|
-
const firstSlash = subPath.indexOf('/')
|
|
199
|
-
|
|
200
|
-
if (subPath[0] === '@') {
|
|
201
|
-
const secondSlash = subPath.substring(firstSlash + 1).indexOf('/')
|
|
202
|
-
|
|
203
|
-
return {
|
|
204
|
-
pkg: subPath.substring(0, firstSlash + 1 + secondSlash),
|
|
205
|
-
path: subPath.substring(firstSlash + 1 + secondSlash + 1)
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
return {
|
|
210
|
-
pkg: subPath.substring(0, firstSlash),
|
|
211
|
-
path: subPath.substring(firstSlash + 1)
|
|
212
|
-
}
|
|
213
|
-
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
/* eslint-disable no-console */
|
|
4
|
+
|
|
5
|
+
const extractPackageAndModulePath = require('./utils/src/extract-package-and-module-path')
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The lowest hanging fruit to debug an app that isn't tracing
|
|
9
|
+
* properly is to check that it is loaded before any modules
|
|
10
|
+
* that need to be instrumented. This function checks the
|
|
11
|
+
* `require.cache` to see if any supported packages have
|
|
12
|
+
* already been required and prints a warning.
|
|
13
|
+
*
|
|
14
|
+
* Note that this only going to work for modules within npm
|
|
15
|
+
* packages, like `express`, and not internal modules, like
|
|
16
|
+
* `http`.
|
|
17
|
+
*
|
|
18
|
+
* The output isn't necessarily 100% perfect. For example if the
|
|
19
|
+
* app loads a package we instrument but outside of an
|
|
20
|
+
* unsupported version then a warning would still be displayed.
|
|
21
|
+
* This is OK as the tracer should be loaded earlier anyway.
|
|
22
|
+
*/
|
|
23
|
+
module.exports = function () {
|
|
24
|
+
const packages = require('../../datadog-instrumentations/src/helpers/hooks')
|
|
25
|
+
const naughties = new Set()
|
|
26
|
+
let didWarn = false
|
|
27
|
+
|
|
28
|
+
for (const pathToModule of Object.keys(require.cache)) {
|
|
29
|
+
const { pkg } = extractPackageAndModulePath(pathToModule)
|
|
30
|
+
|
|
31
|
+
if (naughties.has(pkg)) continue
|
|
32
|
+
if (!(pkg in packages)) continue
|
|
33
|
+
|
|
34
|
+
console.error(`Warning: Package '${pkg}' was loaded before dd-trace! This may break instrumentation.`)
|
|
35
|
+
|
|
36
|
+
naughties.add(pkg)
|
|
37
|
+
didWarn = true
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (didWarn) console.error('Warning: Please ensure dd-trace is loaded before other modules.')
|
|
41
|
+
}
|
|
@@ -57,7 +57,6 @@ module.exports = {
|
|
|
57
57
|
'jest-config': () => require('../jest'),
|
|
58
58
|
'jest-environment-node': () => require('../jest'),
|
|
59
59
|
'jest-environment-jsdom': () => require('../jest'),
|
|
60
|
-
'jest-jasmine2': () => require('../jest'),
|
|
61
60
|
'jest-runtime': () => require('../jest'),
|
|
62
61
|
'jest-worker': () => require('../jest'),
|
|
63
62
|
knex: () => require('../knex'),
|
|
@@ -6,8 +6,12 @@ const semver = require('semver')
|
|
|
6
6
|
const Hook = require('./hook')
|
|
7
7
|
const requirePackageJson = require('../../../dd-trace/src/require-package-json')
|
|
8
8
|
const log = require('../../../dd-trace/src/log')
|
|
9
|
+
const checkRequireCache = require('../check_require_cache')
|
|
9
10
|
|
|
10
|
-
const {
|
|
11
|
+
const {
|
|
12
|
+
DD_TRACE_DISABLED_INSTRUMENTATIONS = '',
|
|
13
|
+
DD_TRACE_DEBUG = ''
|
|
14
|
+
} = process.env
|
|
11
15
|
|
|
12
16
|
const hooks = require('./hooks')
|
|
13
17
|
const instrumentations = require('./instrumentations')
|
|
@@ -27,6 +31,8 @@ if (!disabledInstrumentations.has('fetch')) {
|
|
|
27
31
|
const HOOK_SYMBOL = Symbol('hookExportsMap')
|
|
28
32
|
// TODO: make this more efficient
|
|
29
33
|
|
|
34
|
+
if (DD_TRACE_DEBUG && DD_TRACE_DEBUG.toLowerCase() !== 'false') checkRequireCache()
|
|
35
|
+
|
|
30
36
|
for (const packageName of names) {
|
|
31
37
|
if (disabledInstrumentations.has(packageName)) continue
|
|
32
38
|
|
|
@@ -19,7 +19,6 @@ const {
|
|
|
19
19
|
getJestTestName,
|
|
20
20
|
getJestSuitesToRun
|
|
21
21
|
} = require('../../datadog-plugin-jest/src/util')
|
|
22
|
-
const { DD_MAJOR } = require('../../../version')
|
|
23
22
|
|
|
24
23
|
const testSessionStartCh = channel('ci:jest:session:start')
|
|
25
24
|
const testSessionFinishCh = channel('ci:jest:session:finish')
|
|
@@ -68,14 +67,6 @@ let hasFilteredSkippableSuites = false
|
|
|
68
67
|
|
|
69
68
|
const sessionAsyncResource = new AsyncResource('bound-anonymous-fn')
|
|
70
69
|
|
|
71
|
-
const specStatusToTestStatus = {
|
|
72
|
-
pending: 'skip',
|
|
73
|
-
disabled: 'skip',
|
|
74
|
-
todo: 'skip',
|
|
75
|
-
passed: 'pass',
|
|
76
|
-
failed: 'fail'
|
|
77
|
-
}
|
|
78
|
-
|
|
79
70
|
const asyncResources = new WeakMap()
|
|
80
71
|
const originalTestFns = new WeakMap()
|
|
81
72
|
const retriedTestsToNumAttempts = new Map()
|
|
@@ -837,45 +828,6 @@ addHook({
|
|
|
837
828
|
versions: ['24.8.0 - 24.9.0']
|
|
838
829
|
}, jestConfigSyncWrapper)
|
|
839
830
|
|
|
840
|
-
function jasmineAsyncInstallWraper (jasmineAsyncInstallExport, jestVersion) {
|
|
841
|
-
log.warn('jest-jasmine2 support is removed from dd-trace@v4. Consider changing to jest-circus as `testRunner`.')
|
|
842
|
-
return function (globalConfig, globalInput) {
|
|
843
|
-
globalInput._ddtrace = global._ddtrace
|
|
844
|
-
shimmer.wrap(globalInput.jasmine.Spec.prototype, 'execute', execute => function (onComplete) {
|
|
845
|
-
const asyncResource = new AsyncResource('bound-anonymous-fn')
|
|
846
|
-
asyncResource.runInAsyncScope(() => {
|
|
847
|
-
const testSuite = getTestSuitePath(this.result.testPath, globalConfig.rootDir)
|
|
848
|
-
testStartCh.publish({
|
|
849
|
-
name: this.getFullName(),
|
|
850
|
-
suite: testSuite,
|
|
851
|
-
runner: 'jest-jasmine2',
|
|
852
|
-
frameworkVersion: jestVersion
|
|
853
|
-
})
|
|
854
|
-
const spec = this
|
|
855
|
-
const callback = asyncResource.bind(function () {
|
|
856
|
-
if (spec.result.failedExpectations && spec.result.failedExpectations.length) {
|
|
857
|
-
const formattedError = formatJestError(spec.result.failedExpectations[0].error)
|
|
858
|
-
testErrCh.publish(formattedError)
|
|
859
|
-
}
|
|
860
|
-
testRunFinishCh.publish({ status: specStatusToTestStatus[spec.result.status] })
|
|
861
|
-
onComplete.apply(this, arguments)
|
|
862
|
-
})
|
|
863
|
-
arguments[0] = callback
|
|
864
|
-
execute.apply(this, arguments)
|
|
865
|
-
})
|
|
866
|
-
})
|
|
867
|
-
return jasmineAsyncInstallExport.default(globalConfig, globalInput)
|
|
868
|
-
}
|
|
869
|
-
}
|
|
870
|
-
|
|
871
|
-
if (DD_MAJOR < 4) {
|
|
872
|
-
addHook({
|
|
873
|
-
name: 'jest-jasmine2',
|
|
874
|
-
versions: ['>=24.8.0'],
|
|
875
|
-
file: 'build/jasmineAsyncInstall.js'
|
|
876
|
-
}, jasmineAsyncInstallWraper)
|
|
877
|
-
}
|
|
878
|
-
|
|
879
831
|
const LIBRARIES_BYPASSING_JEST_REQUIRE_ENGINE = [
|
|
880
832
|
'selenium-webdriver'
|
|
881
833
|
]
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const NM = 'node_modules/'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* For a given full path to a module,
|
|
7
|
+
* return the package name it belongs to and the local path to the module
|
|
8
|
+
* input: '/foo/node_modules/@co/stuff/foo/bar/baz.js'
|
|
9
|
+
* output: { pkg: '@co/stuff', path: 'foo/bar/baz.js' }
|
|
10
|
+
*/
|
|
11
|
+
module.exports = function extractPackageAndModulePath (fullPath) {
|
|
12
|
+
const nm = fullPath.lastIndexOf(NM)
|
|
13
|
+
if (nm < 0) {
|
|
14
|
+
return { pkg: null, path: null }
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const subPath = fullPath.substring(nm + NM.length)
|
|
18
|
+
const firstSlash = subPath.indexOf('/')
|
|
19
|
+
|
|
20
|
+
if (subPath[0] === '@') {
|
|
21
|
+
const secondSlash = subPath.substring(firstSlash + 1).indexOf('/')
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
pkg: subPath.substring(0, firstSlash + 1 + secondSlash),
|
|
25
|
+
path: subPath.substring(firstSlash + 1 + secondSlash + 1)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
pkg: subPath.substring(0, firstSlash),
|
|
31
|
+
path: subPath.substring(firstSlash + 1)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -44,7 +44,6 @@ module.exports = {
|
|
|
44
44
|
get 'jest-config' () { return require('../../../datadog-plugin-jest/src') },
|
|
45
45
|
get 'jest-environment-node' () { return require('../../../datadog-plugin-jest/src') },
|
|
46
46
|
get 'jest-environment-jsdom' () { return require('../../../datadog-plugin-jest/src') },
|
|
47
|
-
get 'jest-jasmine2' () { return require('../../../datadog-plugin-jest/src') },
|
|
48
47
|
get 'jest-runtime' () { return require('../../../datadog-plugin-jest/src') },
|
|
49
48
|
get 'jest-worker' () { return require('../../../datadog-plugin-jest/src') },
|
|
50
49
|
get koa () { return require('../../../datadog-plugin-koa/src') },
|