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

Add node: prefix to Node.js built-in imports #4593

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion benchmark/e2e-ci/benchmark-run.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/* eslint-disable no-console */

const https = require('https')
const https = require('node:https')

const API_REPOSITORY_URL = 'https://api.github.com/repos/DataDog/test-environment'
const DISPATCH_WORKFLOW_URL = `${API_REPOSITORY_URL}/actions/workflows/dd-trace-js-tests.yml/dispatches`
Expand Down
10 changes: 5 additions & 5 deletions benchmark/e2e/benchmark-run.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

/* eslint-disable no-console */

const { spawn, fork } = require('child_process')
const { promisify } = require('util')
const { stat } = require('fs')
const { get: _get } = require('http')
const path = require('path')
const { spawn, fork } = require('node:child_process')
const { promisify } = require('node:util')
const { stat } = require('node:fs')
const { get: _get } = require('node:http')
const path = require('node:path')
const mongoService = require('../../packages/dd-trace/test/setup/services/mongo')
const autocannon = require('autocannon')
const { chdir: cd } = process
Expand Down
2 changes: 1 addition & 1 deletion benchmark/e2e/express-helloworld-manyroutes/app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const crypto = require('crypto')
const crypto = require('node:crypto')
const app = require('express')()

for (let i = 0; i < 100; i++) {
Expand Down
2 changes: 1 addition & 1 deletion benchmark/e2e/fake-agent.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict'
const http = require('http')
const http = require('node:http')

http.createServer(async (req, res) => {
res.statusCode = 200
Expand Down
4 changes: 2 additions & 2 deletions benchmark/e2e/preamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
if (process.env.DD_BENCH_TRACE_ENABLE) {
require('../..').init({})
} else if (process.env.DD_BENCH_ASYNC_HOOKS) {
const asyncHooks = require('async_hooks')
const asyncHooks = require('node:async_hooks')
const hook = asyncHooks.createHook({
init () {},
before () {},
Expand All @@ -12,7 +12,7 @@ if (process.env.DD_BENCH_TRACE_ENABLE) {
})
hook.enable()
}
const { Server } = require('http')
const { Server } = require('node:http')
const origEmit = Server.prototype.emit
Server.prototype.emit = function (name) {
if (name === 'listening') { process.send && process.send({ ready: true }) }
Expand Down
2 changes: 1 addition & 1 deletion benchmark/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const execSync = require('child_process').execSync
const execSync = require('node:child_process').execSync
const exec = cmd => execSync(cmd, { stdio: [0, 1, 2] })

exec('node benchmark/core')
Expand Down
4 changes: 2 additions & 2 deletions benchmark/profiler/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const axios = require('axios')
const chalk = require('chalk')
const getPort = require('get-port')
const Table = require('cli-table3')
const URL = require('url').URL
const { spawn } = require('child_process')
const URL = require('node:url').URL
const { spawn } = require('node:child_process')

main()

Expand Down
2 changes: 1 addition & 1 deletion benchmark/scope.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const { AsyncResource } = require('async_hooks')
const { AsyncResource } = require('node:async_hooks')

const benchmark = require('./benchmark')

Expand Down
4 changes: 2 additions & 2 deletions benchmark/sirun/aggregate.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const fs = require('fs')
const path = require('path')
const fs = require('node:fs')
const path = require('node:path')
const { summarizeResults } = require('./get-results')

const jsons = []
Expand Down
2 changes: 1 addition & 1 deletion benchmark/sirun/appsec-iast/client.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const { port, reqs } = require('./common')
const http = require('http')
const http = require('node:http')

let connectionsMade = 0
function request (opts) {
Expand Down
2 changes: 1 addition & 1 deletion benchmark/sirun/appsec-iast/insecure-bank.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const http = require('http')
const http = require('node:http')
const app = require('/opt/insecure-bank-js/app')

const { port } = require('./common')
Expand Down
2 changes: 1 addition & 1 deletion benchmark/sirun/appsec-iast/server-with-vulnerability.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const { port, reqs } = require('./common')
const express = require('../../../versions/express').get()
const cookieParser = require('../../../versions/cookie-parser').get()
const childProcess = require('child_process')
const childProcess = require('node:child_process')

const app = express()
app.use(cookieParser())
Expand Down
2 changes: 1 addition & 1 deletion benchmark/sirun/appsec/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const { port, reqs } = require('./common')

const http = require('http')
const http = require('node:http')
let connectionsMade = 0

function request (opts) {
Expand Down
2 changes: 1 addition & 1 deletion benchmark/sirun/appsec/insecure-bank.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const http = require('http')
const http = require('node:http')
const app = require('/opt/insecure-bank-js/app')

const { port } = require('./common')
Expand Down
2 changes: 1 addition & 1 deletion benchmark/sirun/appsec/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ require('../../..').init()

const { port, reqs } = require('./common')

const http = require('http')
const http = require('node:http')

let connectionsMade = 0

Expand Down
2 changes: 1 addition & 1 deletion benchmark/sirun/async_hooks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const PROMISES_PER_INTERVAL = process.env.PROMISES_PER_INTERVAL || 100000
const INTERVALS = process.env.INTERVALS || 10

if (ASYNC_HOOKS) {
const { createHook } = require('async_hooks')
const { createHook } = require('node:async_hooks')

const hooks = {}

Expand Down
6 changes: 3 additions & 3 deletions benchmark/sirun/diff-recent.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

/* eslint-disable no-console */

const fs = require('fs')
const path = require('path')
const { execSync } = require('child_process')
const fs = require('node:fs')
const path = require('node:path')
const { execSync } = require('node:child_process')
const walk = require('./results-diff')
const {
getBuildNumsFromGithub,
Expand Down
4 changes: 2 additions & 2 deletions benchmark/sirun/diffserver.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict'

const express = require('express')
const path = require('path')
const fs = require('fs')
const path = require('node:path')
const fs = require('node:fs')
const diffRecent = require('./diff-recent')
const {
getBuildNumsFromGithub,
Expand Down
2 changes: 1 addition & 1 deletion benchmark/sirun/event_loop.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const { monitorEventLoopDelay } = require('perf_hooks')
const { monitorEventLoopDelay } = require('node:perf_hooks')
const StatsD = require('./statsd')
const statsd = new StatsD()

Expand Down
2 changes: 1 addition & 1 deletion benchmark/sirun/exporting-pipeline/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const SpanProcessor = require('../../../packages/dd-trace/src/span_processor')
const Exporter = require('../../../packages/dd-trace/src/exporters/agent/index')
const PrioritySampler = require('../../../packages/dd-trace/src/priority_sampler')
const id = require('../../../packages/dd-trace/src/id')
const hostname = require('os').hostname()
const hostname = require('node:os').hostname()

const config = {
url: 'http://localhost:8126',
Expand Down
2 changes: 1 addition & 1 deletion benchmark/sirun/gc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { createHistogram, PerformanceObserver } = require('perf_hooks')
const { createHistogram, PerformanceObserver } = require('node:perf_hooks')
if (createHistogram) {
const StatsD = require('./statsd')
const statsd = new StatsD()
Expand Down
4 changes: 2 additions & 2 deletions benchmark/sirun/get-results.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

/* eslint-disable no-console */

const https = require('https')
const { execSync } = require('child_process')
const https = require('node:https')
const { execSync } = require('node:child_process')

const { CIRCLE_TOKEN, GITHUB_STATUS_TOKEN } = process.env

Expand Down
2 changes: 1 addition & 1 deletion benchmark/sirun/get-variants.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

'use strict'

const path = require('path')
const path = require('node:path')
const metaJson = require(path.join(process.cwd(), 'meta.json'))
const variants = Object.keys(metaJson.variants)

Expand Down
2 changes: 1 addition & 1 deletion benchmark/sirun/plugin-dns/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if (Number(process.env.USE_TRACER)) {
require('../../..').init()
}

const dns = require('dns')
const dns = require('node:dns')

function testRun (count) {
if (++count === 1000) return
Expand Down
2 changes: 1 addition & 1 deletion benchmark/sirun/plugin-graphql/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if (Number(process.env.WITH_ASYNC_HOOKS)) {
? { init () {} }
: { init () {}, before () {}, after () {}, destroy () {} }

require('async_hooks').createHook(hook).enable()
require('node:async_hooks').createHook(hook).enable()
}

const graphql = require('../../../versions/graphql').get()
Expand Down
2 changes: 1 addition & 1 deletion benchmark/sirun/plugin-http/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if (Number(process.env.CLIENT_USE_TRACER)) {

const { port, reqs } = require('./common')

const http = require('http')
const http = require('node:http')
let connectionsMade = 0

function request (url) {
Expand Down
2 changes: 1 addition & 1 deletion benchmark/sirun/plugin-http/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if (Number(process.env.SERVER_USE_TRACER)) {

const { port, reqs } = require('./common')

const http = require('http')
const http = require('node:http')

let connectionsMade = 0

Expand Down
2 changes: 1 addition & 1 deletion benchmark/sirun/plugin-net/client.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const net = require('net')
const net = require('node:net')

const { port, reqs } = require('./common')

Expand Down
2 changes: 1 addition & 1 deletion benchmark/sirun/plugin-net/server.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const net = require('net')
const net = require('node:net')
const { port, reqs } = require('./common')

let connectionsMade = 0
Expand Down
4 changes: 2 additions & 2 deletions benchmark/sirun/run-all-variants.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

'use strict'

const fs = require('fs')
const path = require('path')
const fs = require('node:fs')
const path = require('node:path')
const { exec, getStdio } = require('./run-util')

process.env.DD_INSTRUMENTATION_TELEMETRY_ENABLED = 'false'
Expand Down
2 changes: 1 addition & 1 deletion benchmark/sirun/run-util.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const childProcess = require('child_process')
const childProcess = require('node:child_process')
const readline = require('readline')

function exec (...args) {
Expand Down
4 changes: 2 additions & 2 deletions benchmark/sirun/squash-affinity.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

'use strict'

const fs = require('fs')
const path = require('path')
const fs = require('node:fs')
const path = require('node:path')

const metaJson = require(path.join(process.cwd(), 'meta.json'))

Expand Down
2 changes: 1 addition & 1 deletion benchmark/sirun/statsd.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const dgram = require('dgram')
const dgram = require('node:dgram')
const port = process.env.SIRUN_STATSD_PORT || 8125

class StatsD {
Expand Down
4 changes: 2 additions & 2 deletions benchmark/sirun/strip-unwanted-results.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node

const fs = require('fs')
const path = require('path')
const fs = require('node:fs')
const path = require('node:path')

const IGNORE_TESTS = new Set([
'profiler'
Expand Down
4 changes: 2 additions & 2 deletions init.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const path = require('path')
const Module = require('module')
const path = require('node:path')
const Module = require('node:module')
const semver = require('semver')
const log = require('./packages/dd-trace/src/log')
const { isTrue } = require('./packages/dd-trace/src/util')
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/appsec/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const getPort = require('get-port')
const path = require('path')
const path = require('node:path')
const Axios = require('axios')
const { assert } = require('chai')
const { createSandbox, FakeAgent, spawnProc } = require('../helpers')
Expand Down
6 changes: 3 additions & 3 deletions integration-tests/appsec/rasp/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ tracer.init({
flushInterval: 0
})

const path = require('path')
const fs = require('fs')
const http = require('https')
const path = require('node:path')
const fs = require('node:fs')
const http = require('node:https')
const express = require('express')
const axios = require('axios')

Expand Down
4 changes: 2 additions & 2 deletions integration-tests/ci-visibility-intake.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ const express = require('express')
const bodyParser = require('body-parser')
const msgpack = require('msgpack-lite')
const codec = msgpack.createCodec({ int64: true })
const http = require('http')
const http = require('node:http')
const multer = require('multer')
const upload = multer()
const zlib = require('zlib')
const zlib = require('node:zlib')

const { FakeAgent } = require('./helpers')

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const assert = require('assert')
const assert = require('node:assert')
const { When, Then } = require('@cucumber/cucumber')

let globalCounter = 0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const assert = require('assert')
const assert = require('node:assert')
const { When, Then } = require('@cucumber/cucumber')

let globalCounter = 0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const assert = require('assert')
const assert = require('node:assert')
const { When, Then, Before } = require('@cucumber/cucumber')
class Greeter {
sayFarewell () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const assert = require('assert')
const assert = require('node:assert')
const { When, Then } = require('@cucumber/cucumber')
class Greeter {
sayGreetings () {
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/ci-visibility/web-app-server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// File to spin an HTTP server that returns an HTML for playwright to visit
const http = require('http')
const http = require('node:http')
const coverage = require('../ci-visibility/fixtures/coverage.json')

module.exports = http.createServer((req, res) => {
Expand Down
Loading
Loading