dd-trace 4.30.0 → 4.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/index.d.ts +39 -0
  2. package/package.json +2 -2
  3. package/packages/datadog-instrumentations/src/apollo.js +101 -0
  4. package/packages/datadog-instrumentations/src/helpers/hooks.js +1 -0
  5. package/packages/datadog-instrumentations/src/mongodb-core.js +1 -3
  6. package/packages/datadog-instrumentations/src/playwright.js +151 -6
  7. package/packages/datadog-plugin-apollo/src/gateway/execute.js +12 -0
  8. package/packages/datadog-plugin-apollo/src/gateway/fetch.js +36 -0
  9. package/packages/datadog-plugin-apollo/src/gateway/index.js +36 -0
  10. package/packages/datadog-plugin-apollo/src/gateway/plan.js +13 -0
  11. package/packages/datadog-plugin-apollo/src/gateway/postprocessing.js +12 -0
  12. package/packages/datadog-plugin-apollo/src/gateway/request.js +139 -0
  13. package/packages/datadog-plugin-apollo/src/gateway/validate.js +21 -0
  14. package/packages/datadog-plugin-apollo/src/index.js +15 -0
  15. package/packages/datadog-plugin-cucumber/src/index.js +2 -2
  16. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +2 -2
  17. package/packages/datadog-plugin-jest/src/index.js +2 -2
  18. package/packages/datadog-plugin-mocha/src/index.js +2 -2
  19. package/packages/datadog-plugin-playwright/src/index.js +10 -2
  20. package/packages/dd-trace/src/appsec/iast/iast-plugin.js +23 -12
  21. package/packages/dd-trace/src/appsec/iast/path-line.js +9 -6
  22. package/packages/dd-trace/src/appsec/iast/taint-tracking/operations.js +1 -1
  23. package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +6 -2
  24. package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter-telemetry.js +1 -1
  25. package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +6 -7
  26. package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +1 -1
  27. package/packages/dd-trace/src/appsec/iast/telemetry/iast-metric.js +34 -27
  28. package/packages/dd-trace/src/appsec/iast/telemetry/namespaces.js +39 -11
  29. package/packages/dd-trace/src/appsec/iast/telemetry/span-tags.js +7 -6
  30. package/packages/dd-trace/src/appsec/reporter.js +24 -11
  31. package/packages/dd-trace/src/ci-visibility/exporters/agent-proxy/index.js +6 -1
  32. package/packages/dd-trace/src/lambda/runtime/ritm.js +1 -1
  33. package/packages/dd-trace/src/opentracing/propagation/text_map.js +21 -2
  34. package/packages/dd-trace/src/opentracing/span.js +2 -0
  35. package/packages/dd-trace/src/opentracing/span_context.js +1 -0
  36. package/packages/dd-trace/src/plugin_manager.js +1 -2
  37. package/packages/dd-trace/src/plugins/apollo.js +50 -0
  38. package/packages/dd-trace/src/plugins/composite.js +1 -0
  39. package/packages/dd-trace/src/plugins/index.js +1 -0
  40. package/packages/dd-trace/src/plugins/tracing.js +8 -5
  41. package/packages/dd-trace/src/plugins/util/test.js +2 -2
  42. package/packages/dd-trace/src/priority_sampler.js +11 -6
  43. package/packages/dd-trace/src/profiling/profilers/events.js +79 -82
  44. package/packages/dd-trace/src/proxy.js +2 -0
  45. package/packages/dd-trace/src/service-naming/schemas/v0/web.js +24 -0
  46. package/packages/dd-trace/src/service-naming/schemas/v1/web.js +24 -0
  47. package/packages/dd-trace/src/telemetry/index.js +15 -4
  48. package/CONTRIBUTING.md +0 -171
  49. package/MIGRATING.md +0 -224
  50. package/packages/dd-trace/src/external-logger/test/index.spec.js +0 -147
  51. package/scripts/check-proposal-labels.js +0 -71
  52. package/scripts/check_licenses.js +0 -69
  53. package/scripts/helpers/color.js +0 -8
  54. package/scripts/helpers/exec.js +0 -22
  55. package/scripts/helpers/title.js +0 -15
  56. package/scripts/install_plugin_modules.js +0 -248
  57. package/scripts/publish_docs.js +0 -21
  58. package/scripts/st.js +0 -105
@@ -1,8 +0,0 @@
1
- 'use strict'
2
-
3
- // https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
4
- module.exports = {
5
- GRAY: '\\033[1;90m',
6
- CYAN: '\\033[1;36m',
7
- NONE: '\\033[0m'
8
- }
@@ -1,22 +0,0 @@
1
- 'use strict'
2
-
3
- const execSync = require('child_process').execSync
4
- const color = require('./color')
5
-
6
- function exec (command, options) {
7
- options = Object.assign({ stdio: [0, 1, 2] }, options)
8
-
9
- execSync(`echo "${color.GRAY}$ ${command}${color.NONE}"`, { stdio: [0, 1, 2] })
10
-
11
- return execSync(command, options)
12
- }
13
-
14
- function pipe (command, options) {
15
- return exec(command, Object.assign({ stdio: 'pipe' }, options))
16
- .toString()
17
- .replace(/\n$/, '')
18
- }
19
-
20
- exec.pipe = pipe
21
-
22
- module.exports = exec
@@ -1,15 +0,0 @@
1
- 'use strict'
2
-
3
- const exec = require('child_process').execSync
4
- const color = require('./color')
5
-
6
- function title (str) {
7
- const options = { stdio: [0, 1, 2] }
8
- const line = ''.padStart(str.length, '=')
9
-
10
- exec(`echo "${color.CYAN}${line}${color.NONE}"`, options)
11
- exec(`echo "${color.CYAN}${str}${color.NONE}"`, options)
12
- exec(`echo "${color.CYAN}${line}${color.NONE}"`, options)
13
- }
14
-
15
- module.exports = title
@@ -1,248 +0,0 @@
1
- 'use strict'
2
-
3
- const fs = require('fs')
4
- const os = require('os')
5
- const path = require('path')
6
- const crypto = require('crypto')
7
- const semver = require('semver')
8
- const proxyquire = require('proxyquire')
9
- const exec = require('./helpers/exec')
10
- const childProcess = require('child_process')
11
- const externals = require('../packages/dd-trace/test/plugins/externals')
12
-
13
- const requirePackageJsonPath = require.resolve('../packages/dd-trace/src/require-package-json')
14
-
15
- // Can remove couchbase after removing support for couchbase <= 3.2.0
16
- const excludeList = os.arch() === 'arm64' ? ['couchbase', 'grpc', 'oracledb'] : []
17
- const workspaces = new Set()
18
- const versionLists = {}
19
- const deps = {}
20
- const names = []
21
- const filter = process.env.hasOwnProperty('PLUGINS') && process.env.PLUGINS.split('|')
22
-
23
- Object.keys(externals).forEach(external => externals[external].forEach(thing => {
24
- if (thing.dep) {
25
- if (!deps[external]) {
26
- deps[external] = []
27
- }
28
- deps[external].push(thing.name)
29
- }
30
- }))
31
-
32
- fs.readdirSync(path.join(__dirname, '../packages/datadog-instrumentations/src'))
33
- .filter(file => file.endsWith('js'))
34
- .forEach(file => {
35
- file = file.replace('.js', '')
36
-
37
- if (!filter || filter.includes(file)) {
38
- names.push(file)
39
- }
40
- })
41
-
42
- run()
43
-
44
- async function run () {
45
- assertFolder()
46
- await assertVersions()
47
- assertWorkspace()
48
- // Some native addon packages rely on libraries that are not supported on ARM64
49
- excludeList.forEach(pkg => delete workspaces[pkg])
50
- install()
51
- }
52
-
53
- async function assertVersions () {
54
- const internals = names
55
- .map(key => {
56
- const instrumentations = []
57
- const name = key
58
-
59
- try {
60
- loadInstFile(`${name}/server.js`, instrumentations)
61
- loadInstFile(`${name}/client.js`, instrumentations)
62
- } catch (e) {
63
- loadInstFile(`${name}.js`, instrumentations)
64
- }
65
-
66
- return instrumentations
67
- })
68
- .reduce((prev, next) => prev.concat(next), [])
69
-
70
- for (const inst of internals) {
71
- await assertInstrumentation(inst, false)
72
- }
73
-
74
- const externalNames = Object.keys(externals).filter(name => ~names.indexOf(name))
75
- for (const name of externalNames) {
76
- for (const inst of [].concat(externals[name])) {
77
- await assertInstrumentation(inst, true)
78
- }
79
- }
80
- }
81
-
82
- async function assertInstrumentation (instrumentation, external) {
83
- const versions = process.env.PACKAGE_VERSION_RANGE ? [process.env.PACKAGE_VERSION_RANGE]
84
- : [].concat(instrumentation.versions || [])
85
-
86
- for (const version of versions) {
87
- if (version) {
88
- await assertModules(instrumentation.name, semver.coerce(version).version, external)
89
- await assertModules(instrumentation.name, version, external)
90
- }
91
- }
92
- }
93
-
94
- async function assertModules (name, version, external) {
95
- const range = process.env.RANGE
96
- if (range && !semver.subset(version, range)) return
97
- addFolder(name)
98
- addFolder(name, version)
99
- assertFolder(name)
100
- assertFolder(name, version)
101
- await assertPackage(name, null, version, external)
102
- await assertPackage(name, version, version, external)
103
- assertIndex(name)
104
- assertIndex(name, version)
105
- }
106
-
107
- function assertFolder (name, version) {
108
- if (!fs.existsSync(folder())) {
109
- fs.mkdirSync(folder())
110
- }
111
-
112
- if (name && name.includes(path.sep)) {
113
- name.split(path.sep).reduce(parent => assertFolder(parent))
114
- }
115
-
116
- if (!fs.existsSync(folder(name, version))) {
117
- fs.mkdirSync(folder(name, version))
118
- }
119
- }
120
-
121
- async function assertPackage (name, version, dependency, external) {
122
- const dependencies = { [name]: dependency }
123
- if (deps[name]) {
124
- await addDependencies(dependencies, name, dependency)
125
- }
126
- const pkg = {
127
- name: [name, sha1(name).substr(0, 8), sha1(version)].filter(val => val).join('-'),
128
- version: '1.0.0',
129
- license: 'BSD-3-Clause',
130
- private: true,
131
- dependencies
132
- }
133
-
134
- if (!external) {
135
- if (name === 'aerospike') {
136
- pkg.installConfig = {
137
- 'hoistingLimits': 'workspaces'
138
- }
139
- } else {
140
- pkg.workspaces = {
141
- nohoist: ['**/**']
142
- }
143
- }
144
- }
145
- fs.writeFileSync(filename(name, version, 'package.json'), JSON.stringify(pkg, null, 2) + '\n')
146
- }
147
-
148
- async function addDependencies (dependencies, name, versionRange) {
149
- const versionList = await getVersionList(name)
150
- const version = semver.maxSatisfying(versionList, versionRange)
151
- const pkgJson = await npmView(`${name}@${version}`)
152
- for (const dep of deps[name]) {
153
- for (const section of ['devDependencies', 'peerDependencies']) {
154
- if (pkgJson[section] && dep in pkgJson[section]) {
155
- dependencies[dep] = pkgJson[section][dep]
156
- break
157
- }
158
- }
159
- }
160
- }
161
-
162
- async function getVersionList (name) {
163
- if (versionLists[name]) {
164
- return versionLists[name]
165
- }
166
- const list = await npmView(`${name} versions`)
167
- versionLists[name] = list
168
- return list
169
- }
170
-
171
- function npmView (input) {
172
- return new Promise((resolve, reject) => {
173
- childProcess.exec(`npm view ${input} --json`, (err, stdout) => {
174
- if (err) {
175
- reject(err)
176
- return
177
- }
178
- resolve(JSON.parse(stdout.toString('utf8')))
179
- })
180
- })
181
- }
182
-
183
- function assertIndex (name, version) {
184
- const index = `'use strict'
185
-
186
- const requirePackageJson = require('${requirePackageJsonPath}')
187
-
188
- module.exports = {
189
- get (id) { return require(id || '${name}') },
190
- getPath (id) { return require.resolve(id || '${name}' ) },
191
- version () { return requirePackageJson('${name}', module).version }
192
- }
193
- `
194
- fs.writeFileSync(filename(name, version, 'index.js'), index)
195
- }
196
-
197
- function assertWorkspace () {
198
- fs.writeFileSync(filename(null, null, 'package.json'), JSON.stringify({
199
- name: 'versions',
200
- version: '1.0.0',
201
- license: 'BSD-3-Clause',
202
- private: true,
203
- workspaces: {
204
- packages: Array.from(workspaces)
205
- }
206
- }, null, 2) + '\n')
207
- }
208
-
209
- function install () {
210
- exec('yarn --ignore-engines', { cwd: folder() })
211
- }
212
-
213
- function addFolder (name, version) {
214
- const basename = [name, version].filter(val => val).join('@')
215
- if (!excludeList.includes(name)) workspaces.add(basename)
216
- }
217
-
218
- function folder (name, version) {
219
- const basename = [name, version].filter(val => val).join('@')
220
- return path.join(__dirname, '..', 'versions', basename)
221
- }
222
-
223
- function filename (name, version, file) {
224
- return path.join(folder(name, version), file)
225
- }
226
-
227
- function sha1 (str) {
228
- if (!str) return
229
-
230
- const shasum = crypto.createHash('sha1')
231
- shasum.update(str)
232
- return shasum.digest('hex')
233
- }
234
-
235
- function loadInstFile (file, instrumentations) {
236
- const instrument = {
237
- addHook (instrumentation) {
238
- instrumentations.push(instrumentation)
239
- }
240
- }
241
-
242
- const instPath = path.join(__dirname, `../packages/datadog-instrumentations/src/${file}`)
243
-
244
- proxyquire.noPreserveCache()(instPath, {
245
- './helpers/instrument': instrument,
246
- '../helpers/instrument': instrument
247
- })
248
- }
@@ -1,21 +0,0 @@
1
- 'use strict'
2
-
3
- const exec = require('./helpers/exec')
4
- const title = require('./helpers/title')
5
-
6
- title(`Publishing API documentation to GitHub Pages`)
7
-
8
- const msg = process.argv[2]
9
-
10
- if (!msg) {
11
- throw new Error('Please provide a reason for the change. Example: node scripts/publish_docs.js "fix typo"')
12
- }
13
-
14
- exec('yarn install', { cwd: './docs' })
15
- exec('rm -rf ./out', { cwd: './docs' })
16
- exec('yarn type:doc') // run first because typedoc requires an empty directory
17
- exec('git init', { cwd: './docs/out' }) // cloning would overwrite generated docs
18
- exec('git remote add origin git@github.com:DataDog/dd-trace-js.git', { cwd: './docs/out' })
19
- exec('git add -A', { cwd: './docs/out' })
20
- exec(`git commit -m "${msg}"`, { cwd: './docs/out' })
21
- exec('git push -f origin main:gh-pages', { cwd: './docs/out' })
package/scripts/st.js DELETED
@@ -1,105 +0,0 @@
1
- #!/usr/bin/env node
2
- /* eslint-disable no-console, no-fallthrough */
3
- 'use strict'
4
-
5
- const path = require('path')
6
- const { writeFileSync } = require('fs')
7
- const { execSync } = require('child_process')
8
-
9
- const ddtracePath = path.join(__dirname, '..')
10
- const defaultTestPath = process.env.DD_ST_PATH || path.join(ddtracePath, '..', 'system-tests')
11
-
12
- const { buildAll, npm, testDir, testArgs } = parseArgs()
13
-
14
- const binariesPath = path.join(testDir, 'binaries')
15
-
16
- if (npm) {
17
- console.log('Using NPM package:', npm)
18
-
19
- writeFileSync(path.join(binariesPath, 'nodejs-load-from-npm'), npm)
20
- } else {
21
- console.log('Using local repo')
22
-
23
- const packName = execSync(`npm pack ${ddtracePath}`, {
24
- cwd: binariesPath,
25
- stdio: [null, null, 'inherit'],
26
- encoding: 'utf8'
27
- }).slice(0, -1) // remove trailing newline
28
-
29
- writeFileSync(path.join(binariesPath, 'nodejs-load-from-npm'), `/binaries/${packName}`)
30
- }
31
-
32
- try {
33
- execSync(`./build.sh ${buildAll ? '' : '-i weblog'} && ./run.sh ${testArgs}`, {
34
- cwd: testDir,
35
- stdio: [null, 'inherit', 'inherit']
36
- })
37
- } catch (err) {
38
- process.exit(err.status || 1)
39
- }
40
-
41
- function parseArgs () {
42
- const args = {
43
- buildAll: false,
44
- npm: null,
45
- testDir: defaultTestPath,
46
- testArgs: ''
47
- }
48
-
49
- for (let i = 2; i < process.argv.length; i++) {
50
- switch (process.argv[i]) {
51
- case '-b':
52
- case '--build-all':
53
- args.buildAll = true
54
- break
55
-
56
- case '-h':
57
- case '--help':
58
- helpAndExit()
59
- break
60
-
61
- case '-n':
62
- case '--npm': {
63
- const arg = process.argv[i + 1]
64
- if (!arg || arg[0] === '-') {
65
- args.npm = 'dd-trace'
66
- } else {
67
- args.npm = arg
68
- i++
69
- }
70
- break
71
- }
72
-
73
- case '-t':
74
- case '--test-dir': {
75
- const arg = process.argv[++i]
76
- if (!arg || arg[0] === '-') helpAndExit()
77
- args.testDir = arg
78
- break
79
- }
80
-
81
- case '--':
82
- args.testArgs = process.argv.slice(i + 1).join(' ')
83
- return args
84
-
85
- default:
86
- console.log('Unknown option:', process.argv[i], '\n')
87
- helpAndExit()
88
- }
89
- }
90
-
91
- return args
92
- }
93
-
94
- function helpAndExit () {
95
- console.log('Usage: node st.js [options...] [-- test-args]')
96
- console.log('Options:')
97
- console.log(' -b, --build-all Rebuild all images (default: only build weblog)')
98
- console.log(' -h, --help Print this message')
99
- console.log(' -n, --npm [package] Build a remote package instead of the local repo (default: "dd-trace")')
100
- console.log(' Can be a package name (e.g. "dd-trace@4.2.0") or a git URL (e.g.')
101
- console.log(' "git+https://github.com/DataDog/dd-trace-js.git#mybranch")')
102
- console.log(' -t, --test-dir <path> Specify the system-tests directory (default: "dd-trace/../system-tests/")')
103
- console.log(' -- <test-args> Passed to system-tests run.sh (e.g. "-- SCENARIO_NAME tests/path_to_test.py")')
104
- process.exit()
105
- }