dd-trace 4.0.0-pre-2e8aecc → 4.0.0-pre-768c6c9
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/cypress.js +1 -1
- package/packages/datadog-plugin-cucumber/src/index.js +2 -58
- package/packages/datadog-plugin-cypress/src/plugin.js +11 -2
- package/packages/datadog-plugin-jest/src/index.js +15 -65
- package/packages/datadog-plugin-mocha/src/index.js +34 -85
- package/packages/datadog-plugin-playwright/src/index.js +2 -62
- package/packages/dd-trace/src/plugins/ci_plugin.js +61 -9
package/package.json
CHANGED
|
@@ -8,15 +8,7 @@ const {
|
|
|
8
8
|
TEST_STATUS,
|
|
9
9
|
finishAllTraceSpans,
|
|
10
10
|
getTestSuitePath,
|
|
11
|
-
|
|
12
|
-
getTestSessionCommonTags,
|
|
13
|
-
getTestModuleCommonTags,
|
|
14
|
-
getTestSuiteCommonTags,
|
|
15
|
-
TEST_SUITE_ID,
|
|
16
|
-
TEST_MODULE_ID,
|
|
17
|
-
TEST_SESSION_ID,
|
|
18
|
-
TEST_COMMAND,
|
|
19
|
-
TEST_BUNDLE
|
|
11
|
+
getTestSuiteCommonTags
|
|
20
12
|
} = require('../../dd-trace/src/plugins/util/test')
|
|
21
13
|
const { RESOURCE_NAME } = require('../../../ext/tags')
|
|
22
14
|
const { COMPONENT, ERROR_MESSAGE } = require('../../dd-trace/src/constants')
|
|
@@ -31,32 +23,6 @@ class CucumberPlugin extends CiPlugin {
|
|
|
31
23
|
|
|
32
24
|
this.sourceRoot = process.cwd()
|
|
33
25
|
|
|
34
|
-
this.addSub('ci:cucumber:session:start', ({ command, frameworkVersion }) => {
|
|
35
|
-
const childOf = getTestParentSpan(this.tracer)
|
|
36
|
-
const testSessionSpanMetadata = getTestSessionCommonTags(command, frameworkVersion)
|
|
37
|
-
|
|
38
|
-
this.command = command
|
|
39
|
-
this.frameworkVersion = frameworkVersion
|
|
40
|
-
this.testSessionSpan = this.tracer.startSpan('cucumber.test_session', {
|
|
41
|
-
childOf,
|
|
42
|
-
tags: {
|
|
43
|
-
[COMPONENT]: this.constructor.name,
|
|
44
|
-
...this.testEnvironmentMetadata,
|
|
45
|
-
...testSessionSpanMetadata
|
|
46
|
-
}
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
const testModuleSpanMetadata = getTestModuleCommonTags(command, frameworkVersion)
|
|
50
|
-
this.testModuleSpan = this.tracer.startSpan('cucumber.test_module', {
|
|
51
|
-
childOf: this.testSessionSpan,
|
|
52
|
-
tags: {
|
|
53
|
-
[COMPONENT]: this.constructor.name,
|
|
54
|
-
...this.testEnvironmentMetadata,
|
|
55
|
-
...testModuleSpanMetadata
|
|
56
|
-
}
|
|
57
|
-
})
|
|
58
|
-
})
|
|
59
|
-
|
|
60
26
|
this.addSub('ci:cucumber:session:finish', (status) => {
|
|
61
27
|
this.testSessionSpan.setTag(TEST_STATUS, status)
|
|
62
28
|
this.testModuleSpan.setTag(TEST_STATUS, status)
|
|
@@ -138,32 +104,10 @@ class CucumberPlugin extends CiPlugin {
|
|
|
138
104
|
}
|
|
139
105
|
|
|
140
106
|
startTestSpan (testName, testSuite) {
|
|
141
|
-
const childOf = getTestParentSpan(this.tracer)
|
|
142
|
-
// TODO: move this logic to CiPlugin once every framework supports test suite level visibility
|
|
143
|
-
// This is a hack to get good time resolution on test events, while keeping
|
|
144
|
-
// the test event as the root span of its trace.
|
|
145
|
-
childOf._trace.startTime = this.testSessionSpan.context()._trace.startTime
|
|
146
|
-
childOf._trace.ticks = this.testSessionSpan.context()._trace.ticks
|
|
147
|
-
|
|
148
|
-
const testSuiteTags = {}
|
|
149
|
-
const testSuiteId = this.testSuiteSpan.context().toSpanId()
|
|
150
|
-
testSuiteTags[TEST_SUITE_ID] = testSuiteId
|
|
151
|
-
|
|
152
|
-
const testSessionId = this.testSessionSpan.context().toTraceId()
|
|
153
|
-
testSuiteTags[TEST_SESSION_ID] = testSessionId
|
|
154
|
-
testSuiteTags[TEST_COMMAND] = this.command
|
|
155
|
-
|
|
156
|
-
const testModuleId = this.testModuleSpan.context().toSpanId()
|
|
157
|
-
testSuiteTags[TEST_MODULE_ID] = testModuleId
|
|
158
|
-
testSuiteTags[TEST_COMMAND] = this.command
|
|
159
|
-
testSuiteTags[TEST_BUNDLE] = this.command
|
|
160
|
-
|
|
161
107
|
return super.startTestSpan(
|
|
162
108
|
testName,
|
|
163
109
|
testSuite,
|
|
164
|
-
|
|
165
|
-
this.frameworkVersion,
|
|
166
|
-
testSuiteTags
|
|
110
|
+
this.testSuiteSpan
|
|
167
111
|
)
|
|
168
112
|
}
|
|
169
113
|
}
|
|
@@ -15,7 +15,8 @@ const {
|
|
|
15
15
|
TEST_MODULE_ID,
|
|
16
16
|
TEST_SESSION_ID,
|
|
17
17
|
TEST_COMMAND,
|
|
18
|
-
TEST_BUNDLE
|
|
18
|
+
TEST_BUNDLE,
|
|
19
|
+
finishAllTraceSpans
|
|
19
20
|
} = require('../../dd-trace/src/plugins/util/test')
|
|
20
21
|
|
|
21
22
|
const { ORIGIN_KEY, COMPONENT } = require('../../dd-trace/src/constants')
|
|
@@ -123,12 +124,19 @@ module.exports = (on, config) => {
|
|
|
123
124
|
testModuleSpan.finish()
|
|
124
125
|
testSessionSpan.finish()
|
|
125
126
|
|
|
127
|
+
finishAllTraceSpans(testSessionSpan)
|
|
128
|
+
|
|
126
129
|
return new Promise(resolve => {
|
|
127
|
-
tracer._tracer._exporter._writer.flush(() =>
|
|
130
|
+
tracer._tracer._exporter._writer.flush(() => {
|
|
131
|
+
resolve(null)
|
|
132
|
+
})
|
|
128
133
|
})
|
|
129
134
|
})
|
|
130
135
|
on('task', {
|
|
131
136
|
'dd:testSuiteStart': (suite) => {
|
|
137
|
+
if (testSuiteSpan) {
|
|
138
|
+
return null
|
|
139
|
+
}
|
|
132
140
|
const testSuiteSpanMetadata = getTestSuiteCommonTags(command, frameworkVersion, suite)
|
|
133
141
|
testSuiteSpan = tracer.startSpan('cypress.test_suite', {
|
|
134
142
|
childOf: testModuleSpan,
|
|
@@ -144,6 +152,7 @@ module.exports = (on, config) => {
|
|
|
144
152
|
const status = getSuiteStatus(suiteStats)
|
|
145
153
|
testSuiteSpan.setTag(TEST_STATUS, status)
|
|
146
154
|
testSuiteSpan.finish()
|
|
155
|
+
testSuiteSpan = null
|
|
147
156
|
return null
|
|
148
157
|
},
|
|
149
158
|
'dd:beforeEach': (test) => {
|
|
@@ -6,18 +6,12 @@ const {
|
|
|
6
6
|
JEST_TEST_RUNNER,
|
|
7
7
|
finishAllTraceSpans,
|
|
8
8
|
getTestEnvironmentMetadata,
|
|
9
|
-
getTestParentSpan,
|
|
10
|
-
getTestSessionCommonTags,
|
|
11
|
-
getTestModuleCommonTags,
|
|
12
9
|
getTestSuiteCommonTags,
|
|
13
10
|
addIntelligentTestRunnerSpanTags,
|
|
14
11
|
TEST_PARAMETERS,
|
|
15
12
|
getCodeOwnersFileEntries,
|
|
16
|
-
TEST_SESSION_ID,
|
|
17
|
-
TEST_MODULE_ID,
|
|
18
|
-
TEST_SUITE_ID,
|
|
19
13
|
TEST_COMMAND,
|
|
20
|
-
|
|
14
|
+
TEST_FRAMEWORK_VERSION
|
|
21
15
|
} = require('../../dd-trace/src/plugins/util/test')
|
|
22
16
|
const { COMPONENT } = require('../../dd-trace/src/constants')
|
|
23
17
|
|
|
@@ -49,29 +43,6 @@ class JestPlugin extends CiPlugin {
|
|
|
49
43
|
this.testEnvironmentMetadata = getTestEnvironmentMetadata('jest', this.config)
|
|
50
44
|
this.codeOwnersEntries = getCodeOwnersFileEntries()
|
|
51
45
|
|
|
52
|
-
this.addSub('ci:jest:session:start', ({ command, frameworkVersion }) => {
|
|
53
|
-
const childOf = getTestParentSpan(this.tracer)
|
|
54
|
-
const testSessionSpanMetadata = getTestSessionCommonTags(command, frameworkVersion)
|
|
55
|
-
const testModuleSpanMetadata = getTestModuleCommonTags(command, frameworkVersion)
|
|
56
|
-
|
|
57
|
-
this.testSessionSpan = this.tracer.startSpan('jest.test_session', {
|
|
58
|
-
childOf,
|
|
59
|
-
tags: {
|
|
60
|
-
[COMPONENT]: this.constructor.name,
|
|
61
|
-
...this.testEnvironmentMetadata,
|
|
62
|
-
...testSessionSpanMetadata
|
|
63
|
-
}
|
|
64
|
-
})
|
|
65
|
-
this.testModuleSpan = this.tracer.startSpan('jest.test_module', {
|
|
66
|
-
childOf: this.testSessionSpan,
|
|
67
|
-
tags: {
|
|
68
|
-
[COMPONENT]: this.constructor.name,
|
|
69
|
-
...this.testEnvironmentMetadata,
|
|
70
|
-
...testModuleSpanMetadata
|
|
71
|
-
}
|
|
72
|
-
})
|
|
73
|
-
})
|
|
74
|
-
|
|
75
46
|
this.addSub('ci:jest:session:finish', ({
|
|
76
47
|
status,
|
|
77
48
|
isSuitesSkipped,
|
|
@@ -112,8 +83,6 @@ class JestPlugin extends CiPlugin {
|
|
|
112
83
|
_ddTestModuleId: testModuleId
|
|
113
84
|
} = testEnvironmentOptions
|
|
114
85
|
|
|
115
|
-
const store = storage.getStore()
|
|
116
|
-
|
|
117
86
|
const testSessionSpanContext = this.tracer.extract('text_map', {
|
|
118
87
|
'x-datadog-trace-id': testSessionId,
|
|
119
88
|
'x-datadog-parent-id': testModuleId
|
|
@@ -121,7 +90,7 @@ class JestPlugin extends CiPlugin {
|
|
|
121
90
|
|
|
122
91
|
const testSuiteMetadata = getTestSuiteCommonTags(testCommand, frameworkVersion, testSuite)
|
|
123
92
|
|
|
124
|
-
|
|
93
|
+
this.testSuiteSpan = this.tracer.startSpan('jest.test_suite', {
|
|
125
94
|
childOf: testSessionSpanContext,
|
|
126
95
|
tags: {
|
|
127
96
|
[COMPONENT]: this.constructor.name,
|
|
@@ -129,19 +98,17 @@ class JestPlugin extends CiPlugin {
|
|
|
129
98
|
...testSuiteMetadata
|
|
130
99
|
}
|
|
131
100
|
})
|
|
132
|
-
this.enter(testSuiteSpan, store)
|
|
133
101
|
})
|
|
134
102
|
|
|
135
103
|
this.addSub('ci:jest:test-suite:finish', ({ status, errorMessage }) => {
|
|
136
|
-
|
|
137
|
-
testSuiteSpan.setTag(TEST_STATUS, status)
|
|
104
|
+
this.testSuiteSpan.setTag(TEST_STATUS, status)
|
|
138
105
|
if (errorMessage) {
|
|
139
|
-
testSuiteSpan.setTag('error', new Error(errorMessage))
|
|
106
|
+
this.testSuiteSpan.setTag('error', new Error(errorMessage))
|
|
140
107
|
}
|
|
141
|
-
testSuiteSpan.finish()
|
|
108
|
+
this.testSuiteSpan.finish()
|
|
142
109
|
// Suites potentially run in a different process than the session,
|
|
143
110
|
// so calling finishAllTraceSpans on the session span is not enough
|
|
144
|
-
finishAllTraceSpans(testSuiteSpan)
|
|
111
|
+
finishAllTraceSpans(this.testSuiteSpan)
|
|
145
112
|
})
|
|
146
113
|
|
|
147
114
|
/**
|
|
@@ -150,8 +117,7 @@ class JestPlugin extends CiPlugin {
|
|
|
150
117
|
* fetching the ITR config.
|
|
151
118
|
*/
|
|
152
119
|
this.addSub('ci:jest:test-suite:code-coverage', (coverageFiles) => {
|
|
153
|
-
|
|
154
|
-
this.tracer._exporter.exportCoverage({ span: testSuiteSpan, coverageFiles })
|
|
120
|
+
this.tracer._exporter.exportCoverage({ span: this.testSuiteSpan, coverageFiles })
|
|
155
121
|
})
|
|
156
122
|
|
|
157
123
|
this.addSub('ci:jest:test:start', (test) => {
|
|
@@ -170,9 +136,12 @@ class JestPlugin extends CiPlugin {
|
|
|
170
136
|
|
|
171
137
|
this.addSub('ci:jest:test:err', (error) => {
|
|
172
138
|
if (error) {
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
|
|
139
|
+
const store = storage.getStore()
|
|
140
|
+
if (store && store.span) {
|
|
141
|
+
const span = store.span
|
|
142
|
+
span.setTag(TEST_STATUS, 'fail')
|
|
143
|
+
span.setTag('error', error)
|
|
144
|
+
}
|
|
176
145
|
}
|
|
177
146
|
})
|
|
178
147
|
|
|
@@ -184,34 +153,15 @@ class JestPlugin extends CiPlugin {
|
|
|
184
153
|
}
|
|
185
154
|
|
|
186
155
|
startTestSpan (test) {
|
|
187
|
-
let childOf
|
|
188
|
-
const suiteTags = {}
|
|
189
|
-
const store = storage.getStore()
|
|
190
|
-
const testSuiteSpan = store ? store.span : undefined
|
|
191
|
-
if (testSuiteSpan) {
|
|
192
|
-
const testSuiteId = testSuiteSpan.context().toSpanId()
|
|
193
|
-
suiteTags[TEST_SUITE_ID] = testSuiteId
|
|
194
|
-
suiteTags[TEST_SESSION_ID] = testSuiteSpan.context().toTraceId()
|
|
195
|
-
suiteTags[TEST_MODULE_ID] = testSuiteSpan.context()._parentId.toString(10)
|
|
196
|
-
suiteTags[TEST_COMMAND] = testSuiteSpan.context()._tags[TEST_COMMAND]
|
|
197
|
-
suiteTags[TEST_BUNDLE] = suiteTags[TEST_COMMAND]
|
|
198
|
-
// TODO: move this logic to CiPlugin once every framework supports test suite level visibility
|
|
199
|
-
// This is a hack to get good time resolution on test events, while keeping
|
|
200
|
-
// the test event as the root span of its trace.
|
|
201
|
-
childOf = getTestParentSpan(this.tracer)
|
|
202
|
-
childOf._trace.startTime = testSuiteSpan.context()._trace.startTime
|
|
203
|
-
childOf._trace.ticks = testSuiteSpan.context()._trace.ticks
|
|
204
|
-
}
|
|
205
|
-
|
|
206
156
|
const { suite, name, runner, testParameters, frameworkVersion } = test
|
|
207
157
|
|
|
208
158
|
const extraTags = {
|
|
209
159
|
[JEST_TEST_RUNNER]: runner,
|
|
210
160
|
[TEST_PARAMETERS]: testParameters,
|
|
211
|
-
|
|
161
|
+
[TEST_FRAMEWORK_VERSION]: frameworkVersion
|
|
212
162
|
}
|
|
213
163
|
|
|
214
|
-
return super.startTestSpan(name, suite,
|
|
164
|
+
return super.startTestSpan(name, suite, this.testSuiteSpan, extraTags)
|
|
215
165
|
}
|
|
216
166
|
}
|
|
217
167
|
|
|
@@ -8,17 +8,9 @@ const {
|
|
|
8
8
|
TEST_PARAMETERS,
|
|
9
9
|
finishAllTraceSpans,
|
|
10
10
|
getTestSuitePath,
|
|
11
|
-
getTestParentSpan,
|
|
12
11
|
getTestParametersString,
|
|
13
|
-
getTestSessionCommonTags,
|
|
14
|
-
getTestModuleCommonTags,
|
|
15
12
|
getTestSuiteCommonTags,
|
|
16
|
-
addIntelligentTestRunnerSpanTags
|
|
17
|
-
TEST_SUITE_ID,
|
|
18
|
-
TEST_SESSION_ID,
|
|
19
|
-
TEST_MODULE_ID,
|
|
20
|
-
TEST_BUNDLE,
|
|
21
|
-
TEST_COMMAND
|
|
13
|
+
addIntelligentTestRunnerSpanTags
|
|
22
14
|
} = require('../../dd-trace/src/plugins/util/test')
|
|
23
15
|
const { COMPONENT } = require('../../dd-trace/src/constants')
|
|
24
16
|
|
|
@@ -49,32 +41,6 @@ class MochaPlugin extends CiPlugin {
|
|
|
49
41
|
})
|
|
50
42
|
})
|
|
51
43
|
|
|
52
|
-
this.addSub('ci:mocha:session:start', ({ command, frameworkVersion }) => {
|
|
53
|
-
const childOf = getTestParentSpan(this.tracer)
|
|
54
|
-
const testSessionSpanMetadata = getTestSessionCommonTags(command, frameworkVersion)
|
|
55
|
-
|
|
56
|
-
this.command = command
|
|
57
|
-
this.frameworkVersion = frameworkVersion
|
|
58
|
-
this.testSessionSpan = this.tracer.startSpan('mocha.test_session', {
|
|
59
|
-
childOf,
|
|
60
|
-
tags: {
|
|
61
|
-
[COMPONENT]: this.constructor.name,
|
|
62
|
-
...this.testEnvironmentMetadata,
|
|
63
|
-
...testSessionSpanMetadata
|
|
64
|
-
}
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
const testModuleSpanMetadata = getTestModuleCommonTags(command, frameworkVersion)
|
|
68
|
-
this.testModuleSpan = this.tracer.startSpan('mocha.test_module', {
|
|
69
|
-
childOf: this.testSessionSpan,
|
|
70
|
-
tags: {
|
|
71
|
-
[COMPONENT]: this.constructor.name,
|
|
72
|
-
...this.testEnvironmentMetadata,
|
|
73
|
-
...testModuleSpanMetadata
|
|
74
|
-
}
|
|
75
|
-
})
|
|
76
|
-
})
|
|
77
|
-
|
|
78
44
|
this.addSub('ci:mocha:test-suite:start', (suite) => {
|
|
79
45
|
const store = storage.getStore()
|
|
80
46
|
const testSuiteMetadata = getTestSuiteCommonTags(
|
|
@@ -95,18 +61,24 @@ class MochaPlugin extends CiPlugin {
|
|
|
95
61
|
})
|
|
96
62
|
|
|
97
63
|
this.addSub('ci:mocha:test-suite:finish', (status) => {
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
64
|
+
const store = storage.getStore()
|
|
65
|
+
if (store && store.span) {
|
|
66
|
+
const span = storage.getStore().span
|
|
67
|
+
// the test status of the suite may have been set in ci:mocha:test-suite:error already
|
|
68
|
+
if (!span.context()._tags[TEST_STATUS]) {
|
|
69
|
+
span.setTag(TEST_STATUS, status)
|
|
70
|
+
}
|
|
71
|
+
span.finish()
|
|
102
72
|
}
|
|
103
|
-
span.finish()
|
|
104
73
|
})
|
|
105
74
|
|
|
106
75
|
this.addSub('ci:mocha:test-suite:error', (err) => {
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
76
|
+
const store = storage.getStore()
|
|
77
|
+
if (store && store.span) {
|
|
78
|
+
const span = storage.getStore().span
|
|
79
|
+
span.setTag('error', err)
|
|
80
|
+
span.setTag(TEST_STATUS, 'fail')
|
|
81
|
+
}
|
|
110
82
|
})
|
|
111
83
|
|
|
112
84
|
this.addSub('ci:mocha:test:start', (test) => {
|
|
@@ -117,12 +89,16 @@ class MochaPlugin extends CiPlugin {
|
|
|
117
89
|
})
|
|
118
90
|
|
|
119
91
|
this.addSub('ci:mocha:test:finish', (status) => {
|
|
120
|
-
const
|
|
92
|
+
const store = storage.getStore()
|
|
121
93
|
|
|
122
|
-
|
|
94
|
+
if (store && store.span) {
|
|
95
|
+
const span = storage.getStore().span
|
|
96
|
+
|
|
97
|
+
span.setTag(TEST_STATUS, status)
|
|
123
98
|
|
|
124
|
-
|
|
125
|
-
|
|
99
|
+
span.finish()
|
|
100
|
+
finishAllTraceSpans(span)
|
|
101
|
+
}
|
|
126
102
|
})
|
|
127
103
|
|
|
128
104
|
this.addSub('ci:mocha:test:skip', (test) => {
|
|
@@ -136,8 +112,9 @@ class MochaPlugin extends CiPlugin {
|
|
|
136
112
|
})
|
|
137
113
|
|
|
138
114
|
this.addSub('ci:mocha:test:error', (err) => {
|
|
139
|
-
|
|
140
|
-
|
|
115
|
+
const store = storage.getStore()
|
|
116
|
+
if (err && store && store.span) {
|
|
117
|
+
const span = store.span
|
|
141
118
|
if (err.constructor.name === 'Pending' && !this.forbidPending) {
|
|
142
119
|
span.setTag(TEST_STATUS, 'skip')
|
|
143
120
|
} else {
|
|
@@ -173,47 +150,19 @@ class MochaPlugin extends CiPlugin {
|
|
|
173
150
|
}
|
|
174
151
|
|
|
175
152
|
startTestSpan (test) {
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
// This is a hack to get good time resolution on test events, while keeping
|
|
179
|
-
// the test event as the root span of its trace.
|
|
180
|
-
childOf._trace.startTime = this.testSessionSpan.context()._trace.startTime
|
|
181
|
-
childOf._trace.ticks = this.testSessionSpan.context()._trace.ticks
|
|
182
|
-
|
|
183
|
-
const testSuiteTags = {}
|
|
184
|
-
const testSuiteSpan = this._testSuites.get(test.parent.file)
|
|
185
|
-
if (testSuiteSpan) {
|
|
186
|
-
const testSuiteId = testSuiteSpan.context().toSpanId()
|
|
187
|
-
testSuiteTags[TEST_SUITE_ID] = testSuiteId
|
|
188
|
-
}
|
|
153
|
+
const testName = test.fullTitle()
|
|
154
|
+
const { file: testSuiteAbsolutePath, title } = test
|
|
189
155
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
testSuiteTags[TEST_SESSION_ID] = testSessionId
|
|
193
|
-
testSuiteTags[TEST_COMMAND] = this.command
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
if (this.testModuleSpan) {
|
|
197
|
-
const testModuleId = this.testModuleSpan.context().toSpanId()
|
|
198
|
-
testSuiteTags[TEST_MODULE_ID] = testModuleId
|
|
199
|
-
testSuiteTags[TEST_COMMAND] = this.command
|
|
200
|
-
testSuiteTags[TEST_BUNDLE] = this.command
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
const { file: testSuiteAbsolutePath } = test
|
|
204
|
-
const fullTestName = test.fullTitle()
|
|
205
|
-
const testSuite = getTestSuitePath(testSuiteAbsolutePath, this.sourceRoot)
|
|
206
|
-
|
|
207
|
-
const extraTags = {
|
|
208
|
-
...testSuiteTags
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
const testParametersString = getTestParametersString(this._testNameToParams, test.title)
|
|
156
|
+
const extraTags = {}
|
|
157
|
+
const testParametersString = getTestParametersString(this._testNameToParams, title)
|
|
212
158
|
if (testParametersString) {
|
|
213
159
|
extraTags[TEST_PARAMETERS] = testParametersString
|
|
214
160
|
}
|
|
215
161
|
|
|
216
|
-
|
|
162
|
+
const testSuite = getTestSuitePath(testSuiteAbsolutePath, this.sourceRoot)
|
|
163
|
+
const testSuiteSpan = this._testSuites.get(testSuiteAbsolutePath)
|
|
164
|
+
|
|
165
|
+
return super.startTestSpan(testName, testSuite, testSuiteSpan, extraTags)
|
|
217
166
|
}
|
|
218
167
|
}
|
|
219
168
|
|
|
@@ -6,16 +6,8 @@ const CiPlugin = require('../../dd-trace/src/plugins/ci_plugin')
|
|
|
6
6
|
const {
|
|
7
7
|
TEST_STATUS,
|
|
8
8
|
finishAllTraceSpans,
|
|
9
|
-
getTestParentSpan,
|
|
10
|
-
getTestSessionCommonTags,
|
|
11
9
|
getTestSuitePath,
|
|
12
|
-
|
|
13
|
-
TEST_COMMAND,
|
|
14
|
-
TEST_SUITE_ID,
|
|
15
|
-
getTestSuiteCommonTags,
|
|
16
|
-
getTestModuleCommonTags,
|
|
17
|
-
TEST_MODULE_ID,
|
|
18
|
-
TEST_BUNDLE
|
|
10
|
+
getTestSuiteCommonTags
|
|
19
11
|
} = require('../../dd-trace/src/plugins/util/test')
|
|
20
12
|
const { RESOURCE_NAME } = require('../../../ext/tags')
|
|
21
13
|
const { COMPONENT } = require('../../dd-trace/src/constants')
|
|
@@ -30,32 +22,6 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
30
22
|
|
|
31
23
|
this._testSuites = new Map()
|
|
32
24
|
|
|
33
|
-
this.addSub('ci:playwright:session:start', ({ command, frameworkVersion, rootDir }) => {
|
|
34
|
-
const childOf = getTestParentSpan(this.tracer)
|
|
35
|
-
this.command = command
|
|
36
|
-
this.frameworkVersion = frameworkVersion
|
|
37
|
-
this.rootDir = rootDir
|
|
38
|
-
|
|
39
|
-
const testSessionSpanMetadata = getTestSessionCommonTags(command, frameworkVersion)
|
|
40
|
-
this.testSessionSpan = this.tracer.startSpan('playwright.test_session', {
|
|
41
|
-
childOf,
|
|
42
|
-
tags: {
|
|
43
|
-
[COMPONENT]: this.constructor.name,
|
|
44
|
-
...this.testEnvironmentMetadata,
|
|
45
|
-
...testSessionSpanMetadata
|
|
46
|
-
}
|
|
47
|
-
})
|
|
48
|
-
const testModuleSpanMetadata = getTestModuleCommonTags(command, frameworkVersion)
|
|
49
|
-
this.testModuleSpan = this.tracer.startSpan('playwright.test_module', {
|
|
50
|
-
childOf: this.testSessionSpan,
|
|
51
|
-
tags: {
|
|
52
|
-
[COMPONENT]: this.constructor.name,
|
|
53
|
-
...this.testEnvironmentMetadata,
|
|
54
|
-
...testModuleSpanMetadata
|
|
55
|
-
}
|
|
56
|
-
})
|
|
57
|
-
})
|
|
58
|
-
|
|
59
25
|
this.addSub('ci:playwright:session:finish', ({ status, onDone }) => {
|
|
60
26
|
this.testModuleSpan.setTag(TEST_STATUS, status)
|
|
61
27
|
this.testSessionSpan.setTag(TEST_STATUS, status)
|
|
@@ -138,34 +104,8 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
138
104
|
}
|
|
139
105
|
|
|
140
106
|
startTestSpan (testName, testSuite) {
|
|
141
|
-
const childOf = getTestParentSpan(this.tracer)
|
|
142
|
-
// TODO: move this logic to CiPlugin once every framework supports test suite level visibility
|
|
143
|
-
// This is a hack to get good time resolution on test events, while keeping
|
|
144
|
-
// the test event as the root span of its trace.
|
|
145
|
-
childOf._trace.startTime = this.testSessionSpan.context()._trace.startTime
|
|
146
|
-
childOf._trace.ticks = this.testSessionSpan.context()._trace.ticks
|
|
147
|
-
|
|
148
|
-
const testSuiteTags = {}
|
|
149
107
|
const testSuiteSpan = this._testSuites.get(testSuite)
|
|
150
|
-
|
|
151
|
-
const testSuiteId = testSuiteSpan.context().toSpanId()
|
|
152
|
-
testSuiteTags[TEST_SUITE_ID] = testSuiteId
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
if (this.testSessionSpan) {
|
|
156
|
-
const testSessionId = this.testSessionSpan.context().toTraceId()
|
|
157
|
-
testSuiteTags[TEST_SESSION_ID] = testSessionId
|
|
158
|
-
testSuiteTags[TEST_COMMAND] = this.command
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
if (this.testModuleSpan) {
|
|
162
|
-
const testModuleId = this.testModuleSpan.context().toSpanId()
|
|
163
|
-
testSuiteTags[TEST_MODULE_ID] = testModuleId
|
|
164
|
-
testSuiteTags[TEST_COMMAND] = this.command
|
|
165
|
-
testSuiteTags[TEST_BUNDLE] = this.command
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
return super.startTestSpan(testName, testSuite, childOf, this.frameworkVersion, testSuiteTags)
|
|
108
|
+
return super.startTestSpan(testName, testSuite, testSuiteSpan)
|
|
169
109
|
}
|
|
170
110
|
}
|
|
171
111
|
|
|
@@ -5,7 +5,14 @@ const {
|
|
|
5
5
|
getTestCommonTags,
|
|
6
6
|
getCodeOwnersForFilename,
|
|
7
7
|
TEST_CODE_OWNERS,
|
|
8
|
-
CI_APP_ORIGIN
|
|
8
|
+
CI_APP_ORIGIN,
|
|
9
|
+
getTestSessionCommonTags,
|
|
10
|
+
getTestModuleCommonTags,
|
|
11
|
+
TEST_SUITE_ID,
|
|
12
|
+
TEST_MODULE_ID,
|
|
13
|
+
TEST_SESSION_ID,
|
|
14
|
+
TEST_COMMAND,
|
|
15
|
+
TEST_BUNDLE
|
|
9
16
|
} = require('./util/test')
|
|
10
17
|
const Plugin = require('./plugin')
|
|
11
18
|
const { COMPONENT } = require('../constants')
|
|
@@ -40,6 +47,34 @@ module.exports = class CiPlugin extends Plugin {
|
|
|
40
47
|
onDone({ err, skippableSuites })
|
|
41
48
|
})
|
|
42
49
|
})
|
|
50
|
+
|
|
51
|
+
this.addSub(`ci:${this.constructor.name}:session:start`, ({ command, frameworkVersion, rootDir }) => {
|
|
52
|
+
const childOf = getTestParentSpan(this.tracer)
|
|
53
|
+
const testSessionSpanMetadata = getTestSessionCommonTags(command, frameworkVersion)
|
|
54
|
+
const testModuleSpanMetadata = getTestModuleCommonTags(command, frameworkVersion)
|
|
55
|
+
|
|
56
|
+
this.command = command
|
|
57
|
+
this.frameworkVersion = frameworkVersion
|
|
58
|
+
// only for playwright
|
|
59
|
+
this.rootDir = rootDir
|
|
60
|
+
|
|
61
|
+
this.testSessionSpan = this.tracer.startSpan(`${this.constructor.name}.test_session`, {
|
|
62
|
+
childOf,
|
|
63
|
+
tags: {
|
|
64
|
+
[COMPONENT]: this.constructor.name,
|
|
65
|
+
...this.testEnvironmentMetadata,
|
|
66
|
+
...testSessionSpanMetadata
|
|
67
|
+
}
|
|
68
|
+
})
|
|
69
|
+
this.testModuleSpan = this.tracer.startSpan(`${this.constructor.name}.test_module`, {
|
|
70
|
+
childOf: this.testSessionSpan,
|
|
71
|
+
tags: {
|
|
72
|
+
[COMPONENT]: this.constructor.name,
|
|
73
|
+
...this.testEnvironmentMetadata,
|
|
74
|
+
...testModuleSpanMetadata
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
})
|
|
43
78
|
}
|
|
44
79
|
|
|
45
80
|
configure (config) {
|
|
@@ -70,25 +105,42 @@ module.exports = class CiPlugin extends Plugin {
|
|
|
70
105
|
}
|
|
71
106
|
}
|
|
72
107
|
|
|
73
|
-
startTestSpan (
|
|
74
|
-
const
|
|
75
|
-
const testCommonTags = getTestCommonTags(name, suite, frameworkVersion)
|
|
108
|
+
startTestSpan (testName, testSuite, testSuiteSpan, extraTags = {}) {
|
|
109
|
+
const childOf = getTestParentSpan(this.tracer)
|
|
76
110
|
|
|
77
|
-
|
|
78
|
-
...
|
|
111
|
+
let testTags = {
|
|
112
|
+
...getTestCommonTags(testName, testSuite, this.frameworkVersion),
|
|
79
113
|
[COMPONENT]: this.constructor.name,
|
|
80
114
|
...extraTags
|
|
81
115
|
}
|
|
82
116
|
|
|
83
|
-
const codeOwners = getCodeOwnersForFilename(
|
|
84
|
-
|
|
117
|
+
const codeOwners = getCodeOwnersForFilename(testSuite, this.codeOwnersEntries)
|
|
85
118
|
if (codeOwners) {
|
|
86
119
|
testTags[TEST_CODE_OWNERS] = codeOwners
|
|
87
120
|
}
|
|
88
121
|
|
|
122
|
+
if (testSuiteSpan) {
|
|
123
|
+
// This is a hack to get good time resolution on test events, while keeping
|
|
124
|
+
// the test event as the root span of its trace.
|
|
125
|
+
childOf._trace.startTime = testSuiteSpan.context()._trace.startTime
|
|
126
|
+
childOf._trace.ticks = testSuiteSpan.context()._trace.ticks
|
|
127
|
+
|
|
128
|
+
const suiteTags = {
|
|
129
|
+
[TEST_SUITE_ID]: testSuiteSpan.context().toSpanId(),
|
|
130
|
+
[TEST_SESSION_ID]: testSuiteSpan.context().toTraceId(),
|
|
131
|
+
[TEST_MODULE_ID]: testSuiteSpan.context()._parentId.toString(10),
|
|
132
|
+
[TEST_COMMAND]: testSuiteSpan.context()._tags[TEST_COMMAND],
|
|
133
|
+
[TEST_BUNDLE]: testSuiteSpan.context()._tags[TEST_COMMAND]
|
|
134
|
+
}
|
|
135
|
+
testTags = {
|
|
136
|
+
...testTags,
|
|
137
|
+
...suiteTags
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
89
141
|
const testSpan = this.tracer
|
|
90
142
|
.startSpan(`${this.constructor.name}.test`, {
|
|
91
|
-
childOf
|
|
143
|
+
childOf,
|
|
92
144
|
tags: {
|
|
93
145
|
...this.testEnvironmentMetadata,
|
|
94
146
|
...testTags
|