dd-trace 3.13.0 → 3.13.2
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-instrumentations/src/fs.js +28 -27
- package/packages/datadog-instrumentations/src/mocha.js +6 -1
- package/packages/datadog-plugin-jest/src/index.js +8 -11
- package/packages/datadog-plugin-mocha/src/index.js +9 -8
- package/packages/dd-trace/src/exporters/common/request.js +10 -3
- package/packages/dd-trace/src/log/writer.js +12 -4
- package/packages/dd-trace/src/plugins/util/test.js +26 -0
- package/packages/dd-trace/src/telemetry/index.js +23 -2
package/package.json
CHANGED
|
@@ -85,36 +85,37 @@ const paramsByFileHandleMethods = {
|
|
|
85
85
|
writeFile: ['data', 'options'],
|
|
86
86
|
writev: ['buffers', 'position']
|
|
87
87
|
}
|
|
88
|
+
const names = ['fs', 'node:fs']
|
|
89
|
+
names.forEach(name => {
|
|
90
|
+
addHook({ name }, fs => {
|
|
91
|
+
const asyncMethods = Object.keys(paramsByMethod)
|
|
92
|
+
const syncMethods = asyncMethods.map(name => `${name}Sync`)
|
|
93
|
+
|
|
94
|
+
massWrap(fs, asyncMethods, createWrapFunction())
|
|
95
|
+
massWrap(fs, syncMethods, createWrapFunction())
|
|
96
|
+
massWrap(fs.promises, asyncMethods, createWrapFunction('promises.'))
|
|
97
|
+
|
|
98
|
+
wrap(fs.realpath, 'native', createWrapFunction('', 'realpath.native'))
|
|
99
|
+
wrap(fs.realpathSync, 'native', createWrapFunction('', 'realpath.native'))
|
|
100
|
+
wrap(fs.promises.realpath, 'native', createWrapFunction('', 'realpath.native'))
|
|
101
|
+
|
|
102
|
+
wrap(fs, 'createReadStream', wrapCreateStream)
|
|
103
|
+
wrap(fs, 'createWriteStream', wrapCreateStream)
|
|
104
|
+
if (fs.Dir) {
|
|
105
|
+
wrap(fs.Dir.prototype, 'close', createWrapFunction('dir.'))
|
|
106
|
+
wrap(fs.Dir.prototype, 'closeSync', createWrapFunction('dir.'))
|
|
107
|
+
wrap(fs.Dir.prototype, 'read', createWrapFunction('dir.'))
|
|
108
|
+
wrap(fs.Dir.prototype, 'readSync', createWrapFunction('dir.'))
|
|
109
|
+
wrap(fs.Dir.prototype, Symbol.asyncIterator, createWrapDirAsyncIterator())
|
|
110
|
+
}
|
|
88
111
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
massWrap(fs, asyncMethods, createWrapFunction())
|
|
94
|
-
massWrap(fs, syncMethods, createWrapFunction())
|
|
95
|
-
massWrap(fs.promises, asyncMethods, createWrapFunction('promises.'))
|
|
96
|
-
|
|
97
|
-
wrap(fs.realpath, 'native', createWrapFunction('', 'realpath.native'))
|
|
98
|
-
wrap(fs.realpathSync, 'native', createWrapFunction('', 'realpath.native'))
|
|
99
|
-
wrap(fs.promises.realpath, 'native', createWrapFunction('', 'realpath.native'))
|
|
100
|
-
|
|
101
|
-
wrap(fs, 'createReadStream', wrapCreateStream)
|
|
102
|
-
wrap(fs, 'createWriteStream', wrapCreateStream)
|
|
103
|
-
if (fs.Dir) {
|
|
104
|
-
wrap(fs.Dir.prototype, 'close', createWrapFunction('dir.'))
|
|
105
|
-
wrap(fs.Dir.prototype, 'closeSync', createWrapFunction('dir.'))
|
|
106
|
-
wrap(fs.Dir.prototype, 'read', createWrapFunction('dir.'))
|
|
107
|
-
wrap(fs.Dir.prototype, 'readSync', createWrapFunction('dir.'))
|
|
108
|
-
wrap(fs.Dir.prototype, Symbol.asyncIterator, createWrapDirAsyncIterator())
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
wrap(fs, 'unwatchFile', createWatchWrapFunction())
|
|
112
|
-
wrap(fs, 'watch', createWatchWrapFunction())
|
|
113
|
-
wrap(fs, 'watchFile', createWatchWrapFunction())
|
|
112
|
+
wrap(fs, 'unwatchFile', createWatchWrapFunction())
|
|
113
|
+
wrap(fs, 'watch', createWatchWrapFunction())
|
|
114
|
+
wrap(fs, 'watchFile', createWatchWrapFunction())
|
|
114
115
|
|
|
115
|
-
|
|
116
|
+
return fs
|
|
117
|
+
})
|
|
116
118
|
})
|
|
117
|
-
|
|
118
119
|
function isFirstMethodReturningFileHandle (original) {
|
|
119
120
|
return !kHandle && original.name === 'open'
|
|
120
121
|
}
|
|
@@ -418,8 +418,13 @@ addHook({
|
|
|
418
418
|
|
|
419
419
|
// we store the original function, not to lose it
|
|
420
420
|
originalFns.set(newFn, this.fn)
|
|
421
|
-
|
|
422
421
|
this.fn = newFn
|
|
422
|
+
|
|
423
|
+
// Temporarily keep functionality when .asyncResource is removed from node
|
|
424
|
+
// in https://github.com/nodejs/node/pull/46432
|
|
425
|
+
if (!this.fn.asyncResource) {
|
|
426
|
+
this.fn.asyncResource = asyncResource
|
|
427
|
+
}
|
|
423
428
|
}
|
|
424
429
|
}
|
|
425
430
|
|
|
@@ -10,16 +10,13 @@ const {
|
|
|
10
10
|
getTestSessionCommonTags,
|
|
11
11
|
getTestModuleCommonTags,
|
|
12
12
|
getTestSuiteCommonTags,
|
|
13
|
+
addIntelligentTestRunnerSpanTags,
|
|
13
14
|
TEST_PARAMETERS,
|
|
14
15
|
getCodeOwnersFileEntries,
|
|
15
16
|
TEST_SESSION_ID,
|
|
16
17
|
TEST_MODULE_ID,
|
|
17
18
|
TEST_SUITE_ID,
|
|
18
19
|
TEST_COMMAND,
|
|
19
|
-
TEST_ITR_TESTS_SKIPPED,
|
|
20
|
-
TEST_SESSION_CODE_COVERAGE_ENABLED,
|
|
21
|
-
TEST_SESSION_ITR_SKIPPING_ENABLED,
|
|
22
|
-
TEST_CODE_COVERAGE_LINES_TOTAL,
|
|
23
20
|
TEST_BUNDLE
|
|
24
21
|
} = require('../../dd-trace/src/plugins/util/test')
|
|
25
22
|
const { COMPONENT } = require('../../dd-trace/src/constants')
|
|
@@ -83,14 +80,14 @@ class JestPlugin extends CiPlugin {
|
|
|
83
80
|
testCodeCoverageLinesTotal
|
|
84
81
|
}) => {
|
|
85
82
|
this.testSessionSpan.setTag(TEST_STATUS, status)
|
|
86
|
-
this.testSessionSpan.setTag(TEST_ITR_TESTS_SKIPPED, isSuitesSkipped ? 'true' : 'false')
|
|
87
|
-
this.testSessionSpan.setTag(TEST_SESSION_ITR_SKIPPING_ENABLED, isSuitesSkippingEnabled ? 'true' : 'false')
|
|
88
|
-
this.testSessionSpan.setTag(TEST_SESSION_CODE_COVERAGE_ENABLED, isCodeCoverageEnabled ? 'true' : 'false')
|
|
89
|
-
|
|
90
|
-
if (testCodeCoverageLinesTotal !== undefined) {
|
|
91
|
-
this.testSessionSpan.setTag(TEST_CODE_COVERAGE_LINES_TOTAL, testCodeCoverageLinesTotal)
|
|
92
|
-
}
|
|
93
83
|
this.testModuleSpan.setTag(TEST_STATUS, status)
|
|
84
|
+
|
|
85
|
+
addIntelligentTestRunnerSpanTags(
|
|
86
|
+
this.testSessionSpan,
|
|
87
|
+
this.testModuleSpan,
|
|
88
|
+
{ isSuitesSkipped, isSuitesSkippingEnabled, isCodeCoverageEnabled, testCodeCoverageLinesTotal }
|
|
89
|
+
)
|
|
90
|
+
|
|
94
91
|
this.testModuleSpan.finish()
|
|
95
92
|
this.testSessionSpan.finish()
|
|
96
93
|
finishAllTraceSpans(this.testSessionSpan)
|
|
@@ -13,14 +13,12 @@ const {
|
|
|
13
13
|
getTestSessionCommonTags,
|
|
14
14
|
getTestModuleCommonTags,
|
|
15
15
|
getTestSuiteCommonTags,
|
|
16
|
+
addIntelligentTestRunnerSpanTags,
|
|
16
17
|
TEST_SUITE_ID,
|
|
17
18
|
TEST_SESSION_ID,
|
|
18
19
|
TEST_MODULE_ID,
|
|
19
20
|
TEST_BUNDLE,
|
|
20
|
-
TEST_COMMAND
|
|
21
|
-
TEST_ITR_TESTS_SKIPPED,
|
|
22
|
-
TEST_SESSION_CODE_COVERAGE_ENABLED,
|
|
23
|
-
TEST_SESSION_ITR_SKIPPING_ENABLED
|
|
21
|
+
TEST_COMMAND
|
|
24
22
|
} = require('../../dd-trace/src/plugins/util/test')
|
|
25
23
|
const { COMPONENT } = require('../../dd-trace/src/constants')
|
|
26
24
|
|
|
@@ -156,11 +154,14 @@ class MochaPlugin extends CiPlugin {
|
|
|
156
154
|
if (this.testSessionSpan) {
|
|
157
155
|
const { isSuitesSkippingEnabled, isCodeCoverageEnabled } = this.itrConfig || {}
|
|
158
156
|
this.testSessionSpan.setTag(TEST_STATUS, status)
|
|
159
|
-
this.testSessionSpan.setTag(TEST_ITR_TESTS_SKIPPED, isSuitesSkipped ? 'true' : 'false')
|
|
160
|
-
this.testSessionSpan.setTag(TEST_SESSION_ITR_SKIPPING_ENABLED, isSuitesSkippingEnabled ? 'true' : 'false')
|
|
161
|
-
this.testSessionSpan.setTag(TEST_SESSION_CODE_COVERAGE_ENABLED, isCodeCoverageEnabled ? 'true' : 'false')
|
|
162
|
-
|
|
163
157
|
this.testModuleSpan.setTag(TEST_STATUS, status)
|
|
158
|
+
|
|
159
|
+
addIntelligentTestRunnerSpanTags(
|
|
160
|
+
this.testSessionSpan,
|
|
161
|
+
this.testModuleSpan,
|
|
162
|
+
{ isSuitesSkipped, isSuitesSkippingEnabled, isCodeCoverageEnabled }
|
|
163
|
+
)
|
|
164
|
+
|
|
164
165
|
this.testModuleSpan.finish()
|
|
165
166
|
this.testSessionSpan.finish()
|
|
166
167
|
finishAllTraceSpans(this.testSessionSpan)
|
|
@@ -98,9 +98,16 @@ function request (data, options, callback) {
|
|
|
98
98
|
if (res.statusCode >= 200 && res.statusCode <= 299) {
|
|
99
99
|
callback(null, responseData, res.statusCode)
|
|
100
100
|
} else {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
let errorMessage = ''
|
|
102
|
+
try {
|
|
103
|
+
const fullUrl = new URL(
|
|
104
|
+
options.path,
|
|
105
|
+
options.url || options.hostname || `http://localhost:${options.port}`
|
|
106
|
+
).href
|
|
107
|
+
errorMessage = `Error from ${fullUrl}: ${res.statusCode} ${http.STATUS_CODES[res.statusCode]}.`
|
|
108
|
+
} catch (e) {
|
|
109
|
+
// ignore error
|
|
110
|
+
}
|
|
104
111
|
if (responseData) {
|
|
105
112
|
errorMessage += ` Response from the endpoint: "${responseData}"`
|
|
106
113
|
}
|
|
@@ -23,10 +23,18 @@ function withNoop (fn) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
function unsubscribeAll () {
|
|
26
|
-
debugChannel.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
if (debugChannel.hasSubscribers) {
|
|
27
|
+
debugChannel.unsubscribe(onDebug)
|
|
28
|
+
}
|
|
29
|
+
if (infoChannel.hasSubscribers) {
|
|
30
|
+
infoChannel.unsubscribe(onInfo)
|
|
31
|
+
}
|
|
32
|
+
if (warnChannel.hasSubscribers) {
|
|
33
|
+
warnChannel.unsubscribe(onWarn)
|
|
34
|
+
}
|
|
35
|
+
if (errorChannel.hasSubscribers) {
|
|
36
|
+
errorChannel.unsubscribe(onError)
|
|
37
|
+
}
|
|
30
38
|
}
|
|
31
39
|
|
|
32
40
|
function toggleSubscription (enable) {
|
|
@@ -50,6 +50,8 @@ const JEST_TEST_RUNNER = 'test.jest.test_runner'
|
|
|
50
50
|
const TEST_ITR_TESTS_SKIPPED = '_dd.ci.itr.tests_skipped'
|
|
51
51
|
const TEST_SESSION_ITR_SKIPPING_ENABLED = 'test_session.itr.tests_skipping.enabled'
|
|
52
52
|
const TEST_SESSION_CODE_COVERAGE_ENABLED = 'test_session.code_coverage.enabled'
|
|
53
|
+
const TEST_MODULE_ITR_SKIPPING_ENABLED = 'test_module.itr.tests_skipping.enabled'
|
|
54
|
+
const TEST_MODULE_CODE_COVERAGE_ENABLED = 'test_module.code_coverage.enabled'
|
|
53
55
|
|
|
54
56
|
const TEST_CODE_COVERAGE_LINES_TOTAL = 'test.codecov_lines_total'
|
|
55
57
|
|
|
@@ -84,9 +86,13 @@ module.exports = {
|
|
|
84
86
|
TEST_MODULE_ID,
|
|
85
87
|
TEST_SUITE_ID,
|
|
86
88
|
TEST_ITR_TESTS_SKIPPED,
|
|
89
|
+
TEST_BUNDLE,
|
|
87
90
|
TEST_SESSION_ITR_SKIPPING_ENABLED,
|
|
88
91
|
TEST_SESSION_CODE_COVERAGE_ENABLED,
|
|
92
|
+
TEST_MODULE_ITR_SKIPPING_ENABLED,
|
|
93
|
+
TEST_MODULE_CODE_COVERAGE_ENABLED,
|
|
89
94
|
TEST_CODE_COVERAGE_LINES_TOTAL,
|
|
95
|
+
addIntelligentTestRunnerSpanTags,
|
|
90
96
|
getCoveredFilenamesFromCoverage,
|
|
91
97
|
resetCoverage,
|
|
92
98
|
mergeCoverage,
|
|
@@ -282,6 +288,26 @@ function getTestSuiteCommonTags (command, testFrameworkVersion, testSuite) {
|
|
|
282
288
|
}
|
|
283
289
|
}
|
|
284
290
|
|
|
291
|
+
function addIntelligentTestRunnerSpanTags (
|
|
292
|
+
testSessionSpan,
|
|
293
|
+
testModuleSpan,
|
|
294
|
+
{ isSuitesSkipped, isSuitesSkippingEnabled, isCodeCoverageEnabled, testCodeCoverageLinesTotal }
|
|
295
|
+
) {
|
|
296
|
+
testSessionSpan.setTag(TEST_ITR_TESTS_SKIPPED, isSuitesSkipped ? 'true' : 'false')
|
|
297
|
+
testSessionSpan.setTag(TEST_SESSION_ITR_SKIPPING_ENABLED, isSuitesSkippingEnabled ? 'true' : 'false')
|
|
298
|
+
testSessionSpan.setTag(TEST_SESSION_CODE_COVERAGE_ENABLED, isCodeCoverageEnabled ? 'true' : 'false')
|
|
299
|
+
|
|
300
|
+
testModuleSpan.setTag(TEST_ITR_TESTS_SKIPPED, isSuitesSkipped ? 'true' : 'false')
|
|
301
|
+
testModuleSpan.setTag(TEST_MODULE_ITR_SKIPPING_ENABLED, isSuitesSkippingEnabled ? 'true' : 'false')
|
|
302
|
+
testModuleSpan.setTag(TEST_MODULE_CODE_COVERAGE_ENABLED, isCodeCoverageEnabled ? 'true' : 'false')
|
|
303
|
+
|
|
304
|
+
// If suites have been skipped we don't want to report the total coverage, as it will be wrong
|
|
305
|
+
if (testCodeCoverageLinesTotal !== undefined && !isSuitesSkipped) {
|
|
306
|
+
testSessionSpan.setTag(TEST_CODE_COVERAGE_LINES_TOTAL, testCodeCoverageLinesTotal)
|
|
307
|
+
testModuleSpan.setTag(TEST_CODE_COVERAGE_LINES_TOTAL, testCodeCoverageLinesTotal)
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
285
311
|
function getCoveredFilenamesFromCoverage (coverage) {
|
|
286
312
|
const coverageMap = istanbul.createCoverageMap(coverage)
|
|
287
313
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const tracerVersion = require('../../../../package.json').version
|
|
4
|
-
const containerId = require('../exporters/common/docker').id()
|
|
5
4
|
const os = require('os')
|
|
6
5
|
const dependencies = require('./dependencies')
|
|
7
6
|
const { sendData } = require('./send-data')
|
|
@@ -76,9 +75,31 @@ function createAppObject () {
|
|
|
76
75
|
}
|
|
77
76
|
|
|
78
77
|
function createHostObject () {
|
|
78
|
+
const osName = os.type()
|
|
79
|
+
|
|
80
|
+
if (osName === 'Linux' || osName === 'Darwin') {
|
|
81
|
+
return {
|
|
82
|
+
hostname: os.hostname(),
|
|
83
|
+
os: osName,
|
|
84
|
+
architecture: os.arch(),
|
|
85
|
+
kernel_version: os.version(),
|
|
86
|
+
kernel_release: os.release(),
|
|
87
|
+
kernel_name: osName
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (osName === 'Windows_NT') {
|
|
92
|
+
return {
|
|
93
|
+
hostname: os.hostname(),
|
|
94
|
+
os: osName,
|
|
95
|
+
architecture: os.arch(),
|
|
96
|
+
os_version: os.version()
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
79
100
|
return {
|
|
80
101
|
hostname: os.hostname(), // TODO is this enough?
|
|
81
|
-
|
|
102
|
+
os: osName
|
|
82
103
|
}
|
|
83
104
|
}
|
|
84
105
|
|