Skip to content

Commit

Permalink
[test optimization] Fix session fingerprint in playwright (#5273)
Browse files Browse the repository at this point in the history
  • Loading branch information
juan-fernandez authored Feb 17, 2025
1 parent efb8e44 commit b599fab
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
10 changes: 8 additions & 2 deletions integration-tests/playwright/playwright.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ const {
TEST_SOURCE_START,
TEST_TYPE,
TEST_SOURCE_FILE,
TEST_CONFIGURATION_BROWSER_NAME,
TEST_PARAMETERS,
TEST_BROWSER_NAME,
TEST_IS_NEW,
TEST_IS_RETRY,
TEST_EARLY_FLAKE_ENABLED,
Expand Down Expand Up @@ -153,7 +154,12 @@ versions.forEach((version) => {
assert.propertyVal(testEvent.content.meta, 'test.customtag', 'customvalue')
assert.propertyVal(testEvent.content.meta, 'test.customtag2', 'customvalue2')
// Adds the browser used
assert.propertyVal(testEvent.content.meta, TEST_CONFIGURATION_BROWSER_NAME, 'chromium')
assert.propertyVal(testEvent.content.meta, TEST_BROWSER_NAME, 'chromium')
assert.propertyVal(
testEvent.content.meta,
TEST_PARAMETERS,
JSON.stringify({ arguments: { browser: 'chromium' }, metadata: {} })
)
assert.exists(testEvent.content.metrics[DD_HOST_CPU_COUNT])
})

Expand Down
9 changes: 6 additions & 3 deletions packages/datadog-plugin-playwright/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ const {
TEST_SOURCE_START,
TEST_CODE_OWNERS,
TEST_SOURCE_FILE,
TEST_CONFIGURATION_BROWSER_NAME,
TEST_PARAMETERS,
TEST_IS_NEW,
TEST_IS_RETRY,
TEST_EARLY_FLAKE_ENABLED,
TELEMETRY_TEST_SESSION,
TEST_RETRY_REASON
TEST_RETRY_REASON,
TEST_BROWSER_NAME
} = require('../../dd-trace/src/plugins/util/test')
const { RESOURCE_NAME } = require('../../../ext/tags')
const { COMPONENT } = require('../../dd-trace/src/constants')
Expand Down Expand Up @@ -202,7 +203,9 @@ class PlaywrightPlugin extends CiPlugin {
extraTags[TEST_SOURCE_FILE] = testSourceFile || testSuite
}
if (browserName) {
extraTags[TEST_CONFIGURATION_BROWSER_NAME] = browserName
// Added as parameter too because it should affect the test fingerprint
extraTags[TEST_PARAMETERS] = JSON.stringify({ arguments: { browser: browserName }, metadata: {} })
extraTags[TEST_BROWSER_NAME] = browserName
}

return super.startTestSpan(testName, testSuite, testSuiteSpan, extraTags)
Expand Down
3 changes: 0 additions & 3 deletions packages/dd-trace/src/plugins/util/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ const TEST_MODULE_ID = 'test_module_id'
const TEST_SUITE_ID = 'test_suite_id'
const TEST_TOOLCHAIN = 'test.toolchain'
const TEST_SKIPPED_BY_ITR = 'test.skipped_by_itr'
// Browser used in browser test. Namespaced by test.configuration because it affects the fingerprint
const TEST_CONFIGURATION_BROWSER_NAME = 'test.configuration.browser_name'
// Early flake detection
const TEST_IS_NEW = 'test.is_new'
const TEST_IS_RETRY = 'test.is_retry'
Expand Down Expand Up @@ -143,7 +141,6 @@ module.exports = {
MOCHA_WORKER_TRACE_PAYLOAD_CODE,
TEST_SOURCE_START,
TEST_SKIPPED_BY_ITR,
TEST_CONFIGURATION_BROWSER_NAME,
TEST_IS_NEW,
TEST_IS_RETRY,
TEST_EARLY_FLAKE_ENABLED,
Expand Down

0 comments on commit b599fab

Please sign in to comment.