dd-trace 6.0.0-pre-8ec0cfe → 6.0.0-pre-7561fb5
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/ci/init.js +0 -4
- package/package.json +1 -1
- package/packages/datadog-instrumentations/src/cucumber.js +10 -10
- package/packages/datadog-instrumentations/src/jest.js +3 -0
- package/packages/datadog-plugin-cucumber/src/index.js +12 -7
- package/packages/datadog-plugin-cypress/src/plugin.js +12 -1
- package/packages/datadog-plugin-jest/src/index.js +20 -1
- package/packages/datadog-plugin-mocha/src/index.js +10 -1
- package/packages/datadog-plugin-playwright/src/index.js +14 -4
- package/packages/dd-trace/src/config.js +7 -0
- package/packages/dd-trace/src/plugins/ci_plugin.js +2 -0
- package/packages/dd-trace/src/plugins/util/test.js +0 -1
package/ci/init.js
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
const tracer = require('../packages/dd-trace')
|
|
3
|
-
const { ORIGIN_KEY } = require('../packages/dd-trace/src/constants')
|
|
4
3
|
const { isTrue } = require('../packages/dd-trace/src/util')
|
|
5
4
|
|
|
6
5
|
const isJestWorker = !!process.env.JEST_WORKER_ID
|
|
7
6
|
|
|
8
7
|
const options = {
|
|
9
8
|
startupLogs: false,
|
|
10
|
-
tags: {
|
|
11
|
-
[ORIGIN_KEY]: 'ciapp-test'
|
|
12
|
-
},
|
|
13
9
|
isCiVisibility: true,
|
|
14
10
|
flushInterval: isJestWorker ? 0 : 5000
|
|
15
11
|
}
|
package/package.json
CHANGED
|
@@ -96,11 +96,11 @@ function wrapRun (pl, isLatestVersion) {
|
|
|
96
96
|
|
|
97
97
|
const asyncResource = new AsyncResource('bound-anonymous-fn')
|
|
98
98
|
return asyncResource.runInAsyncScope(() => {
|
|
99
|
-
const
|
|
99
|
+
const testFileAbsolutePath = this.pickle.uri
|
|
100
100
|
|
|
101
|
-
if (!pickleResultByFile[
|
|
101
|
+
if (!pickleResultByFile[testFileAbsolutePath]) { // first test in suite
|
|
102
102
|
isUnskippable = isMarkedAsUnskippable(this.pickle)
|
|
103
|
-
const testSuitePath = getTestSuitePath(
|
|
103
|
+
const testSuitePath = getTestSuitePath(testFileAbsolutePath, process.cwd())
|
|
104
104
|
isForcedToRun = isUnskippable && skippableSuites.includes(testSuitePath)
|
|
105
105
|
|
|
106
106
|
testSuiteStartCh.publish({ testSuitePath, isUnskippable, isForcedToRun, itrCorrelationId })
|
|
@@ -113,7 +113,7 @@ function wrapRun (pl, isLatestVersion) {
|
|
|
113
113
|
|
|
114
114
|
testStartCh.publish({
|
|
115
115
|
testName: this.pickle.name,
|
|
116
|
-
|
|
116
|
+
testFileAbsolutePath,
|
|
117
117
|
testSourceLine
|
|
118
118
|
})
|
|
119
119
|
try {
|
|
@@ -123,21 +123,21 @@ function wrapRun (pl, isLatestVersion) {
|
|
|
123
123
|
const { status, skipReason, errorMessage } = isLatestVersion
|
|
124
124
|
? getStatusFromResultLatest(result) : getStatusFromResult(result)
|
|
125
125
|
|
|
126
|
-
if (!pickleResultByFile[
|
|
127
|
-
pickleResultByFile[
|
|
126
|
+
if (!pickleResultByFile[testFileAbsolutePath]) {
|
|
127
|
+
pickleResultByFile[testFileAbsolutePath] = [status]
|
|
128
128
|
} else {
|
|
129
|
-
pickleResultByFile[
|
|
129
|
+
pickleResultByFile[testFileAbsolutePath].push(status)
|
|
130
130
|
}
|
|
131
131
|
testFinishCh.publish({ status, skipReason, errorMessage })
|
|
132
132
|
// last test in suite
|
|
133
|
-
if (pickleResultByFile[
|
|
134
|
-
const testSuiteStatus = getSuiteStatusFromTestStatuses(pickleResultByFile[
|
|
133
|
+
if (pickleResultByFile[testFileAbsolutePath].length === pickleByFile[testFileAbsolutePath].length) {
|
|
134
|
+
const testSuiteStatus = getSuiteStatusFromTestStatuses(pickleResultByFile[testFileAbsolutePath])
|
|
135
135
|
if (global.__coverage__) {
|
|
136
136
|
const coverageFiles = getCoveredFilenamesFromCoverage(global.__coverage__)
|
|
137
137
|
|
|
138
138
|
testSuiteCodeCoverageCh.publish({
|
|
139
139
|
coverageFiles,
|
|
140
|
-
suiteFile:
|
|
140
|
+
suiteFile: testFileAbsolutePath
|
|
141
141
|
})
|
|
142
142
|
// We need to reset coverage to get a code coverage per suite
|
|
143
143
|
// Before that, we preserve the original coverage
|
|
@@ -113,6 +113,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
|
|
|
113
113
|
const rootDir = config.globalConfig ? config.globalConfig.rootDir : config.rootDir
|
|
114
114
|
this.rootDir = rootDir
|
|
115
115
|
this.testSuite = getTestSuitePath(context.testPath, rootDir)
|
|
116
|
+
this.testFileAbsolutePath = context.testPath
|
|
116
117
|
this.nameToParams = {}
|
|
117
118
|
this.global._ddtrace = global._ddtrace
|
|
118
119
|
|
|
@@ -194,6 +195,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
|
|
|
194
195
|
testStartCh.publish({
|
|
195
196
|
name: removeEfdTestName(testName),
|
|
196
197
|
suite: this.testSuite,
|
|
198
|
+
testFileAbsolutePath: this.testFileAbsolutePath,
|
|
197
199
|
runner: 'jest-circus',
|
|
198
200
|
testParameters,
|
|
199
201
|
frameworkVersion: jestVersion,
|
|
@@ -244,6 +246,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
|
|
|
244
246
|
testSkippedCh.publish({
|
|
245
247
|
name: getJestTestName(event.test),
|
|
246
248
|
suite: this.testSuite,
|
|
249
|
+
testFileAbsolutePath: this.testFileAbsolutePath,
|
|
247
250
|
runner: 'jest-circus',
|
|
248
251
|
frameworkVersion: jestVersion,
|
|
249
252
|
testStartLine: getTestLineStart(event.test.asyncError, this.testSuite)
|
|
@@ -14,7 +14,8 @@ const {
|
|
|
14
14
|
TEST_ITR_UNSKIPPABLE,
|
|
15
15
|
TEST_ITR_FORCED_RUN,
|
|
16
16
|
TEST_CODE_OWNERS,
|
|
17
|
-
ITR_CORRELATION_ID
|
|
17
|
+
ITR_CORRELATION_ID,
|
|
18
|
+
TEST_SOURCE_FILE
|
|
18
19
|
} = require('../../dd-trace/src/plugins/util/test')
|
|
19
20
|
const { RESOURCE_NAME } = require('../../../ext/tags')
|
|
20
21
|
const { COMPONENT, ERROR_MESSAGE } = require('../../dd-trace/src/constants')
|
|
@@ -122,7 +123,7 @@ class CucumberPlugin extends CiPlugin {
|
|
|
122
123
|
}
|
|
123
124
|
|
|
124
125
|
const relativeCoverageFiles = [...coverageFiles, suiteFile]
|
|
125
|
-
.map(filename => getTestSuitePath(filename, this.
|
|
126
|
+
.map(filename => getTestSuitePath(filename, this.repositoryRoot))
|
|
126
127
|
|
|
127
128
|
this.telemetry.distribution(TELEMETRY_CODE_COVERAGE_NUM_FILES, {}, relativeCoverageFiles.length)
|
|
128
129
|
|
|
@@ -136,10 +137,11 @@ class CucumberPlugin extends CiPlugin {
|
|
|
136
137
|
this.telemetry.ciVisEvent(TELEMETRY_CODE_COVERAGE_FINISHED, 'suite', { library: 'istanbul' })
|
|
137
138
|
})
|
|
138
139
|
|
|
139
|
-
this.addSub('ci:cucumber:test:start', ({ testName,
|
|
140
|
+
this.addSub('ci:cucumber:test:start', ({ testName, testFileAbsolutePath, testSourceLine }) => {
|
|
140
141
|
const store = storage.getStore()
|
|
141
|
-
const testSuite = getTestSuitePath(
|
|
142
|
-
const
|
|
142
|
+
const testSuite = getTestSuitePath(testFileAbsolutePath, this.sourceRoot)
|
|
143
|
+
const testSourceFile = getTestSuitePath(testFileAbsolutePath, this.repositoryRoot)
|
|
144
|
+
const testSpan = this.startTestSpan(testName, testSuite, testSourceFile, testSourceLine)
|
|
143
145
|
|
|
144
146
|
this.enter(testSpan, store)
|
|
145
147
|
})
|
|
@@ -191,12 +193,15 @@ class CucumberPlugin extends CiPlugin {
|
|
|
191
193
|
})
|
|
192
194
|
}
|
|
193
195
|
|
|
194
|
-
startTestSpan (testName, testSuite, testSourceLine) {
|
|
196
|
+
startTestSpan (testName, testSuite, testSourceFile, testSourceLine) {
|
|
195
197
|
return super.startTestSpan(
|
|
196
198
|
testName,
|
|
197
199
|
testSuite,
|
|
198
200
|
this.testSuiteSpan,
|
|
199
|
-
{
|
|
201
|
+
{
|
|
202
|
+
[TEST_SOURCE_START]: testSourceLine,
|
|
203
|
+
[TEST_SOURCE_FILE]: testSourceFile
|
|
204
|
+
}
|
|
200
205
|
)
|
|
201
206
|
}
|
|
202
207
|
}
|
|
@@ -24,7 +24,8 @@ const {
|
|
|
24
24
|
TEST_SKIPPED_BY_ITR,
|
|
25
25
|
TEST_ITR_UNSKIPPABLE,
|
|
26
26
|
TEST_ITR_FORCED_RUN,
|
|
27
|
-
ITR_CORRELATION_ID
|
|
27
|
+
ITR_CORRELATION_ID,
|
|
28
|
+
TEST_SOURCE_FILE
|
|
28
29
|
} = require('../../dd-trace/src/plugins/util/test')
|
|
29
30
|
const { ORIGIN_KEY, COMPONENT } = require('../../dd-trace/src/constants')
|
|
30
31
|
const log = require('../../dd-trace/src/log')
|
|
@@ -361,6 +362,11 @@ module.exports = (on, config) => {
|
|
|
361
362
|
cypressTestName === test.name && spec.relative === test.suite
|
|
362
363
|
)
|
|
363
364
|
const skippedTestSpan = getTestSpan(cypressTestName, spec.relative)
|
|
365
|
+
if (spec.absolute && repositoryRoot) {
|
|
366
|
+
skippedTestSpan.setTag(TEST_SOURCE_FILE, getTestSuitePath(spec.absolute, repositoryRoot))
|
|
367
|
+
} else {
|
|
368
|
+
skippedTestSpan.setTag(TEST_SOURCE_FILE, spec.relative)
|
|
369
|
+
}
|
|
364
370
|
skippedTestSpan.setTag(TEST_STATUS, 'skip')
|
|
365
371
|
if (isSkippedByItr) {
|
|
366
372
|
skippedTestSpan.setTag(TEST_SKIPPED_BY_ITR, 'true')
|
|
@@ -392,6 +398,11 @@ module.exports = (on, config) => {
|
|
|
392
398
|
if (itrCorrelationId) {
|
|
393
399
|
finishedTest.testSpan.setTag(ITR_CORRELATION_ID, itrCorrelationId)
|
|
394
400
|
}
|
|
401
|
+
if (spec.absolute && repositoryRoot) {
|
|
402
|
+
finishedTest.testSpan.setTag(TEST_SOURCE_FILE, getTestSuitePath(spec.absolute, repositoryRoot))
|
|
403
|
+
} else {
|
|
404
|
+
finishedTest.testSpan.setTag(TEST_SOURCE_FILE, spec.relative)
|
|
405
|
+
}
|
|
395
406
|
finishedTest.testSpan.finish(finishedTest.finishTime)
|
|
396
407
|
})
|
|
397
408
|
|
|
@@ -15,6 +15,8 @@ const {
|
|
|
15
15
|
TEST_ITR_FORCED_RUN,
|
|
16
16
|
TEST_CODE_OWNERS,
|
|
17
17
|
ITR_CORRELATION_ID,
|
|
18
|
+
TEST_SOURCE_FILE,
|
|
19
|
+
getTestSuitePath,
|
|
18
20
|
TEST_IS_NEW,
|
|
19
21
|
TEST_EARLY_FLAKE_IS_RETRY,
|
|
20
22
|
TEST_EARLY_FLAKE_IS_ENABLED
|
|
@@ -296,7 +298,17 @@ class JestPlugin extends CiPlugin {
|
|
|
296
298
|
}
|
|
297
299
|
|
|
298
300
|
startTestSpan (test) {
|
|
299
|
-
const {
|
|
301
|
+
const {
|
|
302
|
+
suite,
|
|
303
|
+
name,
|
|
304
|
+
runner,
|
|
305
|
+
testParameters,
|
|
306
|
+
frameworkVersion,
|
|
307
|
+
testStartLine,
|
|
308
|
+
testFileAbsolutePath,
|
|
309
|
+
isNew,
|
|
310
|
+
isEfdRetry
|
|
311
|
+
} = test
|
|
300
312
|
|
|
301
313
|
const extraTags = {
|
|
302
314
|
[JEST_TEST_RUNNER]: runner,
|
|
@@ -306,6 +318,13 @@ class JestPlugin extends CiPlugin {
|
|
|
306
318
|
if (testStartLine) {
|
|
307
319
|
extraTags[TEST_SOURCE_START] = testStartLine
|
|
308
320
|
}
|
|
321
|
+
if (testFileAbsolutePath) {
|
|
322
|
+
extraTags[TEST_SOURCE_FILE] = getTestSuitePath(testFileAbsolutePath, this.repositoryRoot)
|
|
323
|
+
} else {
|
|
324
|
+
// If for whatever we don't have the full path, we'll set the source file to the suite name
|
|
325
|
+
extraTags[TEST_SOURCE_FILE] = suite
|
|
326
|
+
}
|
|
327
|
+
|
|
309
328
|
if (isNew) {
|
|
310
329
|
extraTags[TEST_IS_NEW] = 'true'
|
|
311
330
|
if (isEfdRetry) {
|
|
@@ -15,7 +15,8 @@ const {
|
|
|
15
15
|
TEST_ITR_UNSKIPPABLE,
|
|
16
16
|
TEST_ITR_FORCED_RUN,
|
|
17
17
|
TEST_CODE_OWNERS,
|
|
18
|
-
ITR_CORRELATION_ID
|
|
18
|
+
ITR_CORRELATION_ID,
|
|
19
|
+
TEST_SOURCE_FILE
|
|
19
20
|
} = require('../../dd-trace/src/plugins/util/test')
|
|
20
21
|
const { COMPONENT } = require('../../dd-trace/src/constants')
|
|
21
22
|
const {
|
|
@@ -244,6 +245,14 @@ class MochaPlugin extends CiPlugin {
|
|
|
244
245
|
const testSuite = getTestSuitePath(testSuiteAbsolutePath, this.sourceRoot)
|
|
245
246
|
const testSuiteSpan = this._testSuites.get(testSuiteAbsolutePath)
|
|
246
247
|
|
|
248
|
+
const testSourceFile = getTestSuitePath(testSuiteAbsolutePath, this.repositoryRoot)
|
|
249
|
+
|
|
250
|
+
if (testSourceFile) {
|
|
251
|
+
extraTags[TEST_SOURCE_FILE] = testSourceFile
|
|
252
|
+
} else {
|
|
253
|
+
extraTags[TEST_SOURCE_FILE] = testSuite
|
|
254
|
+
}
|
|
255
|
+
|
|
247
256
|
return super.startTestSpan(testName, testSuite, testSuiteSpan, extraTags)
|
|
248
257
|
}
|
|
249
258
|
}
|
|
@@ -9,7 +9,8 @@ const {
|
|
|
9
9
|
getTestSuitePath,
|
|
10
10
|
getTestSuiteCommonTags,
|
|
11
11
|
TEST_SOURCE_START,
|
|
12
|
-
TEST_CODE_OWNERS
|
|
12
|
+
TEST_CODE_OWNERS,
|
|
13
|
+
TEST_SOURCE_FILE
|
|
13
14
|
} = require('../../dd-trace/src/plugins/util/test')
|
|
14
15
|
const { RESOURCE_NAME } = require('../../../ext/tags')
|
|
15
16
|
const { COMPONENT } = require('../../dd-trace/src/constants')
|
|
@@ -79,7 +80,8 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
79
80
|
this.addSub('ci:playwright:test:start', ({ testName, testSuiteAbsolutePath, testSourceLine }) => {
|
|
80
81
|
const store = storage.getStore()
|
|
81
82
|
const testSuite = getTestSuitePath(testSuiteAbsolutePath, this.rootDir)
|
|
82
|
-
const
|
|
83
|
+
const testSourceFile = getTestSuitePath(testSuiteAbsolutePath, this.repositoryRoot)
|
|
84
|
+
const span = this.startTestSpan(testName, testSuite, testSourceFile, testSourceLine)
|
|
83
85
|
|
|
84
86
|
this.enter(span, store)
|
|
85
87
|
})
|
|
@@ -126,9 +128,17 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
126
128
|
})
|
|
127
129
|
}
|
|
128
130
|
|
|
129
|
-
startTestSpan (testName, testSuite, testSourceLine) {
|
|
131
|
+
startTestSpan (testName, testSuite, testSourceFile, testSourceLine) {
|
|
130
132
|
const testSuiteSpan = this._testSuites.get(testSuite)
|
|
131
|
-
|
|
133
|
+
|
|
134
|
+
const extraTags = {
|
|
135
|
+
[TEST_SOURCE_START]: testSourceLine
|
|
136
|
+
}
|
|
137
|
+
if (testSourceFile) {
|
|
138
|
+
extraTags[TEST_SOURCE_FILE] = testSourceFile || testSuite
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return super.startTestSpan(testName, testSuite, testSuiteSpan, extraTags)
|
|
132
142
|
}
|
|
133
143
|
}
|
|
134
144
|
|
|
@@ -13,6 +13,7 @@ const { GIT_REPOSITORY_URL, GIT_COMMIT_SHA } = require('./plugins/util/tags')
|
|
|
13
13
|
const { getGitMetadataFromGitProperties, removeUserSensitiveInfo } = require('./git_properties')
|
|
14
14
|
const { updateConfig } = require('./telemetry')
|
|
15
15
|
const { getIsGCPFunction, getIsAzureFunctionConsumptionPlan } = require('./serverless')
|
|
16
|
+
const { ORIGIN_KEY } = require('./constants')
|
|
16
17
|
|
|
17
18
|
const fromEntries = Object.fromEntries || (entries =>
|
|
18
19
|
entries.reduce((obj, [k, v]) => Object.assign(obj, { [k]: v }), {}))
|
|
@@ -710,6 +711,12 @@ ken|consumer_?(?:id|key|secret)|sign(?:ed|ature)?|auth(?:entication|orization)?)
|
|
|
710
711
|
'runtime-id': uuid()
|
|
711
712
|
})
|
|
712
713
|
|
|
714
|
+
if (this.isCiVisibility) {
|
|
715
|
+
tagger.add(this.tags, {
|
|
716
|
+
[ORIGIN_KEY]: 'ciapp-test'
|
|
717
|
+
})
|
|
718
|
+
}
|
|
719
|
+
|
|
713
720
|
if (this.gitMetadataEnabled) {
|
|
714
721
|
this.repositoryUrl = removeUserSensitiveInfo(
|
|
715
722
|
coalesce(
|
|
@@ -166,6 +166,8 @@ module.exports = class CiPlugin extends Plugin {
|
|
|
166
166
|
[CI_WORKSPACE_PATH]: repositoryRoot
|
|
167
167
|
} = this.testEnvironmentMetadata
|
|
168
168
|
|
|
169
|
+
this.repositoryRoot = repositoryRoot || process.cwd()
|
|
170
|
+
|
|
169
171
|
this.codeOwnersEntries = getCodeOwnersFileEntries(repositoryRoot)
|
|
170
172
|
|
|
171
173
|
this.isUnsupportedCIProvider = !ciProviderName
|
|
@@ -259,7 +259,6 @@ function getTestCommonTags (name, suite, version, testFramework) {
|
|
|
259
259
|
[SAMPLING_PRIORITY]: AUTO_KEEP,
|
|
260
260
|
[TEST_NAME]: name,
|
|
261
261
|
[TEST_SUITE]: suite,
|
|
262
|
-
[TEST_SOURCE_FILE]: suite,
|
|
263
262
|
[RESOURCE_NAME]: `${suite}.${name}`,
|
|
264
263
|
[TEST_FRAMEWORK_VERSION]: version,
|
|
265
264
|
[LIBRARY_VERSION]: ddTraceVersion
|