dd-trace 5.20.0 → 5.21.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/index.d.ts +2 -1
- package/package.json +4 -4
- package/packages/datadog-instrumentations/src/body-parser.js +14 -2
- package/packages/datadog-instrumentations/src/cucumber.js +10 -0
- package/packages/datadog-instrumentations/src/helpers/hooks.js +3 -2
- package/packages/datadog-instrumentations/src/helpers/register.js +8 -1
- package/packages/datadog-instrumentations/src/mocha/main.js +90 -70
- package/packages/datadog-instrumentations/src/nyc.js +23 -0
- package/packages/datadog-instrumentations/src/vitest.js +18 -2
- package/packages/datadog-plugin-cucumber/src/index.js +12 -2
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +16 -4
- package/packages/datadog-plugin-jest/src/index.js +17 -4
- package/packages/datadog-plugin-mocha/src/index.js +25 -6
- package/packages/datadog-plugin-nyc/src/index.js +35 -0
- package/packages/datadog-plugin-playwright/src/index.js +9 -4
- package/packages/datadog-plugin-vitest/src/index.js +30 -4
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +40 -1
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +2 -4
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +2 -4
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +8 -7
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +2 -4
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +2 -4
- package/packages/dd-trace/src/ci-visibility/telemetry.js +29 -2
- package/packages/dd-trace/src/config.js +118 -112
- package/packages/dd-trace/src/opentelemetry/context_manager.js +22 -39
- package/packages/dd-trace/src/opentelemetry/span_context.js +2 -2
- package/packages/dd-trace/src/opentelemetry/tracer.js +23 -14
- package/packages/dd-trace/src/opentelemetry/tracer_provider.js +9 -1
- package/packages/dd-trace/src/opentracing/propagation/log.js +1 -1
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +60 -0
- package/packages/dd-trace/src/opentracing/span_context.js +1 -0
- package/packages/dd-trace/src/plugins/ci_plugin.js +2 -2
- package/packages/dd-trace/src/plugins/index.js +1 -0
- package/packages/dd-trace/src/plugins/util/git.js +14 -1
- package/packages/dd-trace/src/telemetry/index.js +1 -1
|
@@ -14,7 +14,8 @@ const {
|
|
|
14
14
|
TEST_CONFIGURATION_BROWSER_NAME,
|
|
15
15
|
TEST_IS_NEW,
|
|
16
16
|
TEST_IS_RETRY,
|
|
17
|
-
TEST_EARLY_FLAKE_ENABLED
|
|
17
|
+
TEST_EARLY_FLAKE_ENABLED,
|
|
18
|
+
TELEMETRY_TEST_SESSION
|
|
18
19
|
} = require('../../dd-trace/src/plugins/util/test')
|
|
19
20
|
const { RESOURCE_NAME } = require('../../../ext/tags')
|
|
20
21
|
const { COMPONENT } = require('../../dd-trace/src/constants')
|
|
@@ -59,6 +60,7 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
59
60
|
this.testSessionSpan.finish()
|
|
60
61
|
this.telemetry.ciVisEvent(TELEMETRY_EVENT_FINISHED, 'session')
|
|
61
62
|
finishAllTraceSpans(this.testSessionSpan)
|
|
63
|
+
this.telemetry.count(TELEMETRY_TEST_SESSION, { provider: this.ciProviderName })
|
|
62
64
|
appClosingTelemetry()
|
|
63
65
|
this.tracer._exporter.flush(onDone)
|
|
64
66
|
this.numFailedTests = 0
|
|
@@ -160,8 +162,6 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
160
162
|
stepSpan.finish(stepStartTime + stepDuration)
|
|
161
163
|
})
|
|
162
164
|
|
|
163
|
-
span.finish()
|
|
164
|
-
|
|
165
165
|
if (testStatus === 'fail') {
|
|
166
166
|
this.numFailedTests++
|
|
167
167
|
}
|
|
@@ -169,8 +169,13 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
169
169
|
this.telemetry.ciVisEvent(
|
|
170
170
|
TELEMETRY_EVENT_FINISHED,
|
|
171
171
|
'test',
|
|
172
|
-
{
|
|
172
|
+
{
|
|
173
|
+
hasCodeOwners: !!span.context()._tags[TEST_CODE_OWNERS],
|
|
174
|
+
isNew,
|
|
175
|
+
browserDriver: 'playwright'
|
|
176
|
+
}
|
|
173
177
|
)
|
|
178
|
+
span.finish()
|
|
174
179
|
|
|
175
180
|
finishAllTraceSpans(span)
|
|
176
181
|
})
|
|
@@ -7,9 +7,16 @@ const {
|
|
|
7
7
|
getTestSuitePath,
|
|
8
8
|
getTestSuiteCommonTags,
|
|
9
9
|
TEST_SOURCE_FILE,
|
|
10
|
-
TEST_IS_RETRY
|
|
10
|
+
TEST_IS_RETRY,
|
|
11
|
+
TEST_CODE_COVERAGE_LINES_PCT,
|
|
12
|
+
TEST_CODE_OWNERS
|
|
11
13
|
} = require('../../dd-trace/src/plugins/util/test')
|
|
12
14
|
const { COMPONENT } = require('../../dd-trace/src/constants')
|
|
15
|
+
const {
|
|
16
|
+
TELEMETRY_EVENT_CREATED,
|
|
17
|
+
TELEMETRY_EVENT_FINISHED,
|
|
18
|
+
TELEMETRY_TEST_SESSION
|
|
19
|
+
} = require('../../dd-trace/src/ci-visibility/telemetry')
|
|
13
20
|
|
|
14
21
|
// Milliseconds that we subtract from the error test duration
|
|
15
22
|
// so that they do not overlap with the following test
|
|
@@ -64,6 +71,9 @@ class VitestPlugin extends CiPlugin {
|
|
|
64
71
|
const span = store?.span
|
|
65
72
|
|
|
66
73
|
if (span) {
|
|
74
|
+
this.telemetry.ciVisEvent(TELEMETRY_EVENT_FINISHED, 'test', {
|
|
75
|
+
hasCodeowners: !!span.context()._tags[TEST_CODE_OWNERS]
|
|
76
|
+
})
|
|
67
77
|
span.setTag(TEST_STATUS, 'pass')
|
|
68
78
|
span.finish(this.taskToFinishTime.get(task))
|
|
69
79
|
finishAllTraceSpans(span)
|
|
@@ -75,6 +85,9 @@ class VitestPlugin extends CiPlugin {
|
|
|
75
85
|
const span = store?.span
|
|
76
86
|
|
|
77
87
|
if (span) {
|
|
88
|
+
this.telemetry.ciVisEvent(TELEMETRY_EVENT_FINISHED, 'test', {
|
|
89
|
+
hasCodeowners: !!span.context()._tags[TEST_CODE_OWNERS]
|
|
90
|
+
})
|
|
78
91
|
span.setTag(TEST_STATUS, 'fail')
|
|
79
92
|
|
|
80
93
|
if (error) {
|
|
@@ -91,7 +104,7 @@ class VitestPlugin extends CiPlugin {
|
|
|
91
104
|
|
|
92
105
|
this.addSub('ci:vitest:test:skip', ({ testName, testSuiteAbsolutePath }) => {
|
|
93
106
|
const testSuite = getTestSuitePath(testSuiteAbsolutePath, this.repositoryRoot)
|
|
94
|
-
this.startTestSpan(
|
|
107
|
+
const testSpan = this.startTestSpan(
|
|
95
108
|
testName,
|
|
96
109
|
testSuite,
|
|
97
110
|
this.testSuiteSpan,
|
|
@@ -99,7 +112,11 @@ class VitestPlugin extends CiPlugin {
|
|
|
99
112
|
[TEST_SOURCE_FILE]: testSuite,
|
|
100
113
|
[TEST_STATUS]: 'skip'
|
|
101
114
|
}
|
|
102
|
-
)
|
|
115
|
+
)
|
|
116
|
+
this.telemetry.ciVisEvent(TELEMETRY_EVENT_FINISHED, 'test', {
|
|
117
|
+
hasCodeowners: !!testSpan.context()._tags[TEST_CODE_OWNERS]
|
|
118
|
+
})
|
|
119
|
+
testSpan.finish()
|
|
103
120
|
})
|
|
104
121
|
|
|
105
122
|
this.addSub('ci:vitest:test-suite:start', ({ testSuiteAbsolutePath, frameworkVersion }) => {
|
|
@@ -124,6 +141,7 @@ class VitestPlugin extends CiPlugin {
|
|
|
124
141
|
...testSuiteMetadata
|
|
125
142
|
}
|
|
126
143
|
})
|
|
144
|
+
this.telemetry.ciVisEvent(TELEMETRY_EVENT_CREATED, 'suite')
|
|
127
145
|
const store = storage.getStore()
|
|
128
146
|
this.enter(testSuiteSpan, store)
|
|
129
147
|
this.testSuiteSpan = testSuiteSpan
|
|
@@ -137,6 +155,7 @@ class VitestPlugin extends CiPlugin {
|
|
|
137
155
|
span.finish()
|
|
138
156
|
finishAllTraceSpans(span)
|
|
139
157
|
}
|
|
158
|
+
this.telemetry.ciVisEvent(TELEMETRY_EVENT_FINISHED, 'suite')
|
|
140
159
|
// TODO: too frequent flush - find for method in worker to decrease frequency
|
|
141
160
|
this.tracer._exporter.flush(onFinish)
|
|
142
161
|
})
|
|
@@ -150,16 +169,23 @@ class VitestPlugin extends CiPlugin {
|
|
|
150
169
|
}
|
|
151
170
|
})
|
|
152
171
|
|
|
153
|
-
this.addSub('ci:vitest:session:finish', ({ status, onFinish, error }) => {
|
|
172
|
+
this.addSub('ci:vitest:session:finish', ({ status, onFinish, error, testCodeCoverageLinesTotal }) => {
|
|
154
173
|
this.testSessionSpan.setTag(TEST_STATUS, status)
|
|
155
174
|
this.testModuleSpan.setTag(TEST_STATUS, status)
|
|
156
175
|
if (error) {
|
|
157
176
|
this.testModuleSpan.setTag('error', error)
|
|
158
177
|
this.testSessionSpan.setTag('error', error)
|
|
159
178
|
}
|
|
179
|
+
if (testCodeCoverageLinesTotal) {
|
|
180
|
+
this.testModuleSpan.setTag(TEST_CODE_COVERAGE_LINES_PCT, testCodeCoverageLinesTotal)
|
|
181
|
+
this.testSessionSpan.setTag(TEST_CODE_COVERAGE_LINES_PCT, testCodeCoverageLinesTotal)
|
|
182
|
+
}
|
|
160
183
|
this.testModuleSpan.finish()
|
|
184
|
+
this.telemetry.ciVisEvent(TELEMETRY_EVENT_FINISHED, 'module')
|
|
161
185
|
this.testSessionSpan.finish()
|
|
186
|
+
this.telemetry.ciVisEvent(TELEMETRY_EVENT_FINISHED, 'session')
|
|
162
187
|
finishAllTraceSpans(this.testSessionSpan)
|
|
188
|
+
this.telemetry.count(TELEMETRY_TEST_SESSION, { provider: this.ciProviderName })
|
|
163
189
|
this.tracer._exporter.flush(onFinish)
|
|
164
190
|
})
|
|
165
191
|
}
|
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
const request = require('../../exporters/common/request')
|
|
2
2
|
const id = require('../../id')
|
|
3
|
+
const log = require('../../log')
|
|
4
|
+
|
|
5
|
+
const {
|
|
6
|
+
incrementCountMetric,
|
|
7
|
+
distributionMetric,
|
|
8
|
+
TELEMETRY_KNOWN_TESTS,
|
|
9
|
+
TELEMETRY_KNOWN_TESTS_MS,
|
|
10
|
+
TELEMETRY_KNOWN_TESTS_ERRORS,
|
|
11
|
+
TELEMETRY_KNOWN_TESTS_RESPONSE_TESTS,
|
|
12
|
+
TELEMETRY_KNOWN_TESTS_RESPONSE_BYTES
|
|
13
|
+
} = require('../../ci-visibility/telemetry')
|
|
14
|
+
|
|
15
|
+
function getNumTests (knownTests) {
|
|
16
|
+
let totalNumTests = 0
|
|
17
|
+
|
|
18
|
+
for (const testModule of Object.values(knownTests)) {
|
|
19
|
+
for (const testSuite of Object.values(testModule)) {
|
|
20
|
+
for (const testList of Object.values(testSuite)) {
|
|
21
|
+
totalNumTests += testList.length
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return totalNumTests
|
|
27
|
+
}
|
|
3
28
|
|
|
4
29
|
function getKnownTests ({
|
|
5
30
|
url,
|
|
@@ -64,12 +89,26 @@ function getKnownTests ({
|
|
|
64
89
|
}
|
|
65
90
|
})
|
|
66
91
|
|
|
67
|
-
|
|
92
|
+
incrementCountMetric(TELEMETRY_KNOWN_TESTS)
|
|
93
|
+
|
|
94
|
+
const startTime = Date.now()
|
|
95
|
+
|
|
96
|
+
request(data, options, (err, res, statusCode) => {
|
|
97
|
+
distributionMetric(TELEMETRY_KNOWN_TESTS_MS, {}, Date.now() - startTime)
|
|
68
98
|
if (err) {
|
|
99
|
+
incrementCountMetric(TELEMETRY_KNOWN_TESTS_ERRORS, { statusCode })
|
|
69
100
|
done(err)
|
|
70
101
|
} else {
|
|
71
102
|
try {
|
|
72
103
|
const { data: { attributes: { tests: knownTests } } } = JSON.parse(res)
|
|
104
|
+
|
|
105
|
+
const numTests = getNumTests(knownTests)
|
|
106
|
+
|
|
107
|
+
incrementCountMetric(TELEMETRY_KNOWN_TESTS_RESPONSE_TESTS, {}, numTests)
|
|
108
|
+
distributionMetric(TELEMETRY_KNOWN_TESTS_RESPONSE_BYTES, {}, res.length)
|
|
109
|
+
|
|
110
|
+
log.debug(() => `Number of received known tests: ${numTests}`)
|
|
111
|
+
|
|
73
112
|
done(null, knownTests)
|
|
74
113
|
} catch (err) {
|
|
75
114
|
done(err)
|
|
@@ -12,8 +12,7 @@ const {
|
|
|
12
12
|
TELEMETRY_ENDPOINT_PAYLOAD_BYTES,
|
|
13
13
|
TELEMETRY_ENDPOINT_PAYLOAD_REQUESTS_MS,
|
|
14
14
|
TELEMETRY_ENDPOINT_PAYLOAD_REQUESTS_ERRORS,
|
|
15
|
-
TELEMETRY_ENDPOINT_PAYLOAD_DROPPED
|
|
16
|
-
getErrorTypeFromStatusCode
|
|
15
|
+
TELEMETRY_ENDPOINT_PAYLOAD_DROPPED
|
|
17
16
|
} = require('../../../ci-visibility/telemetry')
|
|
18
17
|
|
|
19
18
|
class Writer extends BaseWriter {
|
|
@@ -56,10 +55,9 @@ class Writer extends BaseWriter {
|
|
|
56
55
|
Date.now() - startRequestTime
|
|
57
56
|
)
|
|
58
57
|
if (err) {
|
|
59
|
-
const errorType = getErrorTypeFromStatusCode(statusCode)
|
|
60
58
|
incrementCountMetric(
|
|
61
59
|
TELEMETRY_ENDPOINT_PAYLOAD_REQUESTS_ERRORS,
|
|
62
|
-
{ endpoint: 'code_coverage',
|
|
60
|
+
{ endpoint: 'code_coverage', statusCode }
|
|
63
61
|
)
|
|
64
62
|
incrementCountMetric(
|
|
65
63
|
TELEMETRY_ENDPOINT_PAYLOAD_DROPPED,
|
|
@@ -12,8 +12,7 @@ const {
|
|
|
12
12
|
TELEMETRY_ENDPOINT_PAYLOAD_BYTES,
|
|
13
13
|
TELEMETRY_ENDPOINT_PAYLOAD_REQUESTS_MS,
|
|
14
14
|
TELEMETRY_ENDPOINT_PAYLOAD_REQUESTS_ERRORS,
|
|
15
|
-
TELEMETRY_ENDPOINT_PAYLOAD_DROPPED
|
|
16
|
-
getErrorTypeFromStatusCode
|
|
15
|
+
TELEMETRY_ENDPOINT_PAYLOAD_DROPPED
|
|
17
16
|
} = require('../../../ci-visibility/telemetry')
|
|
18
17
|
|
|
19
18
|
class Writer extends BaseWriter {
|
|
@@ -57,10 +56,9 @@ class Writer extends BaseWriter {
|
|
|
57
56
|
Date.now() - startRequestTime
|
|
58
57
|
)
|
|
59
58
|
if (err) {
|
|
60
|
-
const errorType = getErrorTypeFromStatusCode(statusCode)
|
|
61
59
|
incrementCountMetric(
|
|
62
60
|
TELEMETRY_ENDPOINT_PAYLOAD_REQUESTS_ERRORS,
|
|
63
|
-
{ endpoint: 'test_cycle',
|
|
61
|
+
{ endpoint: 'test_cycle', statusCode }
|
|
64
62
|
)
|
|
65
63
|
incrementCountMetric(
|
|
66
64
|
TELEMETRY_ENDPOINT_PAYLOAD_DROPPED,
|
|
@@ -11,7 +11,8 @@ const {
|
|
|
11
11
|
generatePackFilesForCommits,
|
|
12
12
|
getCommitsRevList,
|
|
13
13
|
isShallowRepository,
|
|
14
|
-
unshallowRepository
|
|
14
|
+
unshallowRepository,
|
|
15
|
+
isGitAvailable
|
|
15
16
|
} = require('../../../plugins/util/git')
|
|
16
17
|
|
|
17
18
|
const {
|
|
@@ -24,8 +25,7 @@ const {
|
|
|
24
25
|
TELEMETRY_GIT_REQUESTS_OBJECT_PACKFILES,
|
|
25
26
|
TELEMETRY_GIT_REQUESTS_OBJECT_PACKFILES_MS,
|
|
26
27
|
TELEMETRY_GIT_REQUESTS_OBJECT_PACKFILES_ERRORS,
|
|
27
|
-
TELEMETRY_GIT_REQUESTS_OBJECT_PACKFILES_BYTES
|
|
28
|
-
getErrorTypeFromStatusCode
|
|
28
|
+
TELEMETRY_GIT_REQUESTS_OBJECT_PACKFILES_BYTES
|
|
29
29
|
} = require('../../../ci-visibility/telemetry')
|
|
30
30
|
|
|
31
31
|
const isValidSha1 = (sha) => /^[0-9a-f]{40}$/.test(sha)
|
|
@@ -92,8 +92,7 @@ function getCommitsToUpload ({ url, repositoryUrl, latestCommits, isEvpProxy, ev
|
|
|
92
92
|
request(localCommitData, options, (err, response, statusCode) => {
|
|
93
93
|
distributionMetric(TELEMETRY_GIT_REQUESTS_SEARCH_COMMITS_MS, {}, Date.now() - startTime)
|
|
94
94
|
if (err) {
|
|
95
|
-
|
|
96
|
-
incrementCountMetric(TELEMETRY_GIT_REQUESTS_SEARCH_COMMITS_ERRORS, { errorType })
|
|
95
|
+
incrementCountMetric(TELEMETRY_GIT_REQUESTS_SEARCH_COMMITS_ERRORS, { statusCode })
|
|
97
96
|
const error = new Error(`Error fetching commits to exclude: ${err.message}`)
|
|
98
97
|
return callback(error)
|
|
99
98
|
}
|
|
@@ -178,8 +177,7 @@ function uploadPackFile ({ url, isEvpProxy, evpProxyPrefix, packFileToUpload, re
|
|
|
178
177
|
request(form, options, (err, _, statusCode) => {
|
|
179
178
|
distributionMetric(TELEMETRY_GIT_REQUESTS_OBJECT_PACKFILES_MS, {}, Date.now() - startTime)
|
|
180
179
|
if (err) {
|
|
181
|
-
|
|
182
|
-
incrementCountMetric(TELEMETRY_GIT_REQUESTS_OBJECT_PACKFILES_ERRORS, { errorType })
|
|
180
|
+
incrementCountMetric(TELEMETRY_GIT_REQUESTS_OBJECT_PACKFILES_ERRORS, { statusCode })
|
|
183
181
|
const error = new Error(`Could not upload packfiles: status code ${statusCode}: ${err.message}`)
|
|
184
182
|
return callback(error, uploadSize)
|
|
185
183
|
}
|
|
@@ -245,6 +243,9 @@ function generateAndUploadPackFiles ({
|
|
|
245
243
|
* This function uploads git metadata to CI Visibility's backend.
|
|
246
244
|
*/
|
|
247
245
|
function sendGitMetadata (url, { isEvpProxy, evpProxyPrefix }, configRepositoryUrl, callback) {
|
|
246
|
+
if (!isGitAvailable()) {
|
|
247
|
+
return callback(new Error('Git is not available'))
|
|
248
|
+
}
|
|
248
249
|
let repositoryUrl = configRepositoryUrl
|
|
249
250
|
if (!repositoryUrl) {
|
|
250
251
|
repositoryUrl = getRepositoryUrl()
|
|
@@ -8,8 +8,7 @@ const {
|
|
|
8
8
|
TELEMETRY_ITR_SKIPPABLE_TESTS_ERRORS,
|
|
9
9
|
TELEMETRY_ITR_SKIPPABLE_TESTS_RESPONSE_SUITES,
|
|
10
10
|
TELEMETRY_ITR_SKIPPABLE_TESTS_RESPONSE_TESTS,
|
|
11
|
-
TELEMETRY_ITR_SKIPPABLE_TESTS_RESPONSE_BYTES
|
|
12
|
-
getErrorTypeFromStatusCode
|
|
11
|
+
TELEMETRY_ITR_SKIPPABLE_TESTS_RESPONSE_BYTES
|
|
13
12
|
} = require('../../ci-visibility/telemetry')
|
|
14
13
|
|
|
15
14
|
function getSkippableSuites ({
|
|
@@ -83,8 +82,7 @@ function getSkippableSuites ({
|
|
|
83
82
|
request(data, options, (err, res, statusCode) => {
|
|
84
83
|
distributionMetric(TELEMETRY_ITR_SKIPPABLE_TESTS_MS, {}, Date.now() - startTime)
|
|
85
84
|
if (err) {
|
|
86
|
-
|
|
87
|
-
incrementCountMetric(TELEMETRY_ITR_SKIPPABLE_TESTS_ERRORS, { errorType })
|
|
85
|
+
incrementCountMetric(TELEMETRY_ITR_SKIPPABLE_TESTS_ERRORS, { statusCode })
|
|
88
86
|
done(err)
|
|
89
87
|
} else {
|
|
90
88
|
let skippableSuites = []
|
|
@@ -7,8 +7,7 @@ const {
|
|
|
7
7
|
TELEMETRY_GIT_REQUESTS_SETTINGS,
|
|
8
8
|
TELEMETRY_GIT_REQUESTS_SETTINGS_MS,
|
|
9
9
|
TELEMETRY_GIT_REQUESTS_SETTINGS_ERRORS,
|
|
10
|
-
TELEMETRY_GIT_REQUESTS_SETTINGS_RESPONSE
|
|
11
|
-
getErrorTypeFromStatusCode
|
|
10
|
+
TELEMETRY_GIT_REQUESTS_SETTINGS_RESPONSE
|
|
12
11
|
} = require('../telemetry')
|
|
13
12
|
|
|
14
13
|
const DEFAULT_EARLY_FLAKE_DETECTION_NUM_RETRIES = 2
|
|
@@ -81,8 +80,7 @@ function getLibraryConfiguration ({
|
|
|
81
80
|
request(data, options, (err, res, statusCode) => {
|
|
82
81
|
distributionMetric(TELEMETRY_GIT_REQUESTS_SETTINGS_MS, {}, Date.now() - startTime)
|
|
83
82
|
if (err) {
|
|
84
|
-
|
|
85
|
-
incrementCountMetric(TELEMETRY_GIT_REQUESTS_SETTINGS_ERRORS, { errorType })
|
|
83
|
+
incrementCountMetric(TELEMETRY_GIT_REQUESTS_SETTINGS_ERRORS, { statusCode })
|
|
86
84
|
done(err)
|
|
87
85
|
} else {
|
|
88
86
|
try {
|
|
@@ -10,13 +10,24 @@ const formattedTags = {
|
|
|
10
10
|
isCodeCoverageEnabled: 'coverage_enabled',
|
|
11
11
|
isSuitesSkippingEnabled: 'itrskip_enabled',
|
|
12
12
|
hasCodeOwners: 'has_code_owners',
|
|
13
|
-
isUnsupportedCIProvider: 'is_unsupported_ci'
|
|
13
|
+
isUnsupportedCIProvider: 'is_unsupported_ci',
|
|
14
|
+
isNew: 'is_new',
|
|
15
|
+
isRum: 'is_rum',
|
|
16
|
+
browserDriver: 'browser_driver'
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
// Transform tags dictionary to array of strings.
|
|
17
20
|
// If tag value is true, then only tag key is added to the array.
|
|
18
21
|
function formatMetricTags (tagsDictionary) {
|
|
19
22
|
return Object.keys(tagsDictionary).reduce((acc, tagKey) => {
|
|
23
|
+
if (tagKey === 'statusCode') {
|
|
24
|
+
const statusCode = tagsDictionary[tagKey]
|
|
25
|
+
if (isStatusCode400(statusCode)) {
|
|
26
|
+
acc.push(`status_code:${statusCode}`)
|
|
27
|
+
}
|
|
28
|
+
acc.push(`error_type:${getErrorTypeFromStatusCode(statusCode)}`)
|
|
29
|
+
return acc
|
|
30
|
+
}
|
|
20
31
|
const formattedTagKey = formattedTags[tagKey] || tagKey
|
|
21
32
|
if (tagsDictionary[tagKey] === true) {
|
|
22
33
|
acc.push(formattedTagKey)
|
|
@@ -36,6 +47,7 @@ function distributionMetric (name, tags, measure) {
|
|
|
36
47
|
}
|
|
37
48
|
|
|
38
49
|
// CI Visibility telemetry events
|
|
50
|
+
const TELEMETRY_TEST_SESSION = 'test_session'
|
|
39
51
|
const TELEMETRY_EVENT_CREATED = 'event_created'
|
|
40
52
|
const TELEMETRY_EVENT_FINISHED = 'event_finished'
|
|
41
53
|
const TELEMETRY_CODE_COVERAGE_STARTED = 'code_coverage_started'
|
|
@@ -74,6 +86,16 @@ const TELEMETRY_ITR_SKIPPABLE_TESTS_ERRORS = 'itr_skippable_tests.request_errors
|
|
|
74
86
|
const TELEMETRY_ITR_SKIPPABLE_TESTS_RESPONSE_SUITES = 'itr_skippable_tests.response_suites'
|
|
75
87
|
const TELEMETRY_ITR_SKIPPABLE_TESTS_RESPONSE_TESTS = 'itr_skippable_tests.response_tests'
|
|
76
88
|
const TELEMETRY_ITR_SKIPPABLE_TESTS_RESPONSE_BYTES = 'itr_skippable_tests.response_bytes'
|
|
89
|
+
// early flake detection
|
|
90
|
+
const TELEMETRY_KNOWN_TESTS = 'early_flake_detection.request'
|
|
91
|
+
const TELEMETRY_KNOWN_TESTS_MS = 'early_flake_detection.request_ms'
|
|
92
|
+
const TELEMETRY_KNOWN_TESTS_ERRORS = 'early_flake_detection.request_errors'
|
|
93
|
+
const TELEMETRY_KNOWN_TESTS_RESPONSE_TESTS = 'early_flake_detection.response_tests'
|
|
94
|
+
const TELEMETRY_KNOWN_TESTS_RESPONSE_BYTES = 'early_flake_detection.response_bytes'
|
|
95
|
+
|
|
96
|
+
function isStatusCode400 (statusCode) {
|
|
97
|
+
return statusCode >= 400 && statusCode < 500
|
|
98
|
+
}
|
|
77
99
|
|
|
78
100
|
function getErrorTypeFromStatusCode (statusCode) {
|
|
79
101
|
if (statusCode >= 400 && statusCode < 500) {
|
|
@@ -88,6 +110,7 @@ function getErrorTypeFromStatusCode (statusCode) {
|
|
|
88
110
|
module.exports = {
|
|
89
111
|
incrementCountMetric,
|
|
90
112
|
distributionMetric,
|
|
113
|
+
TELEMETRY_TEST_SESSION,
|
|
91
114
|
TELEMETRY_EVENT_CREATED,
|
|
92
115
|
TELEMETRY_EVENT_FINISHED,
|
|
93
116
|
TELEMETRY_CODE_COVERAGE_STARTED,
|
|
@@ -126,5 +149,9 @@ module.exports = {
|
|
|
126
149
|
TELEMETRY_ITR_SKIPPABLE_TESTS_RESPONSE_SUITES,
|
|
127
150
|
TELEMETRY_ITR_SKIPPABLE_TESTS_RESPONSE_TESTS,
|
|
128
151
|
TELEMETRY_ITR_SKIPPABLE_TESTS_RESPONSE_BYTES,
|
|
129
|
-
|
|
152
|
+
TELEMETRY_KNOWN_TESTS,
|
|
153
|
+
TELEMETRY_KNOWN_TESTS_MS,
|
|
154
|
+
TELEMETRY_KNOWN_TESTS_ERRORS,
|
|
155
|
+
TELEMETRY_KNOWN_TESTS_RESPONSE_TESTS,
|
|
156
|
+
TELEMETRY_KNOWN_TESTS_RESPONSE_BYTES
|
|
130
157
|
}
|