Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
4 changes: 2 additions & 2 deletions integration-tests/playwright/playwright.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const {
} = require('../helpers')
const { FakeCiVisIntake } = require('../ci-visibility-intake')
const webAppServer = require('../ci-visibility/web-app-server')
const { TEST_STATUS, TEST_SOURCE_START } = require('../../packages/dd-trace/src/plugins/util/test')
const { TEST_STATUS, TEST_SOURCE_START, TEST_TYPE } = require('../../packages/dd-trace/src/plugins/util/test')

// TODO: remove when 2.x support is removed.
// This is done because from playwright@>=1.22.0 node 12 is not supported
Expand Down Expand Up @@ -73,7 +73,7 @@ versions.forEach((version) => {
assert.equal(testSessionEvent.content.meta[TEST_STATUS], 'fail')
assert.include(testModuleEvent.content.resource, 'test_module.playwright test')
assert.equal(testModuleEvent.content.meta[TEST_STATUS], 'fail')

assert.equal(testSessionEvent.content.meta[TEST_TYPE], 'browser')
assert.includeMembers(testSuiteEvents.map(suite => suite.content.resource), [
'test_suite.todo-list-page-test.js',
'test_suite.landing-page-test.js',
Expand Down
2 changes: 1 addition & 1 deletion packages/datadog-plugin-cypress/src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const CYPRESS_STATUS_TO_TEST_STATUS = {
function getTestSpanMetadata (tracer, testName, testSuite, cypressConfig) {
const childOf = getTestParentSpan(tracer)

const commonTags = getTestCommonTags(testName, testSuite, cypressConfig.version)
const commonTags = getTestCommonTags(testName, testSuite, cypressConfig.version, TEST_FRAMEWORK_NAME)

return {
childOf,
Expand Down
4 changes: 2 additions & 2 deletions packages/datadog-plugin-cypress/test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe('Plugin', function () {
[TEST_STATUS]: 'pass',
[TEST_SUITE]: 'cypress/integration/integration-test.js',
[TEST_SOURCE_FILE]: 'cypress/integration/integration-test.js',
[TEST_TYPE]: 'test',
[TEST_TYPE]: 'browser',
[ORIGIN_KEY]: CI_APP_ORIGIN,
[TEST_IS_RUM_ACTIVE]: 'true',
[TEST_CODE_OWNERS]: JSON.stringify(['@datadog']),
Expand All @@ -103,7 +103,7 @@ describe('Plugin', function () {
[TEST_STATUS]: 'fail',
[TEST_SUITE]: 'cypress/integration/integration-test.js',
[TEST_SOURCE_FILE]: 'cypress/integration/integration-test.js',
[TEST_TYPE]: 'test',
[TEST_TYPE]: 'browser',
[ORIGIN_KEY]: CI_APP_ORIGIN,
[ERROR_TYPE]: 'AssertionError',
[TEST_IS_RUM_ACTIVE]: 'true',
Expand Down
7 changes: 6 additions & 1 deletion packages/dd-trace/src/plugins/ci_plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,12 @@ module.exports = class CiPlugin extends Plugin {
const childOf = getTestParentSpan(this.tracer)

let testTags = {
...getTestCommonTags(testName, testSuite, this.frameworkVersion),
...getTestCommonTags(
testName,
testSuite,
this.frameworkVersion,
this.constructor.id
),
[COMPONENT]: this.constructor.id,
...extraTags
}
Expand Down
11 changes: 9 additions & 2 deletions packages/dd-trace/src/plugins/util/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@ function getTestParametersString (parametersByTestName, testName) {
}
}

function getTestTypeFromFramework (testFramework) {
if (testFramework.includes('playwright') || testFramework.includes('cypress')) {
return 'browser'
}
return 'test'
}

function finishAllTraceSpans (span) {
span.context()._trace.started.forEach(traceSpan => {
if (traceSpan !== span) {
Expand All @@ -188,10 +195,10 @@ function getTestParentSpan (tracer) {
})
}

function getTestCommonTags (name, suite, version) {
function getTestCommonTags (name, suite, version, testFramework) {
return {
[SPAN_TYPE]: 'test',
[TEST_TYPE]: 'test',
[TEST_TYPE]: getTestTypeFromFramework(testFramework),
[SAMPLING_RULE_DECISION]: 1,
[SAMPLING_PRIORITY]: AUTO_KEEP,
[TEST_NAME]: name,
Expand Down