dd-trace 3.9.3 → 3.10.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 -0
- package/README.md +108 -43
- package/ci/init.js +6 -1
- package/ext/exporters.d.ts +2 -1
- package/ext/exporters.js +2 -1
- package/index.d.ts +6 -1
- package/package.json +3 -2
- package/packages/datadog-instrumentations/src/http/server.js +4 -1
- package/packages/datadog-instrumentations/src/jest.js +24 -10
- package/packages/datadog-instrumentations/src/mocha.js +7 -4
- package/packages/datadog-instrumentations/src/opensearch.js +1 -1
- package/packages/datadog-instrumentations/src/router.js +1 -1
- package/packages/datadog-plugin-cucumber/src/index.js +1 -1
- package/packages/datadog-plugin-http/src/server.js +2 -1
- package/packages/datadog-plugin-jest/src/index.js +21 -25
- package/packages/datadog-plugin-mocha/src/index.js +11 -18
- package/packages/datadog-plugin-mongodb-core/src/index.js +3 -3
- package/packages/dd-trace/src/appsec/callbacks/ddwaf.js +4 -0
- package/packages/dd-trace/src/appsec/index.js +6 -1
- package/packages/dd-trace/src/appsec/remote_config/index.js +23 -2
- package/packages/dd-trace/src/appsec/remote_config/manager.js +1 -1
- package/packages/dd-trace/src/appsec/rule_manager.js +58 -1
- package/packages/dd-trace/src/ci-visibility/exporters/agent-proxy/index.js +62 -0
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +8 -1
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/index.js +11 -59
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +9 -1
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +196 -0
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +20 -7
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-itr-configuration.js +22 -19
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +22 -18
- package/packages/dd-trace/src/config.js +10 -8
- package/packages/dd-trace/src/exporter.js +3 -0
- package/packages/dd-trace/src/exporters/agent/index.js +4 -0
- package/packages/dd-trace/src/exporters/common/agent-info-exporter.js +82 -0
- package/packages/dd-trace/src/plugin_manager.js +0 -8
- package/packages/dd-trace/src/plugins/ci_plugin.js +9 -50
- package/packages/dd-trace/src/plugins/util/ci.js +35 -2
- package/packages/dd-trace/src/plugins/util/test.js +4 -0
- package/packages/dd-trace/src/plugins/util/web.js +1 -2
- package/packages/dd-trace/src/profiling/exporters/agent.js +4 -0
- package/packages/dd-trace/src/proxy.js +3 -17
- package/packages/dd-trace/src/ritm.js +18 -13
- package/packages/dd-trace/src/telemetry/dependencies.js +11 -1
|
@@ -16,6 +16,8 @@ let cache = Object.create(null)
|
|
|
16
16
|
let patching = Object.create(null)
|
|
17
17
|
let patchedRequire = null
|
|
18
18
|
const moduleLoadStartChannel = dc.channel('dd-trace:moduleLoadStart')
|
|
19
|
+
const moduleLoadEndChannel = dc.channel('dd-trace:moduleLoadEnd')
|
|
20
|
+
|
|
19
21
|
function Hook (modules, options, onrequire) {
|
|
20
22
|
if (!(this instanceof Hook)) return new Hook(modules, options, onrequire)
|
|
21
23
|
if (typeof modules === 'function') {
|
|
@@ -52,7 +54,6 @@ function Hook (modules, options, onrequire) {
|
|
|
52
54
|
const filename = Module._resolveFilename(request, this)
|
|
53
55
|
const core = filename.indexOf(path.sep) === -1
|
|
54
56
|
let name, basedir, hooks
|
|
55
|
-
|
|
56
57
|
// return known patched modules immediately
|
|
57
58
|
if (cache[filename]) {
|
|
58
59
|
// require.cache was potentially altered externally
|
|
@@ -66,27 +67,31 @@ function Hook (modules, options, onrequire) {
|
|
|
66
67
|
// Check if this module has a patcher in-progress already.
|
|
67
68
|
// Otherwise, mark this module as patching in-progress.
|
|
68
69
|
const patched = patching[filename]
|
|
69
|
-
if (
|
|
70
|
+
if (patched) {
|
|
71
|
+
// If it's already patched, just return it as-is.
|
|
72
|
+
return origRequire.apply(this, arguments)
|
|
73
|
+
} else {
|
|
70
74
|
patching[filename] = true
|
|
71
75
|
}
|
|
72
76
|
|
|
73
|
-
const
|
|
77
|
+
const payload = {
|
|
78
|
+
filename,
|
|
79
|
+
request
|
|
80
|
+
}
|
|
74
81
|
|
|
75
|
-
|
|
76
|
-
|
|
82
|
+
if (moduleLoadStartChannel.hasSubscribers) {
|
|
83
|
+
moduleLoadStartChannel.publish(payload)
|
|
84
|
+
}
|
|
85
|
+
const exports = origRequire.apply(this, arguments)
|
|
86
|
+
payload.module = exports
|
|
87
|
+
if (moduleLoadEndChannel.hasSubscribers) {
|
|
88
|
+
moduleLoadEndChannel.publish(payload)
|
|
89
|
+
}
|
|
77
90
|
|
|
78
91
|
// The module has already been loaded,
|
|
79
92
|
// so the patching mark can be cleaned up.
|
|
80
93
|
delete patching[filename]
|
|
81
94
|
|
|
82
|
-
if (moduleLoadStartChannel.hasSubscribers) {
|
|
83
|
-
moduleLoadStartChannel.publish({
|
|
84
|
-
filename,
|
|
85
|
-
module: exports,
|
|
86
|
-
request
|
|
87
|
-
})
|
|
88
|
-
}
|
|
89
|
-
|
|
90
95
|
if (core) {
|
|
91
96
|
hooks = moduleHooks[filename]
|
|
92
97
|
if (!hooks) return exports // abort if module name isn't on whitelist
|
|
@@ -71,7 +71,17 @@ function start (_config, _application, _host) {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
function isDependency (filename, request) {
|
|
74
|
-
|
|
74
|
+
const isDependencyWithSlash = isDependencyWithSeparator(filename, request, '/')
|
|
75
|
+
if (isDependencyWithSlash && process.platform === 'win32') {
|
|
76
|
+
return isDependencyWithSeparator(filename, request, path.sep)
|
|
77
|
+
}
|
|
78
|
+
return isDependencyWithSlash
|
|
79
|
+
}
|
|
80
|
+
function isDependencyWithSeparator (filename, request, sep) {
|
|
81
|
+
return request.indexOf(`..${sep}`) !== 0 &&
|
|
82
|
+
request.indexOf(`.${sep}`) !== 0 &&
|
|
83
|
+
request.indexOf(sep) !== 0 &&
|
|
84
|
+
request.indexOf(`:${sep}`) !== 1
|
|
75
85
|
}
|
|
76
86
|
|
|
77
87
|
function stop () {
|