dd-trace 2.30.1 → 2.31.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.
- package/LICENSE-3rdparty.csv +1 -1
- package/esbuild.js +3 -0
- package/index.d.ts +10 -9
- package/package.json +7 -7
- package/packages/datadog-core/src/storage/async_resource.js +1 -1
- package/packages/datadog-esbuild/index.js +9 -2
- package/packages/datadog-instrumentations/src/cucumber.js +11 -1
- package/packages/datadog-instrumentations/src/helpers/instrument.js +1 -1
- package/packages/datadog-instrumentations/src/helpers/register.js +1 -1
- package/packages/datadog-instrumentations/src/jest.js +6 -3
- package/packages/datadog-instrumentations/src/mocha.js +19 -2
- package/packages/datadog-instrumentations/src/playwright.js +2 -2
- package/packages/datadog-plugin-cucumber/src/index.js +6 -4
- package/packages/datadog-plugin-cypress/src/plugin.js +5 -1
- package/packages/datadog-plugin-cypress/src/support.js +4 -0
- package/packages/datadog-plugin-http/src/client.js +1 -1
- package/packages/datadog-plugin-jest/src/index.js +10 -5
- package/packages/datadog-plugin-mocha/src/index.js +9 -4
- package/packages/datadog-plugin-playwright/src/index.js +6 -5
- package/packages/datadog-plugin-redis/src/index.js +16 -5
- package/packages/dd-trace/src/appsec/gateway/channels.js +1 -1
- package/packages/dd-trace/src/appsec/iast/index.js +1 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/operations.js +21 -13
- package/packages/dd-trace/src/appsec/iast/telemetry/logs.js +1 -1
- package/packages/dd-trace/src/appsec/remote_config/index.js +1 -1
- package/packages/dd-trace/src/config.js +1 -0
- package/packages/dd-trace/src/dcitm.js +2 -0
- package/packages/dd-trace/src/encode/tags-processors.js +40 -68
- package/packages/dd-trace/src/exporters/common/request.js +2 -2
- package/packages/dd-trace/src/format.js +2 -1
- package/packages/dd-trace/src/iitm.js +1 -1
- package/packages/dd-trace/src/log/channels.js +11 -12
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +2 -2
- package/packages/dd-trace/src/plugin_manager.js +1 -1
- package/packages/dd-trace/src/plugins/plugin.js +1 -1
- package/packages/dd-trace/src/plugins/util/test.js +19 -1
- package/packages/dd-trace/src/profiling/profilers/cpu.js +1 -1
- package/packages/dd-trace/src/ritm.js +1 -1
- package/packages/dd-trace/src/span_stats.js +1 -1
- package/packages/dd-trace/src/telemetry/dependencies.js +1 -1
- package/packages/dd-trace/src/telemetry/index.js +1 -1
- package/packages/diagnostics_channel/index.js +3 -0
- package/packages/diagnostics_channel/src/index.js +57 -0
- package/packages/dd-trace/src/instrumenter.js +0 -203
- package/packages/dd-trace/src/loader.js +0 -131
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const semver = require('semver')
|
|
4
|
-
const Hook = require('../../datadog-instrumentations/src/helpers/hook')
|
|
5
|
-
const parse = require('module-details-from-path')
|
|
6
|
-
const path = require('path')
|
|
7
|
-
const uniq = require('lodash.uniq')
|
|
8
|
-
const log = require('./log')
|
|
9
|
-
const requirePackageJson = require('./require-package-json')
|
|
10
|
-
|
|
11
|
-
const pathSepExpr = new RegExp(`\\${path.sep}`, 'g')
|
|
12
|
-
|
|
13
|
-
class Loader {
|
|
14
|
-
constructor (instrumenter) {
|
|
15
|
-
this._instrumenter = instrumenter
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
reload (plugins) {
|
|
19
|
-
this._plugins = plugins
|
|
20
|
-
this._patched = []
|
|
21
|
-
|
|
22
|
-
const instrumentations = Array.from(this._plugins.keys())
|
|
23
|
-
.reduce((prev, current) => prev.concat(current), [])
|
|
24
|
-
|
|
25
|
-
const instrumentedModules = uniq(instrumentations
|
|
26
|
-
.map(instrumentation => instrumentation.name))
|
|
27
|
-
|
|
28
|
-
this._names = new Set(instrumentations
|
|
29
|
-
.map(instrumentation => filename(instrumentation)))
|
|
30
|
-
|
|
31
|
-
this._hook && this._hook.unhook()
|
|
32
|
-
this._hook = Hook(instrumentedModules, (moduleExports, moduleName, moduleBaseDir) => {
|
|
33
|
-
return this._hookModule(moduleExports, moduleName, moduleBaseDir)
|
|
34
|
-
})
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
load (instrumentation, config) {
|
|
38
|
-
this._getModules(instrumentation).forEach(nodule => {
|
|
39
|
-
this._instrumenter.patch(instrumentation, nodule, config)
|
|
40
|
-
})
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
_getModules (instrumentation) {
|
|
44
|
-
const modules = []
|
|
45
|
-
const ids = Object.keys(require.cache)
|
|
46
|
-
|
|
47
|
-
let pkg
|
|
48
|
-
|
|
49
|
-
for (let i = 0, l = ids.length; i < l; i++) {
|
|
50
|
-
const id = ids[i].replace(pathSepExpr, '/')
|
|
51
|
-
|
|
52
|
-
if (!id.includes(`/node_modules/${instrumentation.name}/`)) continue
|
|
53
|
-
|
|
54
|
-
if (instrumentation.file) {
|
|
55
|
-
if (!id.endsWith(`/node_modules/${filename(instrumentation)}`)) continue
|
|
56
|
-
|
|
57
|
-
const basedir = getBasedir(ids[i])
|
|
58
|
-
|
|
59
|
-
pkg = requirePackageJson(basedir, module)
|
|
60
|
-
} else {
|
|
61
|
-
const basedir = getBasedir(ids[i])
|
|
62
|
-
|
|
63
|
-
pkg = requirePackageJson(basedir, module)
|
|
64
|
-
|
|
65
|
-
const mainFile = path.posix.normalize(pkg.main || 'index.js')
|
|
66
|
-
if (!id.endsWith(`/node_modules/${instrumentation.name}/${mainFile}`)) continue
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (!matchVersion(pkg.version, instrumentation.versions)) continue
|
|
70
|
-
|
|
71
|
-
modules.push(require.cache[ids[i]].exports)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return modules
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
_hookModule (moduleExports, moduleName, moduleBaseDir) {
|
|
78
|
-
moduleName = moduleName.replace(pathSepExpr, '/')
|
|
79
|
-
|
|
80
|
-
if (!this._names.has(moduleName)) {
|
|
81
|
-
return moduleExports
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (moduleBaseDir) {
|
|
85
|
-
moduleBaseDir = moduleBaseDir.replace(pathSepExpr, '/')
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const moduleVersion = getVersion(moduleBaseDir)
|
|
89
|
-
|
|
90
|
-
for (const [plugin, meta] of this._plugins) {
|
|
91
|
-
if (meta.config.enabled === false) {
|
|
92
|
-
continue
|
|
93
|
-
}
|
|
94
|
-
try {
|
|
95
|
-
for (const instrumentation of [].concat(plugin)) {
|
|
96
|
-
if (moduleName !== filename(instrumentation) || !matchVersion(moduleVersion, instrumentation.versions)) {
|
|
97
|
-
continue
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
moduleExports = this._instrumenter.patch(instrumentation, moduleExports, meta.config) || moduleExports
|
|
101
|
-
}
|
|
102
|
-
} catch (e) {
|
|
103
|
-
log.error(e)
|
|
104
|
-
this._instrumenter.unload(plugin)
|
|
105
|
-
log.debug(`Error while trying to patch ${meta.name}. The plugin has been disabled.`)
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return moduleExports
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function getBasedir (id) {
|
|
114
|
-
return parse(id).basedir.replace(pathSepExpr, '/')
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function matchVersion (version, ranges) {
|
|
118
|
-
return !version || (ranges && ranges.some(range => semver.satisfies(semver.coerce(version), range)))
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function getVersion (moduleBaseDir) {
|
|
122
|
-
if (moduleBaseDir) {
|
|
123
|
-
return requirePackageJson(moduleBaseDir, module).version
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function filename (plugin) {
|
|
128
|
-
return [plugin.name, plugin.file].filter(val => val).join('/')
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
module.exports = Loader
|