Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[test optimization] Fix session fingerprint in playwright #5273

Merged
merged 2 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading