Skip to content

Commit

Permalink
even more logs
Browse files Browse the repository at this point in the history
  • Loading branch information
juan-fernandez committed Jan 30, 2025
1 parent d6ef951 commit 4017446
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
14 changes: 12 additions & 2 deletions packages/datadog-instrumentations/src/jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,19 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
const asyncResource = asyncResources.get(event.test)

if (status === 'fail') {
log.warn('Setting probe because test failed')
const shouldSetProbe = this.isDiEnabled && willBeRetried && numTestExecutions === 1
log.warn(
`Setting probe because test failed: ${getJestTestName(event.test)},
num test executions: ${numTestExecutions}
will be retried: ${willBeRetried}
is di enabled: ${this.isDiEnabled}
should set probe: ${shouldSetProbe}
`
)
asyncResource.runInAsyncScope(() => {
testErrCh.publish({
error: formatJestError(event.test.errors[0]),
shouldSetProbe: this.isDiEnabled && willBeRetried && numTestExecutions === 1,
shouldSetProbe,
promises
})
})
Expand All @@ -333,7 +341,9 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
})
}

const shouldRemoveProbe = this.isDiEnabled && !willBeRetried
asyncResource.runInAsyncScope(() => {
log.warn(`shouldRemoveProbe: ${shouldRemoveProbe}`)
testFinishCh.publish({
status,
testStartLine: getTestLineStart(event.test.asyncError, this.testSuite),
Expand Down
4 changes: 3 additions & 1 deletion packages/datadog-plugin-jest/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const {
TEST_IS_RUM_ACTIVE,
TEST_BROWSER_DRIVER,
getFormattedError,
TEST_RETRY_REASON
TEST_RETRY_REASON,
TEST_NAME
} = require('../../dd-trace/src/plugins/util/test')
const { COMPONENT } = require('../../dd-trace/src/constants')
const id = require('../../dd-trace/src/id')
Expand Down Expand Up @@ -348,6 +349,7 @@ class JestPlugin extends CiPlugin {
finishAllTraceSpans(span)
this.activeTestSpan = null
if (shouldRemoveProbe && this.runningTestProbeId) {
log.warn(`ci:jest:test:finish removing probe ${spanTags[TEST_NAME]}`)
promises.isProbeRemoved = withTimeout(this.removeDiProbe(this.runningTestProbeId), 2000)
this.runningTestProbeId = null
}
Expand Down

0 comments on commit 4017446

Please sign in to comment.