dd-trace 2.40.0 → 2.42.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/README.md +2 -2
- package/package.json +4 -4
- package/packages/datadog-core/src/storage/async_resource.js +4 -0
- package/packages/datadog-instrumentations/src/cucumber.js +5 -2
- package/packages/datadog-instrumentations/src/grpc/client.js +44 -42
- package/packages/datadog-instrumentations/src/grpc/server.js +69 -60
- package/packages/datadog-instrumentations/src/http2/client.js +25 -26
- package/packages/datadog-instrumentations/src/jest.js +9 -5
- package/packages/datadog-instrumentations/src/mocha.js +5 -3
- package/packages/datadog-plugin-cypress/src/plugin.js +4 -2
- package/packages/datadog-plugin-graphql/src/execute.js +6 -4
- package/packages/datadog-plugin-grpc/src/client.js +29 -11
- package/packages/datadog-plugin-grpc/src/server.js +22 -6
- package/packages/datadog-plugin-http2/src/client.js +46 -29
- package/packages/datadog-plugin-jest/src/index.js +8 -3
- package/packages/datadog-plugin-openai/src/index.js +39 -16
- package/packages/datadog-plugin-openai/src/services.js +13 -9
- package/packages/datadog-plugin-router/src/index.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/analyzers.js +3 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/command-injection-analyzer.js +3 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/cookie-analyzer.js +7 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hsts-header-missing-analyzer.js +45 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/index.js +3 -3
- package/packages/dd-trace/src/appsec/iast/analyzers/ldap-injection-analyzer.js +3 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/missing-header-analyzer.js +66 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/path-traversal-analyzer.js +19 -15
- package/packages/dd-trace/src/appsec/iast/analyzers/sql-injection-analyzer.js +5 -2
- package/packages/dd-trace/src/appsec/iast/analyzers/ssrf-analyzer.js +2 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/unvalidated-redirect-analyzer.js +27 -8
- package/packages/dd-trace/src/appsec/iast/analyzers/vulnerability-analyzer.js +18 -19
- package/packages/dd-trace/src/appsec/iast/analyzers/weak-cipher-analyzer.js +3 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/weak-hash-analyzer.js +3 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/xcontenttype-header-missing-analyzer.js +19 -0
- package/packages/dd-trace/src/appsec/iast/iast-log.js +1 -1
- package/packages/dd-trace/src/appsec/iast/iast-plugin.js +205 -0
- package/packages/dd-trace/src/appsec/iast/index.js +11 -7
- package/packages/dd-trace/src/appsec/iast/tags.js +2 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/csi-methods.js +6 -6
- package/packages/dd-trace/src/appsec/iast/taint-tracking/index.js +7 -5
- package/packages/dd-trace/src/appsec/iast/taint-tracking/operations.js +23 -4
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +49 -17
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter-telemetry.js +33 -0
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +23 -16
- package/packages/dd-trace/src/appsec/iast/taint-tracking/{origin-types.js → source-types.js} +1 -0
- package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +76 -37
- package/packages/dd-trace/src/appsec/iast/telemetry/iast-metric.js +101 -0
- package/packages/dd-trace/src/appsec/iast/telemetry/index.js +45 -0
- package/packages/dd-trace/src/appsec/iast/telemetry/{logs.js → log/index.js} +5 -5
- package/packages/dd-trace/src/appsec/iast/telemetry/{log_collector.js → log/log-collector.js} +1 -1
- package/packages/dd-trace/src/appsec/iast/telemetry/namespaces.js +76 -0
- package/packages/dd-trace/src/appsec/iast/telemetry/span-tags.js +53 -0
- package/packages/dd-trace/src/appsec/iast/telemetry/verbosity.js +42 -0
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/index.js +5 -1
- package/packages/dd-trace/src/appsec/iast/vulnerabilities.js +3 -1
- package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +1 -1
- package/packages/dd-trace/src/config.js +47 -12
- package/packages/dd-trace/src/constants.js +1 -0
- package/packages/dd-trace/src/external-logger/src/index.js +9 -1
- package/packages/dd-trace/src/external-logger/test/index.spec.js +1 -1
- package/packages/dd-trace/src/format.js +1 -1
- package/packages/dd-trace/src/lambda/handler.js +8 -1
- package/packages/dd-trace/src/opentelemetry/span.js +3 -1
- package/packages/dd-trace/src/opentracing/span_context.js +2 -1
- package/packages/dd-trace/src/opentracing/tracer.js +1 -0
- package/packages/dd-trace/src/plugins/ci_plugin.js +6 -1
- package/packages/dd-trace/src/plugins/outbound.js +29 -12
- package/packages/dd-trace/src/plugins/plugin.js +28 -0
- package/packages/dd-trace/src/plugins/tracing.js +33 -16
- package/packages/dd-trace/src/plugins/util/ci.js +3 -2
- package/packages/dd-trace/src/plugins/util/test.js +55 -11
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +1 -22
- package/packages/dd-trace/src/plugins/util/web.js +1 -0
- package/packages/dd-trace/src/profiling/config.js +8 -8
- package/packages/dd-trace/src/profiling/exporters/agent.js +4 -1
- package/packages/dd-trace/src/profiling/index.js +0 -2
- package/packages/dd-trace/src/profiling/profiler.js +1 -1
- package/packages/dd-trace/src/profiling/profilers/wall.js +162 -10
- package/packages/dd-trace/src/service-naming/index.js +2 -2
- package/packages/dd-trace/src/service-naming/schemas/v0/graphql.js +12 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/index.js +2 -1
- package/packages/dd-trace/src/service-naming/schemas/v1/graphql.js +12 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/index.js +2 -1
- package/packages/dd-trace/src/span_processor.js +0 -4
- package/packages/dd-trace/src/span_sampler.js +1 -1
- package/packages/dd-trace/src/telemetry/dependencies.js +24 -12
- package/packages/dd-trace/src/telemetry/metrics.js +11 -1
- package/packages/diagnostics_channel/src/index.js +64 -0
- package/packages/dd-trace/src/profiling/profilers/cpu.js +0 -126
- package/scripts/version.js +0 -66
|
@@ -25,6 +25,10 @@ function mapToJsonArray (map) {
|
|
|
25
25
|
return Array.from(map.values()).map(v => v.toJSON())
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
function hasPoints (metric) {
|
|
29
|
+
return metric.points.length > 0
|
|
30
|
+
}
|
|
31
|
+
|
|
28
32
|
class Metric {
|
|
29
33
|
constructor (namespace, metric, common, tags) {
|
|
30
34
|
this.namespace = namespace.toString()
|
|
@@ -172,10 +176,16 @@ class MetricsCollection extends Map {
|
|
|
172
176
|
|
|
173
177
|
toJSON () {
|
|
174
178
|
if (!this.size) return
|
|
179
|
+
|
|
180
|
+
const series = mapToJsonArray(this)
|
|
181
|
+
.filter(hasPoints)
|
|
182
|
+
|
|
183
|
+
if (!series.length) return
|
|
184
|
+
|
|
175
185
|
const { namespace } = this
|
|
176
186
|
return {
|
|
177
187
|
namespace,
|
|
178
|
-
series
|
|
188
|
+
series
|
|
179
189
|
}
|
|
180
190
|
}
|
|
181
191
|
}
|
|
@@ -54,4 +54,68 @@ if (major === '19' && minor === '9') {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
if (!Channel.prototype.runStores) {
|
|
58
|
+
const ActiveChannelPrototype = getActiveChannelPrototype()
|
|
59
|
+
|
|
60
|
+
Channel.prototype.bindStore = ActiveChannelPrototype.bindStore = function (store, transform) {
|
|
61
|
+
if (!this._stores) {
|
|
62
|
+
this._stores = new Map()
|
|
63
|
+
}
|
|
64
|
+
this._stores.set(store, transform)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
Channel.prototype.unbindStore = ActiveChannelPrototype.runStores = function (store) {
|
|
68
|
+
if (!this._stores) return
|
|
69
|
+
this._stores.delete(store)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
Channel.prototype.runStores = ActiveChannelPrototype.runStores = function (data, fn, thisArg, ...args) {
|
|
73
|
+
if (!this._stores) return Reflect.apply(fn, thisArg, args)
|
|
74
|
+
|
|
75
|
+
let run = () => {
|
|
76
|
+
this.publish(data)
|
|
77
|
+
return Reflect.apply(fn, thisArg, args)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
for (const entry of this._stores.entries()) {
|
|
81
|
+
const store = entry[0]
|
|
82
|
+
const transform = entry[1]
|
|
83
|
+
run = wrapStoreRun(store, data, run, transform)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return run()
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function defaultTransform (data) {
|
|
91
|
+
return data
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function wrapStoreRun (store, data, next, transform = defaultTransform) {
|
|
95
|
+
return () => {
|
|
96
|
+
let context
|
|
97
|
+
try {
|
|
98
|
+
context = transform(data)
|
|
99
|
+
} catch (err) {
|
|
100
|
+
process.nextTick(() => {
|
|
101
|
+
throw err
|
|
102
|
+
})
|
|
103
|
+
return next()
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return store.run(context, next)
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function getActiveChannelPrototype () {
|
|
111
|
+
const dummyChannel = channel('foo')
|
|
112
|
+
const listener = () => {}
|
|
113
|
+
|
|
114
|
+
dummyChannel.subscribe(listener)
|
|
115
|
+
const ActiveChannelPrototype = Object.getPrototypeOf(dummyChannel)
|
|
116
|
+
dummyChannel.unsubscribe(listener)
|
|
117
|
+
|
|
118
|
+
return ActiveChannelPrototype
|
|
119
|
+
}
|
|
120
|
+
|
|
57
121
|
module.exports = dc
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const { storage } = require('../../../../datadog-core')
|
|
4
|
-
|
|
5
|
-
const dc = require('../../../../diagnostics_channel')
|
|
6
|
-
|
|
7
|
-
const beforeCh = dc.channel('dd-trace:storage:before')
|
|
8
|
-
const afterCh = dc.channel('dd-trace:storage:after')
|
|
9
|
-
|
|
10
|
-
function getActiveSpan () {
|
|
11
|
-
const store = storage.getStore()
|
|
12
|
-
if (!store) return
|
|
13
|
-
return store.span
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function getStartedSpans (activeSpan) {
|
|
17
|
-
const context = activeSpan.context()
|
|
18
|
-
if (!context) return
|
|
19
|
-
return context._trace.started
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function getSpanContextTags (span) {
|
|
23
|
-
return span.context()._tags
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function isWebServerSpan (tags) {
|
|
27
|
-
return tags['span.type'] === 'web'
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function endpointNameFromTags (tags) {
|
|
31
|
-
return tags['resource.name'] || [
|
|
32
|
-
tags['http.method'],
|
|
33
|
-
tags['http.route']
|
|
34
|
-
].filter(v => v).join(' ')
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
class NativeCpuProfiler {
|
|
38
|
-
constructor (options = {}) {
|
|
39
|
-
this.type = 'cpu'
|
|
40
|
-
this._frequency = options.frequency || 99
|
|
41
|
-
this._mapper = undefined
|
|
42
|
-
this._pprof = undefined
|
|
43
|
-
this._started = false
|
|
44
|
-
this._cpuProfiler = undefined
|
|
45
|
-
this._endpointCollection = options.endpointCollection
|
|
46
|
-
|
|
47
|
-
// Bind to this so the same value can be used to unsubscribe later
|
|
48
|
-
this._enter = this._enter.bind(this)
|
|
49
|
-
this._exit = this._exit.bind(this)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
_enter () {
|
|
53
|
-
if (!this._cpuProfiler) return
|
|
54
|
-
|
|
55
|
-
const active = getActiveSpan()
|
|
56
|
-
if (!active) return
|
|
57
|
-
|
|
58
|
-
const activeCtx = active.context()
|
|
59
|
-
if (!activeCtx) return
|
|
60
|
-
|
|
61
|
-
const spans = getStartedSpans(active)
|
|
62
|
-
if (!spans || !spans.length) return
|
|
63
|
-
|
|
64
|
-
const firstCtx = spans[0].context()
|
|
65
|
-
if (!firstCtx) return
|
|
66
|
-
|
|
67
|
-
const labels = {
|
|
68
|
-
'local root span id': firstCtx.toSpanId(),
|
|
69
|
-
'span id': activeCtx.toSpanId()
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (this._endpointCollection) {
|
|
73
|
-
const webServerTags = spans
|
|
74
|
-
.map(getSpanContextTags)
|
|
75
|
-
.filter(isWebServerSpan)[0]
|
|
76
|
-
|
|
77
|
-
if (webServerTags) {
|
|
78
|
-
labels['trace endpoint'] = endpointNameFromTags(webServerTags)
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
this._cpuProfiler.labels = labels
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
_exit () {
|
|
86
|
-
if (!this._cpuProfiler) return
|
|
87
|
-
this._cpuProfiler.labels = {}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
start ({ mapper } = {}) {
|
|
91
|
-
if (this._started) return
|
|
92
|
-
this._started = true
|
|
93
|
-
|
|
94
|
-
this._mapper = mapper
|
|
95
|
-
if (!this._pprof) {
|
|
96
|
-
this._pprof = require('@datadog/pprof')
|
|
97
|
-
this._cpuProfiler = new this._pprof.CpuProfiler()
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
this._cpuProfiler.start(this._frequency)
|
|
101
|
-
|
|
102
|
-
this._enter()
|
|
103
|
-
beforeCh.subscribe(this._enter)
|
|
104
|
-
afterCh.subscribe(this._exit)
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
profile () {
|
|
108
|
-
if (!this._started) return
|
|
109
|
-
return this._cpuProfiler.profile()
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
encode (profile) {
|
|
113
|
-
return this._pprof.encode(profile)
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
stop () {
|
|
117
|
-
if (!this._started) return
|
|
118
|
-
this._started = false
|
|
119
|
-
|
|
120
|
-
this._cpuProfiler.stop()
|
|
121
|
-
beforeCh.unsubscribe(this._enter)
|
|
122
|
-
afterCh.unsubscribe(this._exit)
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
module.exports = NativeCpuProfiler
|
package/scripts/version.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const path = require('path')
|
|
4
|
-
const fs = require('fs')
|
|
5
|
-
const semver = require('semver')
|
|
6
|
-
const exec = require('./helpers/exec')
|
|
7
|
-
const title = require('./helpers/title')
|
|
8
|
-
|
|
9
|
-
const pkg = require('../package.json')
|
|
10
|
-
const increment = getIncrement()
|
|
11
|
-
const version = semver.inc(pkg.version, increment, 'pre')
|
|
12
|
-
|
|
13
|
-
title(`Bumping version to v${version}.`)
|
|
14
|
-
|
|
15
|
-
const currentBranch = exec.pipe(`git branch --show-current`)
|
|
16
|
-
|
|
17
|
-
if (currentBranch === 'master') {
|
|
18
|
-
const major = semver.major(pkg.version)
|
|
19
|
-
const nextMajor = semver.major(pkg.version) + 1
|
|
20
|
-
|
|
21
|
-
exec(`git checkout -b v${major}.x`)
|
|
22
|
-
exec(`git push -u origin HEAD`)
|
|
23
|
-
|
|
24
|
-
bump(`${nextMajor}.0.0-pre`)
|
|
25
|
-
|
|
26
|
-
exec(`git checkout v${major}.x`)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
bump(version)
|
|
30
|
-
|
|
31
|
-
exec(`git checkout ${currentBranch}`)
|
|
32
|
-
|
|
33
|
-
function bump (newVersion) {
|
|
34
|
-
pkg.version = newVersion
|
|
35
|
-
|
|
36
|
-
exec(`git checkout -b v${newVersion}-bump`)
|
|
37
|
-
write('package.json', JSON.stringify(pkg, null, 2) + '\n')
|
|
38
|
-
write('packages/dd-trace/lib/version.js', `module.exports = '${newVersion}'\n`)
|
|
39
|
-
add('package.json')
|
|
40
|
-
add('packages/dd-trace/lib/version.js')
|
|
41
|
-
exec(`git commit -m "v${newVersion}"`)
|
|
42
|
-
exec(`git push -u origin HEAD`)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function getIncrement () {
|
|
46
|
-
const increments = ['major', 'premajor', 'minor', 'preminor', 'patch', 'prepatch', 'prerelease']
|
|
47
|
-
const index = increments.indexOf(process.argv[2])
|
|
48
|
-
|
|
49
|
-
if (index === -1) {
|
|
50
|
-
throw new Error(`increment must be one of ${increments.join(', ')}`)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return increments[index]
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function filename (relativePath) {
|
|
57
|
-
return path.normalize(path.join(__dirname, '..', relativePath))
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function write (file, data) {
|
|
61
|
-
fs.writeFileSync(filename(file), data)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function add (file) {
|
|
65
|
-
exec(`git add ${filename(file)}`)
|
|
66
|
-
}
|