Skip to content

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
watson committed Feb 19, 2025
1 parent 55eed03 commit 8a0931a
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ addHook({ name: 'apollo-server-core', file: 'dist/runHttpQuery.js', versions: ['
const HttpQueryError = runHttpQueryModule.HttpQueryError

shimmer.wrap(runHttpQueryModule, 'runHttpQuery', function wrapRunHttpQuery (originalRunHttpQuery) {
// The original function is async, but no need to mark it as such as long as it returns a promise
return function runHttpQuery () {
if (!requestChannel.start.hasSubscribers) {
return originalRunHttpQuery.apply(this, arguments)
Expand Down
1 change: 1 addition & 0 deletions packages/datadog-instrumentations/src/apollo-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const requestChannel = dc.tracingChannel('datadog:apollo:request')
let HeaderMap

function wrapExecuteHTTPGraphQLRequest (originalExecuteHTTPGraphQLRequest) {
// The original function is async, but no need to mark it as such as long as it returns a promise
return function executeHTTPGraphQLRequest () {
if (!HeaderMap || !requestChannel.start.hasSubscribers) {
return originalExecuteHTTPGraphQLRequest.apply(this, arguments)
Expand Down
3 changes: 3 additions & 0 deletions packages/datadog-instrumentations/src/jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ addHook({
}, getTestEnvironment)

function getWrappedScheduleTests (scheduleTests, frameworkVersion) {
// The original function is async, but no need to mark it as such as long as it returns a promise
return function (tests) {
if (!isSuitesSkippingEnabled || hasFilteredSkippableSuites) {
return scheduleTests.apply(this, arguments)
Expand Down Expand Up @@ -741,6 +742,7 @@ function coverageReporterWrapper (coverageReporter) {
* This calculation adds no value, so we'll skip it, as long as the user has not manually opted in to code coverage,
* in which case we'll leave it.
*/
// The original function is async, but no need to mark it as such as long as it returns a promise
shimmer.wrap(CoverageReporter.prototype, '_addUntestedFiles', addUntestedFiles => function () {
// If the user has added coverage manually, they're willing to pay the price of this execution, so
// we will not skip it.
Expand Down Expand Up @@ -898,6 +900,7 @@ addHook({
}, transformPackage => {
const originalCreateScriptTransformer = transformPackage.createScriptTransformer

// The original function is async, but no need to mark it as such as long as it returns a promise
transformPackage.createScriptTransformer = function (config) {
const { testEnvironmentOptions, ...restOfConfig } = config
const {
Expand Down
1 change: 1 addition & 0 deletions packages/datadog-instrumentations/src/mocha/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ addHook({
versions: ['>=5.2.0'],
file: 'lib/cli/run-helpers.js'
}, (run) => {
// The original function is async, but no need to mark it as such as long as it returns a promise
shimmer.wrap(run, 'runMocha', runMocha => function () {
if (!testStartCh.hasSubscribers) {
return runMocha.apply(this, arguments)
Expand Down
1 change: 1 addition & 0 deletions packages/datadog-instrumentations/src/nyc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ addHook({
name: 'nyc',
versions: ['>=17']
}, (nycPackage) => {
// The original function is async, but no need to mark it as such as long as it returns a promise
shimmer.wrap(nycPackage.prototype, 'wrap', wrap => function () {
// Only relevant if the config `all` is set to true
try {
Expand Down
2 changes: 2 additions & 0 deletions packages/datadog-instrumentations/src/vitest.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ addHook({
const { VitestTestRunner } = vitestPackage

// `onBeforeRunTask` is run before any repetition or attempt is run
// The original function is async, but no need to mark it as such as long as it returns a promise
shimmer.wrap(VitestTestRunner.prototype, 'onBeforeRunTask', onBeforeRunTask => function (task) {
const testName = getTestName(task)

Expand Down Expand Up @@ -361,6 +362,7 @@ addHook({
})

// `onAfterRunTask` is run after all repetitions or attempts are run
// The original function is async, but no need to mark it as such as long as it returns a promise
shimmer.wrap(VitestTestRunner.prototype, 'onAfterRunTask', onAfterRunTask => function (task) {
const { isEarlyFlakeDetectionEnabled, isQuarantinedTestsEnabled } = getProvidedContext()

Expand Down

0 comments on commit 8a0931a

Please sign in to comment.