dd-trace 4.6.0 → 4.8.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/couchbase.js +4 -4
- 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/scripts/install_plugin_modules.js +1 -0
- package/packages/dd-trace/src/profiling/profilers/cpu.js +0 -126
- package/scripts/version.js +0 -66
package/README.md
CHANGED
|
@@ -143,8 +143,8 @@ $ yarn leak:plugins
|
|
|
143
143
|
|
|
144
144
|
### Linting
|
|
145
145
|
|
|
146
|
-
We use [ESLint](https://eslint.org) to make sure that new code
|
|
147
|
-
|
|
146
|
+
We use [ESLint](https://eslint.org) to make sure that new code
|
|
147
|
+
conforms to our coding standards.
|
|
148
148
|
|
|
149
149
|
To run the linter, use:
|
|
150
150
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dd-trace",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.8.0",
|
|
4
4
|
"description": "Datadog APM tracing client for JavaScript",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -68,9 +68,9 @@
|
|
|
68
68
|
"dependencies": {
|
|
69
69
|
"@datadog/native-appsec": "^3.2.0",
|
|
70
70
|
"@datadog/native-iast-rewriter": "2.0.1",
|
|
71
|
-
"@datadog/native-iast-taint-tracking": "
|
|
71
|
+
"@datadog/native-iast-taint-tracking": "1.5.0",
|
|
72
72
|
"@datadog/native-metrics": "^2.0.0",
|
|
73
|
-
"@datadog/pprof": "
|
|
73
|
+
"@datadog/pprof": "3.1.0",
|
|
74
74
|
"@datadog/sketches-js": "^2.1.0",
|
|
75
75
|
"@opentelemetry/api": "^1.0.0",
|
|
76
76
|
"@opentelemetry/core": "^1.14.0",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"node-abort-controller": "^3.0.1",
|
|
95
95
|
"opentracing": ">=0.12.1",
|
|
96
96
|
"path-to-regexp": "^0.1.2",
|
|
97
|
-
"protobufjs": "^7.
|
|
97
|
+
"protobufjs": "^7.2.4",
|
|
98
98
|
"retry": "^0.10.1",
|
|
99
99
|
"semver": "^7.3.8"
|
|
100
100
|
},
|
|
@@ -5,6 +5,7 @@ const { channel } = require('../../../diagnostics_channel')
|
|
|
5
5
|
|
|
6
6
|
const beforeCh = channel('dd-trace:storage:before')
|
|
7
7
|
const afterCh = channel('dd-trace:storage:after')
|
|
8
|
+
const enterCh = channel('dd-trace:storage:enter')
|
|
8
9
|
|
|
9
10
|
let PrivateSymbol = Symbol
|
|
10
11
|
function makePrivateSymbol () {
|
|
@@ -52,6 +53,7 @@ class AsyncResourceStorage {
|
|
|
52
53
|
const resource = this._executionAsyncResource()
|
|
53
54
|
|
|
54
55
|
resource[this._ddResourceStore] = store
|
|
56
|
+
enterCh.publish()
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
run (store, callback, ...args) {
|
|
@@ -61,11 +63,13 @@ class AsyncResourceStorage {
|
|
|
61
63
|
const oldStore = resource[this._ddResourceStore]
|
|
62
64
|
|
|
63
65
|
resource[this._ddResourceStore] = store
|
|
66
|
+
enterCh.publish()
|
|
64
67
|
|
|
65
68
|
try {
|
|
66
69
|
return callback(...args)
|
|
67
70
|
} finally {
|
|
68
71
|
resource[this._ddResourceStore] = oldStore
|
|
72
|
+
enterCh.publish()
|
|
69
73
|
}
|
|
70
74
|
}
|
|
71
75
|
|
|
@@ -160,7 +160,7 @@ function wrapV3Query (query) {
|
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
// semver >=2 <3
|
|
163
|
-
addHook({ name: 'couchbase', file: 'lib/bucket.js', versions: ['^2.6.
|
|
163
|
+
addHook({ name: 'couchbase', file: 'lib/bucket.js', versions: ['^2.6.12'] }, Bucket => {
|
|
164
164
|
const startCh = channel('apm:couchbase:query:start')
|
|
165
165
|
const finishCh = channel('apm:couchbase:query:finish')
|
|
166
166
|
const errorCh = channel('apm:couchbase:query:error')
|
|
@@ -208,7 +208,7 @@ addHook({ name: 'couchbase', file: 'lib/bucket.js', versions: ['^2.6.5'] }, Buck
|
|
|
208
208
|
return Bucket
|
|
209
209
|
})
|
|
210
210
|
|
|
211
|
-
addHook({ name: 'couchbase', file: 'lib/cluster.js', versions: ['^2.6.
|
|
211
|
+
addHook({ name: 'couchbase', file: 'lib/cluster.js', versions: ['^2.6.12'] }, Cluster => {
|
|
212
212
|
Cluster.prototype._maybeInvoke = wrapMaybeInvoke(Cluster.prototype._maybeInvoke)
|
|
213
213
|
Cluster.prototype.query = wrapQuery(Cluster.prototype.query)
|
|
214
214
|
|
|
@@ -217,7 +217,7 @@ addHook({ name: 'couchbase', file: 'lib/cluster.js', versions: ['^2.6.5'] }, Clu
|
|
|
217
217
|
|
|
218
218
|
// semver >=3 <3.2.0
|
|
219
219
|
|
|
220
|
-
addHook({ name: 'couchbase', file: 'lib/collection.js', versions: ['
|
|
220
|
+
addHook({ name: 'couchbase', file: 'lib/collection.js', versions: ['^3.0.7', '^3.1.3'] }, Collection => {
|
|
221
221
|
wrapAllNames(['upsert', 'insert', 'replace'], name => {
|
|
222
222
|
shimmer.wrap(Collection.prototype, name, wrapWithName(name))
|
|
223
223
|
})
|
|
@@ -225,7 +225,7 @@ addHook({ name: 'couchbase', file: 'lib/collection.js', versions: ['>=3.0.0 <3.2
|
|
|
225
225
|
return Collection
|
|
226
226
|
})
|
|
227
227
|
|
|
228
|
-
addHook({ name: 'couchbase', file: 'lib/cluster.js', versions: ['
|
|
228
|
+
addHook({ name: 'couchbase', file: 'lib/cluster.js', versions: ['^3.0.7', '^3.1.3'] }, Cluster => {
|
|
229
229
|
shimmer.wrap(Cluster.prototype, 'query', wrapV3Query)
|
|
230
230
|
return Cluster
|
|
231
231
|
})
|
|
@@ -37,6 +37,7 @@ const patched = new WeakSet()
|
|
|
37
37
|
|
|
38
38
|
let pickleByFile = {}
|
|
39
39
|
const pickleResultByFile = {}
|
|
40
|
+
let isSuitesSkipped = false
|
|
40
41
|
|
|
41
42
|
function getSuiteStatusFromTestStatuses (testStatuses) {
|
|
42
43
|
if (testStatuses.some(status => status === 'fail')) {
|
|
@@ -264,7 +265,9 @@ addHook({
|
|
|
264
265
|
const { err, skippableSuites } = await skippableSuitesPromise
|
|
265
266
|
|
|
266
267
|
if (!err) {
|
|
267
|
-
|
|
268
|
+
const newPickleIds = getPicklesToRun(this, skippableSuites)
|
|
269
|
+
isSuitesSkipped = newPickleIds.length !== this.pickleIds.length
|
|
270
|
+
this.pickleIds = newPickleIds
|
|
268
271
|
}
|
|
269
272
|
|
|
270
273
|
pickleByFile = getPickleByFile(this)
|
|
@@ -292,7 +295,7 @@ addHook({
|
|
|
292
295
|
asyncResource.runInAsyncScope(() => {
|
|
293
296
|
sessionFinishCh.publish({
|
|
294
297
|
status: success ? 'pass' : 'fail',
|
|
295
|
-
isSuitesSkipped
|
|
298
|
+
isSuitesSkipped,
|
|
296
299
|
testCodeCoverageLinesTotal
|
|
297
300
|
})
|
|
298
301
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const types = require('./types')
|
|
4
|
-
const { addHook, channel
|
|
4
|
+
const { addHook, channel } = require('../helpers/instrument')
|
|
5
5
|
const shimmer = require('../../../datadog-shimmer')
|
|
6
6
|
|
|
7
7
|
const nodeMajor = parseInt(process.versions.node.split('.')[0])
|
|
@@ -10,8 +10,10 @@ const patched = new WeakSet()
|
|
|
10
10
|
const instances = new WeakMap()
|
|
11
11
|
|
|
12
12
|
const startChannel = channel('apm:grpc:client:request:start')
|
|
13
|
+
const asyncStartChannel = channel('apm:grpc:client:request:asyncStart')
|
|
13
14
|
const errorChannel = channel('apm:grpc:client:request:error')
|
|
14
15
|
const finishChannel = channel('apm:grpc:client:request:finish')
|
|
16
|
+
const emitChannel = channel('apm:grpc:client:request:emit')
|
|
15
17
|
|
|
16
18
|
function createWrapMakeRequest (type) {
|
|
17
19
|
return function wrapMakeRequest (makeRequest) {
|
|
@@ -101,45 +103,39 @@ function wrapMethod (method, path, type) {
|
|
|
101
103
|
return wrapped
|
|
102
104
|
}
|
|
103
105
|
|
|
104
|
-
function wrapCallback (
|
|
106
|
+
function wrapCallback (ctx, callback = () => { }) {
|
|
105
107
|
return function (err) {
|
|
106
108
|
if (err) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
})
|
|
109
|
+
ctx.error = err
|
|
110
|
+
errorChannel.publish(ctx)
|
|
110
111
|
}
|
|
111
112
|
|
|
112
|
-
|
|
113
|
-
return
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
113
|
+
return asyncStartChannel.runStores(ctx, () => {
|
|
114
|
+
return callback.apply(this, arguments)
|
|
115
|
+
// No async end channel needed
|
|
116
|
+
})
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
function
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
break
|
|
135
|
-
}
|
|
136
|
-
})
|
|
120
|
+
function createWrapEmit (ctx) {
|
|
121
|
+
return function wrapEmit (emit) {
|
|
122
|
+
return function (event, arg1) {
|
|
123
|
+
switch (event) {
|
|
124
|
+
case 'error':
|
|
125
|
+
ctx.error = arg1
|
|
126
|
+
errorChannel.publish(ctx)
|
|
127
|
+
break
|
|
128
|
+
case 'status':
|
|
129
|
+
ctx.result = arg1
|
|
130
|
+
finishChannel.publish(ctx)
|
|
131
|
+
break
|
|
132
|
+
}
|
|
137
133
|
|
|
138
|
-
return
|
|
134
|
+
return emitChannel.runStores(ctx, () => {
|
|
139
135
|
return emit.apply(this, arguments)
|
|
140
136
|
})
|
|
141
137
|
}
|
|
142
|
-
}
|
|
138
|
+
}
|
|
143
139
|
}
|
|
144
140
|
|
|
145
141
|
function callMethod (client, method, args, path, metadata, type) {
|
|
@@ -147,25 +143,31 @@ function callMethod (client, method, args, path, metadata, type) {
|
|
|
147
143
|
|
|
148
144
|
const length = args.length
|
|
149
145
|
const callback = args[length - 1]
|
|
150
|
-
const parentResource = new AsyncResource('bound-anonymous-fn')
|
|
151
|
-
const requestResource = new AsyncResource('bound-anonymous-fn')
|
|
152
146
|
|
|
153
|
-
|
|
154
|
-
startChannel.publish({ metadata, path, type })
|
|
147
|
+
const ctx = { metadata, path, type }
|
|
155
148
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
149
|
+
return startChannel.runStores(ctx, () => {
|
|
150
|
+
try {
|
|
151
|
+
if (type === types.unary || type === types.client_stream) {
|
|
152
|
+
if (typeof callback === 'function') {
|
|
153
|
+
args[length - 1] = wrapCallback(ctx, callback)
|
|
154
|
+
} else {
|
|
155
|
+
args[length] = wrapCallback(ctx)
|
|
156
|
+
}
|
|
161
157
|
}
|
|
162
|
-
}
|
|
163
158
|
|
|
164
|
-
|
|
159
|
+
const call = method.apply(client, args)
|
|
165
160
|
|
|
166
|
-
|
|
161
|
+
if (call && typeof call.emit === 'function') {
|
|
162
|
+
shimmer.wrap(call, 'emit', createWrapEmit(ctx))
|
|
163
|
+
}
|
|
167
164
|
|
|
168
|
-
|
|
165
|
+
return call
|
|
166
|
+
} catch (e) {
|
|
167
|
+
ctx.error = e
|
|
168
|
+
errorChannel.publish(ctx)
|
|
169
|
+
}
|
|
170
|
+
// No end channel needed
|
|
169
171
|
})
|
|
170
172
|
}
|
|
171
173
|
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const types = require('./types')
|
|
4
|
-
const { channel, addHook
|
|
4
|
+
const { channel, addHook } = require('../helpers/instrument')
|
|
5
5
|
const shimmer = require('../../../datadog-shimmer')
|
|
6
6
|
|
|
7
7
|
const nodeMajor = parseInt(process.versions.node.split('.')[0])
|
|
8
8
|
|
|
9
9
|
const startChannel = channel('apm:grpc:server:request:start')
|
|
10
|
+
const asyncStartChannel = channel('apm:grpc:server:request:asyncStart')
|
|
10
11
|
const errorChannel = channel('apm:grpc:server:request:error')
|
|
11
12
|
const updateChannel = channel('apm:grpc:server:request:update')
|
|
12
13
|
const finishChannel = channel('apm:grpc:server:request:finish')
|
|
14
|
+
const emitChannel = channel('apm:grpc:server:request:emit')
|
|
13
15
|
|
|
14
16
|
// https://github.com/grpc/grpc/blob/master/doc/statuscodes.md
|
|
15
17
|
const OK = 0
|
|
@@ -33,28 +35,38 @@ function wrapHandler (func, name) {
|
|
|
33
35
|
const type = types[this.type]
|
|
34
36
|
const isStream = type !== 'unary'
|
|
35
37
|
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
const ctx = { name, metadata, type }
|
|
39
|
+
|
|
40
|
+
return startChannel.runStores(ctx, () => {
|
|
41
|
+
try {
|
|
42
|
+
const onCancel = () => {
|
|
43
|
+
ctx.code = CANCELLED
|
|
44
|
+
finishChannel.publish(ctx)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Finish the span if the call was cancelled.
|
|
48
|
+
call.once('cancelled', onCancel)
|
|
49
|
+
|
|
50
|
+
if (isStream) {
|
|
51
|
+
wrapStream(call, ctx, onCancel)
|
|
52
|
+
} else {
|
|
53
|
+
arguments[1] = wrapCallback(callback, call, ctx, onCancel)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
shimmer.wrap(call, 'emit', emit => {
|
|
57
|
+
return function () {
|
|
58
|
+
return emitChannel.runStores(ctx, () => {
|
|
59
|
+
return emit.apply(this, arguments)
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
})
|
|
48
63
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
64
|
+
return func.apply(this, arguments)
|
|
65
|
+
} catch (e) {
|
|
66
|
+
ctx.error = e
|
|
67
|
+
errorChannel.publish(ctx)
|
|
53
68
|
}
|
|
54
|
-
|
|
55
|
-
shimmer.wrap(call, 'emit', emit => requestResource.bind(emit))
|
|
56
|
-
|
|
57
|
-
return func.apply(this, arguments)
|
|
69
|
+
// No end channel needed
|
|
58
70
|
})
|
|
59
71
|
}
|
|
60
72
|
}
|
|
@@ -69,69 +81,66 @@ function wrapRegister (register) {
|
|
|
69
81
|
}
|
|
70
82
|
}
|
|
71
83
|
|
|
72
|
-
function
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
shimmer.wrap(call, 'emit', emit => {
|
|
78
|
-
return function (eventName, ...args) {
|
|
79
|
-
switch (eventName) {
|
|
84
|
+
function createWrapEmit (call, ctx, onCancel) {
|
|
85
|
+
return function wrapEmit (emit) {
|
|
86
|
+
return function (event, arg1) {
|
|
87
|
+
switch (event) {
|
|
80
88
|
case 'error':
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
89
|
+
ctx.error = arg1
|
|
90
|
+
errorChannel.publish(ctx)
|
|
91
|
+
ctx.code = arg1.code
|
|
92
|
+
finishChannel.publish(ctx)
|
|
84
93
|
call.removeListener('cancelled', onCancel)
|
|
85
|
-
|
|
86
94
|
break
|
|
87
|
-
|
|
88
|
-
// Finish the span of the response only if it was successful.
|
|
89
|
-
// Otherwise it'll be finished in the `error` listener.
|
|
90
95
|
case 'finish':
|
|
91
96
|
if (call.status) {
|
|
92
97
|
updateChannel.publish(call.status)
|
|
93
98
|
}
|
|
94
|
-
|
|
95
99
|
if (!call.status || call.status.code === 0) {
|
|
96
|
-
finishChannel.publish()
|
|
100
|
+
finishChannel.publish(ctx)
|
|
97
101
|
}
|
|
98
|
-
|
|
99
102
|
call.removeListener('cancelled', onCancel)
|
|
100
|
-
|
|
101
103
|
break
|
|
102
104
|
}
|
|
103
105
|
|
|
104
106
|
return emit.apply(this, arguments)
|
|
105
107
|
}
|
|
106
|
-
}
|
|
108
|
+
}
|
|
107
109
|
}
|
|
108
110
|
|
|
109
|
-
function
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
errorChannel.publish(err)
|
|
114
|
-
finishChannel.publish(err)
|
|
115
|
-
} else {
|
|
116
|
-
finishChannel.publish({ code: OK, trailer })
|
|
117
|
-
}
|
|
111
|
+
function wrapStream (call, ctx, onCancel) {
|
|
112
|
+
if (call.call && call.call.sendStatus) {
|
|
113
|
+
call.call.sendStatus = wrapSendStatus(call.call.sendStatus, ctx)
|
|
114
|
+
}
|
|
118
115
|
|
|
119
|
-
|
|
120
|
-
|
|
116
|
+
shimmer.wrap(call, 'emit', createWrapEmit(call, ctx, onCancel))
|
|
117
|
+
}
|
|
121
118
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
119
|
+
function wrapCallback (callback = () => {}, call, ctx, onCancel) {
|
|
120
|
+
return function (err, value, trailer, flags) {
|
|
121
|
+
if (err) {
|
|
122
|
+
ctx.error = err
|
|
123
|
+
errorChannel.publish(ctx)
|
|
124
|
+
} else {
|
|
125
|
+
ctx.code = OK
|
|
126
|
+
ctx.trailer = trailer
|
|
126
127
|
}
|
|
128
|
+
|
|
129
|
+
finishChannel.publish(ctx)
|
|
130
|
+
|
|
131
|
+
call.removeListener('cancelled', onCancel)
|
|
132
|
+
|
|
133
|
+
return asyncStartChannel.runStores(ctx, () => {
|
|
134
|
+
return callback.apply(this, arguments)
|
|
135
|
+
// No async end channel needed
|
|
136
|
+
})
|
|
127
137
|
}
|
|
128
138
|
}
|
|
129
139
|
|
|
130
|
-
function wrapSendStatus (sendStatus,
|
|
140
|
+
function wrapSendStatus (sendStatus, ctx) {
|
|
131
141
|
return function (status) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
})
|
|
142
|
+
ctx.status = status
|
|
143
|
+
updateChannel.publish(ctx)
|
|
135
144
|
|
|
136
145
|
return sendStatus.apply(this, arguments)
|
|
137
146
|
}
|
|
@@ -1,32 +1,27 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const shimmer = require('../../../datadog-shimmer')
|
|
4
|
-
const { addHook, channel
|
|
4
|
+
const { addHook, channel } = require('../helpers/instrument')
|
|
5
5
|
|
|
6
6
|
const connectChannel = channel('apm:http2:client:connect:start')
|
|
7
7
|
const startChannel = channel('apm:http2:client:request:start')
|
|
8
|
-
const
|
|
8
|
+
const endChannel = channel('apm:http2:client:request:end')
|
|
9
|
+
const asyncStartChannel = channel('apm:http2:client:request:asyncStart')
|
|
10
|
+
const asyncEndChannel = channel('apm:http2:client:request:asyncEnd')
|
|
9
11
|
const errorChannel = channel('apm:http2:client:request:error')
|
|
10
|
-
const responseChannel = channel('apm:http2:client:response')
|
|
11
12
|
|
|
12
|
-
function createWrapEmit (
|
|
13
|
+
function createWrapEmit (ctx) {
|
|
13
14
|
return function wrapEmit (emit) {
|
|
14
15
|
return function (event, arg1) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
case 'response':
|
|
18
|
-
responseChannel.publish(arg1)
|
|
19
|
-
break
|
|
20
|
-
case 'error':
|
|
21
|
-
errorChannel.publish(arg1)
|
|
22
|
-
case 'close': // eslint-disable-line no-fallthrough
|
|
23
|
-
finishChannel.publish()
|
|
24
|
-
break
|
|
25
|
-
}
|
|
26
|
-
})
|
|
16
|
+
ctx.eventName = event
|
|
17
|
+
ctx.eventData = arg1
|
|
27
18
|
|
|
28
|
-
return
|
|
29
|
-
|
|
19
|
+
return asyncStartChannel.runStores(ctx, () => {
|
|
20
|
+
try {
|
|
21
|
+
return emit.apply(this, arguments)
|
|
22
|
+
} finally {
|
|
23
|
+
asyncEndChannel.publish(ctx)
|
|
24
|
+
}
|
|
30
25
|
})
|
|
31
26
|
}
|
|
32
27
|
}
|
|
@@ -35,17 +30,21 @@ function createWrapEmit (requestResource, parentResource) {
|
|
|
35
30
|
function createWrapRequest (authority, options) {
|
|
36
31
|
return function wrapRequest (request) {
|
|
37
32
|
return function (headers) {
|
|
38
|
-
const
|
|
39
|
-
const requestResource = new AsyncResource('bound-anonymous-fn')
|
|
33
|
+
const ctx = { headers, authority, options }
|
|
40
34
|
|
|
41
|
-
return
|
|
42
|
-
|
|
35
|
+
return startChannel.runStores(ctx, () => {
|
|
36
|
+
try {
|
|
37
|
+
const req = request.apply(this, arguments)
|
|
43
38
|
|
|
44
|
-
|
|
39
|
+
shimmer.wrap(req, 'emit', createWrapEmit(ctx))
|
|
45
40
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
return req
|
|
42
|
+
} catch (e) {
|
|
43
|
+
ctx.error = e
|
|
44
|
+
errorChannel.publish(ctx)
|
|
45
|
+
} finally {
|
|
46
|
+
endChannel.publish(ctx)
|
|
47
|
+
}
|
|
49
48
|
})
|
|
50
49
|
}
|
|
51
50
|
}
|
|
@@ -42,6 +42,7 @@ const jestItrConfigurationCh = channel('ci:jest:itr-configuration')
|
|
|
42
42
|
let skippableSuites = []
|
|
43
43
|
let isCodeCoverageEnabled = false
|
|
44
44
|
let isSuitesSkippingEnabled = false
|
|
45
|
+
let isSuitesSkipped = false
|
|
45
46
|
|
|
46
47
|
const sessionAsyncResource = new AsyncResource('bound-anonymous-fn')
|
|
47
48
|
|
|
@@ -128,8 +129,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
|
|
|
128
129
|
suite: this.testSuite,
|
|
129
130
|
runner: 'jest-circus',
|
|
130
131
|
testParameters,
|
|
131
|
-
frameworkVersion: jestVersion
|
|
132
|
-
testStartLine: getTestLineStart(event.test.asyncError, this.testSuite)
|
|
132
|
+
frameworkVersion: jestVersion
|
|
133
133
|
})
|
|
134
134
|
originalTestFns.set(event.test, event.test.fn)
|
|
135
135
|
event.test.fn = asyncResource.bind(event.test.fn)
|
|
@@ -144,7 +144,10 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
|
|
|
144
144
|
const formattedError = formatJestError(event.test.errors[0])
|
|
145
145
|
testErrCh.publish(formattedError)
|
|
146
146
|
}
|
|
147
|
-
testRunFinishCh.publish(
|
|
147
|
+
testRunFinishCh.publish({
|
|
148
|
+
status,
|
|
149
|
+
testStartLine: getTestLineStart(event.test.asyncError, this.testSuite)
|
|
150
|
+
})
|
|
148
151
|
// restore in case it is retried
|
|
149
152
|
event.test.fn = originalTestFns.get(event.test)
|
|
150
153
|
})
|
|
@@ -227,7 +230,6 @@ function cliWrapper (cli, jestVersion) {
|
|
|
227
230
|
log.error(err)
|
|
228
231
|
}
|
|
229
232
|
}
|
|
230
|
-
const isSuitesSkipped = !!skippableSuites.length
|
|
231
233
|
|
|
232
234
|
const processArgv = process.argv.slice(2).join(' ')
|
|
233
235
|
sessionAsyncResource.runInAsyncScope(() => {
|
|
@@ -430,6 +432,8 @@ addHook({
|
|
|
430
432
|
|
|
431
433
|
const filteredTests = getJestSuitesToRun(skippableSuites, tests, rootDir)
|
|
432
434
|
|
|
435
|
+
isSuitesSkipped = filteredTests.length !== tests.length
|
|
436
|
+
|
|
433
437
|
skippableSuites = []
|
|
434
438
|
|
|
435
439
|
return { ...testPaths, tests: filteredTests }
|
|
@@ -469,7 +473,7 @@ function jasmineAsyncInstallWraper (jasmineAsyncInstallExport, jestVersion) {
|
|
|
469
473
|
const formattedError = formatJestError(spec.result.failedExpectations[0].error)
|
|
470
474
|
testErrCh.publish(formattedError)
|
|
471
475
|
}
|
|
472
|
-
testRunFinishCh.publish(specStatusToTestStatus[spec.result.status])
|
|
476
|
+
testRunFinishCh.publish({ status: specStatusToTestStatus[spec.result.status] })
|
|
473
477
|
onComplete.apply(this, arguments)
|
|
474
478
|
})
|
|
475
479
|
arguments[0] = callback
|
|
@@ -46,6 +46,7 @@ const originalCoverageMap = createCoverageMap()
|
|
|
46
46
|
|
|
47
47
|
let suitesToSkip = []
|
|
48
48
|
let frameworkVersion
|
|
49
|
+
let isSuitesSkipped = false
|
|
49
50
|
|
|
50
51
|
function getSuitesByTestFile (root) {
|
|
51
52
|
const suitesByTestFile = {}
|
|
@@ -125,8 +126,6 @@ function mochaHook (Runner) {
|
|
|
125
126
|
}
|
|
126
127
|
testFileToSuiteAr.clear()
|
|
127
128
|
|
|
128
|
-
const isSuitesSkipped = !!suitesToSkip.length
|
|
129
|
-
|
|
130
129
|
let testCodeCoverageLinesTotal
|
|
131
130
|
if (global.__coverage__) {
|
|
132
131
|
try {
|
|
@@ -360,7 +359,10 @@ addHook({
|
|
|
360
359
|
suitesToSkip = skippableSuites
|
|
361
360
|
}
|
|
362
361
|
// We remove the suites that we skip through ITR
|
|
363
|
-
|
|
362
|
+
const newSuites = getSuitesToRun(runner.suite.suites)
|
|
363
|
+
isSuitesSkipped = newSuites.length !== runner.suite.suites.length
|
|
364
|
+
runner.suite.suites = newSuites
|
|
365
|
+
|
|
364
366
|
global.run()
|
|
365
367
|
}
|
|
366
368
|
|
|
@@ -37,7 +37,7 @@ const CYPRESS_STATUS_TO_TEST_STATUS = {
|
|
|
37
37
|
function getTestSpanMetadata (tracer, testName, testSuite, cypressConfig) {
|
|
38
38
|
const childOf = getTestParentSpan(tracer)
|
|
39
39
|
|
|
40
|
-
const commonTags = getTestCommonTags(testName, testSuite, cypressConfig.version)
|
|
40
|
+
const commonTags = getTestCommonTags(testName, testSuite, cypressConfig.version, TEST_FRAMEWORK_NAME)
|
|
41
41
|
|
|
42
42
|
return {
|
|
43
43
|
childOf,
|
|
@@ -119,6 +119,7 @@ function getSkippableTests (isSuitesSkippingEnabled, tracer, testConfiguration)
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
module.exports = (on, config) => {
|
|
122
|
+
let isTestsSkipped = false
|
|
122
123
|
const tracer = require('../../dd-trace')
|
|
123
124
|
const testEnvironmentMetadata = getTestEnvironmentMetadata(TEST_FRAMEWORK_NAME)
|
|
124
125
|
|
|
@@ -306,7 +307,7 @@ module.exports = (on, config) => {
|
|
|
306
307
|
testSessionSpan,
|
|
307
308
|
testModuleSpan,
|
|
308
309
|
{
|
|
309
|
-
isSuitesSkipped:
|
|
310
|
+
isSuitesSkipped: isTestsSkipped,
|
|
310
311
|
isSuitesSkippingEnabled,
|
|
311
312
|
isCodeCoverageEnabled
|
|
312
313
|
}
|
|
@@ -352,6 +353,7 @@ module.exports = (on, config) => {
|
|
|
352
353
|
if (testsToSkip.find(test => {
|
|
353
354
|
return testName === test.name && testSuite === test.suite
|
|
354
355
|
})) {
|
|
356
|
+
isTestsSkipped = true
|
|
355
357
|
return { shouldSkip: true }
|
|
356
358
|
}
|
|
357
359
|
|
|
@@ -7,6 +7,8 @@ let tools
|
|
|
7
7
|
class GraphQLExecutePlugin extends TracingPlugin {
|
|
8
8
|
static get id () { return 'graphql' }
|
|
9
9
|
static get operation () { return 'execute' }
|
|
10
|
+
static get type () { return 'graphql' }
|
|
11
|
+
static get kind () { return 'server' }
|
|
10
12
|
|
|
11
13
|
start ({ operation, args, docSource }) {
|
|
12
14
|
const type = operation && operation.operation
|
|
@@ -14,11 +16,11 @@ class GraphQLExecutePlugin extends TracingPlugin {
|
|
|
14
16
|
const document = args.document
|
|
15
17
|
const source = this.config.source && document && docSource
|
|
16
18
|
|
|
17
|
-
const span = this.startSpan(
|
|
18
|
-
service: this.config.service,
|
|
19
|
+
const span = this.startSpan(this.operationName(), {
|
|
20
|
+
service: this.config.service || this.serviceName(),
|
|
19
21
|
resource: getSignature(document, name, type, this.config.signature),
|
|
20
|
-
kind:
|
|
21
|
-
type:
|
|
22
|
+
kind: this.constructor.kind,
|
|
23
|
+
type: this.constructor.type,
|
|
22
24
|
meta: {
|
|
23
25
|
'graphql.operation.type': type,
|
|
24
26
|
'graphql.operation.name': name,
|