dd-trace 3.4.0 → 3.6.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/index.d.ts +40 -2
- package/package.json +1 -1
- package/packages/datadog-instrumentations/src/cucumber.js +0 -2
- package/packages/datadog-instrumentations/src/elasticsearch.js +51 -47
- package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +1 -1
- package/packages/datadog-instrumentations/src/helpers/hooks.js +1 -0
- package/packages/datadog-instrumentations/src/mariadb.js +43 -69
- package/packages/datadog-instrumentations/src/mocha.js +14 -18
- package/packages/datadog-instrumentations/src/opensearch.js +10 -0
- package/packages/datadog-instrumentations/src/pg.js +2 -1
- package/packages/datadog-instrumentations/src/restify.js +1 -0
- package/packages/datadog-instrumentations/src/rhea.js +20 -17
- package/packages/datadog-plugin-amqp10/src/consumer.js +32 -0
- package/packages/datadog-plugin-amqp10/src/index.js +11 -101
- package/packages/datadog-plugin-amqp10/src/producer.js +34 -0
- package/packages/datadog-plugin-amqp10/src/util.js +15 -0
- package/packages/datadog-plugin-amqplib/src/client.js +38 -0
- package/packages/datadog-plugin-amqplib/src/consumer.js +40 -0
- package/packages/datadog-plugin-amqplib/src/index.js +14 -102
- package/packages/datadog-plugin-amqplib/src/producer.js +37 -0
- package/packages/datadog-plugin-amqplib/src/util.js +14 -0
- package/packages/datadog-plugin-dns/src/index.js +16 -91
- package/packages/datadog-plugin-dns/src/lookup.js +40 -0
- package/packages/datadog-plugin-dns/src/lookup_service.js +24 -0
- package/packages/datadog-plugin-dns/src/resolve.js +24 -0
- package/packages/datadog-plugin-dns/src/reverse.js +21 -0
- package/packages/datadog-plugin-elasticsearch/src/index.js +7 -7
- package/packages/datadog-plugin-google-cloud-pubsub/src/client.js +25 -0
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +42 -0
- package/packages/datadog-plugin-google-cloud-pubsub/src/index.js +14 -99
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +34 -0
- package/packages/datadog-plugin-graphql/src/execute.js +73 -0
- package/packages/datadog-plugin-graphql/src/index.js +14 -176
- package/packages/datadog-plugin-graphql/src/parse.js +32 -0
- package/packages/datadog-plugin-graphql/src/resolve.js +70 -76
- package/packages/datadog-plugin-graphql/src/validate.js +28 -0
- package/packages/datadog-plugin-grpc/src/client.js +46 -55
- package/packages/datadog-plugin-grpc/src/index.js +7 -24
- package/packages/datadog-plugin-grpc/src/server.js +50 -52
- package/packages/datadog-plugin-grpc/src/util.js +15 -14
- package/packages/datadog-plugin-http/src/index.js +7 -22
- package/packages/datadog-plugin-http2/src/index.js +8 -26
- package/packages/datadog-plugin-jest/src/index.js +3 -0
- package/packages/datadog-plugin-kafkajs/src/consumer.js +42 -0
- package/packages/datadog-plugin-kafkajs/src/index.js +11 -87
- package/packages/datadog-plugin-kafkajs/src/producer.js +31 -0
- package/packages/datadog-plugin-mocha/src/index.js +2 -2
- package/packages/datadog-plugin-moleculer/src/client.js +22 -36
- package/packages/datadog-plugin-moleculer/src/index.js +8 -26
- package/packages/datadog-plugin-moleculer/src/server.js +18 -30
- package/packages/datadog-plugin-net/src/ipc.js +21 -0
- package/packages/datadog-plugin-net/src/tcp.js +46 -0
- package/packages/datadog-plugin-opensearch/src/index.js +11 -0
- package/packages/datadog-plugin-pg/src/index.js +2 -1
- package/packages/datadog-plugin-rhea/src/consumer.js +55 -0
- package/packages/datadog-plugin-rhea/src/index.js +11 -99
- package/packages/datadog-plugin-rhea/src/producer.js +45 -0
- package/packages/datadog-plugin-sharedb/src/index.js +22 -39
- package/packages/dd-trace/src/appsec/iast/analyzers/vulnerability-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/index.js +4 -6
- package/packages/dd-trace/src/appsec/iast/path-line.js +3 -0
- package/packages/dd-trace/src/appsec/recommended.json +60 -46
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +2 -5
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +2 -5
- package/packages/dd-trace/src/config.js +26 -6
- package/packages/dd-trace/src/constants.js +3 -0
- package/packages/dd-trace/src/dogstatsd.js +42 -10
- package/packages/dd-trace/src/encode/agentless-ci-visibility.js +10 -2
- package/packages/dd-trace/src/exporters/agent/writer.js +2 -9
- package/packages/dd-trace/src/exporters/common/request.js +12 -0
- package/packages/dd-trace/src/format.js +13 -0
- package/packages/dd-trace/src/metrics.js +10 -2
- package/packages/dd-trace/src/plugins/client.js +3 -1
- package/packages/dd-trace/src/plugins/composite.js +26 -0
- package/packages/dd-trace/src/plugins/consumer.js +9 -0
- package/packages/dd-trace/src/plugins/incoming.js +7 -0
- package/packages/dd-trace/src/plugins/index.js +1 -0
- package/packages/dd-trace/src/plugins/outgoing.js +1 -1
- package/packages/dd-trace/src/plugins/producer.js +9 -0
- package/packages/dd-trace/src/plugins/server.js +9 -0
- package/packages/dd-trace/src/plugins/storage.js +0 -4
- package/packages/dd-trace/src/plugins/tracing.js +10 -9
- package/packages/dd-trace/src/profiling/profiler.js +8 -1
- package/packages/dd-trace/src/span_processor.js +3 -0
- package/packages/dd-trace/src/span_sampler.js +80 -0
- package/packages/dd-trace/src/tracer.js +6 -2
- package/packages/dd-trace/src/util.js +43 -1
package/index.d.ts
CHANGED
|
@@ -189,6 +189,31 @@ export declare interface SamplingRule {
|
|
|
189
189
|
name?: string | RegExp
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
+
/**
|
|
193
|
+
* Span sampling rules to ingest single spans where the enclosing trace is dropped
|
|
194
|
+
*/
|
|
195
|
+
export declare interface SpanSamplingRule {
|
|
196
|
+
/**
|
|
197
|
+
* Sampling rate for this rule. Will default to 1.0 (always) if not provided.
|
|
198
|
+
*/
|
|
199
|
+
sampleRate?: Number
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Maximum number of spans matching a span sampling rule to be allowed per second.
|
|
203
|
+
*/
|
|
204
|
+
maxPerSecond?: Number
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Service name or pattern on which to apply this rule. The rule will apply to all services if not provided.
|
|
208
|
+
*/
|
|
209
|
+
service?: string
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Operation name or pattern on which to apply this rule. The rule will apply to all operation names if not provided.
|
|
213
|
+
*/
|
|
214
|
+
name?: string
|
|
215
|
+
}
|
|
216
|
+
|
|
192
217
|
/**
|
|
193
218
|
* List of options available to the tracer.
|
|
194
219
|
*/
|
|
@@ -283,6 +308,12 @@ export declare interface TracerOptions {
|
|
|
283
308
|
*/
|
|
284
309
|
samplingRules?: SamplingRule[]
|
|
285
310
|
|
|
311
|
+
/**
|
|
312
|
+
* Span sampling rules that take effect when the enclosing trace is dropped, to ingest single spans
|
|
313
|
+
* @default []
|
|
314
|
+
*/
|
|
315
|
+
spanSamplingRules?: SpanSamplingRule[]
|
|
316
|
+
|
|
286
317
|
/**
|
|
287
318
|
* Interval in milliseconds at which the tracer will submit traces to the agent.
|
|
288
319
|
* @default 2000
|
|
@@ -598,6 +629,7 @@ interface Plugins {
|
|
|
598
629
|
"mysql2": plugins.mysql2;
|
|
599
630
|
"net": plugins.net;
|
|
600
631
|
"next": plugins.next;
|
|
632
|
+
"opensearch": plugins.opensearch;
|
|
601
633
|
"oracledb": plugins.oracledb;
|
|
602
634
|
"paperplane": plugins.paperplane;
|
|
603
635
|
"pg": plugins.pg;
|
|
@@ -730,7 +762,7 @@ declare namespace plugins {
|
|
|
730
762
|
* status code as its only parameter and return `true` for success or `false`
|
|
731
763
|
* for errors.
|
|
732
764
|
*
|
|
733
|
-
* @default code => code < 400
|
|
765
|
+
* @default code => code < 400 || code >= 500
|
|
734
766
|
*/
|
|
735
767
|
validateStatus?: (code: number) => boolean;
|
|
736
768
|
|
|
@@ -764,7 +796,7 @@ declare namespace plugins {
|
|
|
764
796
|
* status code as its only parameter and return `true` for success or `false`
|
|
765
797
|
* for errors.
|
|
766
798
|
*
|
|
767
|
-
* @default code => code < 400
|
|
799
|
+
* @default code => code < 400 || code >= 500
|
|
768
800
|
*/
|
|
769
801
|
validateStatus?: (code: number) => boolean;
|
|
770
802
|
}
|
|
@@ -1255,6 +1287,12 @@ declare namespace plugins {
|
|
|
1255
1287
|
};
|
|
1256
1288
|
}
|
|
1257
1289
|
|
|
1290
|
+
/**
|
|
1291
|
+
* This plugin automatically instruments the
|
|
1292
|
+
* [opensearch](https://github.com/opensearch-project/opensearch-js) module.
|
|
1293
|
+
*/
|
|
1294
|
+
interface opensearch extends elasticsearch {}
|
|
1295
|
+
|
|
1258
1296
|
/**
|
|
1259
1297
|
* This plugin automatically instruments the
|
|
1260
1298
|
* [oracledb](https://github.com/oracle/node-oracledb) module.
|
package/package.json
CHANGED
|
@@ -7,76 +7,80 @@ const {
|
|
|
7
7
|
} = require('./helpers/instrument')
|
|
8
8
|
const shimmer = require('../../datadog-shimmer')
|
|
9
9
|
|
|
10
|
-
const startCh = channel('apm:elasticsearch:query:start')
|
|
11
|
-
const finishCh = channel('apm:elasticsearch:query:finish')
|
|
12
|
-
const errorCh = channel('apm:elasticsearch:query:error')
|
|
13
|
-
|
|
14
10
|
addHook({ name: '@elastic/transport', file: 'lib/Transport.js', versions: ['>=8'] }, (exports) => {
|
|
15
|
-
shimmer.wrap(exports.default.prototype, 'request',
|
|
11
|
+
shimmer.wrap(exports.default.prototype, 'request', createWrapRequest('elasticsearch'))
|
|
16
12
|
return exports
|
|
17
13
|
})
|
|
18
14
|
|
|
19
15
|
addHook({ name: '@elastic/elasticsearch', file: 'lib/Transport.js', versions: ['>=5.6.16 <8', '>=8'] }, Transport => {
|
|
20
|
-
shimmer.wrap(Transport.prototype, 'request',
|
|
16
|
+
shimmer.wrap(Transport.prototype, 'request', createWrapRequest('elasticsearch'))
|
|
21
17
|
return Transport
|
|
22
18
|
})
|
|
23
19
|
|
|
24
20
|
addHook({ name: 'elasticsearch', file: 'src/lib/transport.js', versions: ['>=10'] }, Transport => {
|
|
25
|
-
shimmer.wrap(Transport.prototype, 'request',
|
|
21
|
+
shimmer.wrap(Transport.prototype, 'request', createWrapRequest('elasticsearch'))
|
|
26
22
|
return Transport
|
|
27
23
|
})
|
|
28
24
|
|
|
29
|
-
function
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
25
|
+
function createWrapRequest (name) {
|
|
26
|
+
const startCh = channel(`apm:${name}:query:start`)
|
|
27
|
+
const finishCh = channel(`apm:${name}:query:finish`)
|
|
28
|
+
const errorCh = channel(`apm:${name}:query:error`)
|
|
34
29
|
|
|
35
|
-
|
|
30
|
+
return function wrapRequest (request) {
|
|
31
|
+
return function (params, options, cb) {
|
|
32
|
+
if (!startCh.hasSubscribers) {
|
|
33
|
+
return request.apply(this, arguments)
|
|
34
|
+
}
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
const asyncResource = new AsyncResource('bound-anonymous-fn')
|
|
36
|
+
if (!params) return request.apply(this, arguments)
|
|
39
37
|
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
const parentResource = new AsyncResource('bound-anonymous-fn')
|
|
39
|
+
const asyncResource = new AsyncResource('bound-anonymous-fn')
|
|
42
40
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
cb = arguments[lastIndex]
|
|
41
|
+
return asyncResource.runInAsyncScope(() => {
|
|
42
|
+
startCh.publish({ params })
|
|
46
43
|
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
try {
|
|
45
|
+
const lastIndex = arguments.length - 1
|
|
46
|
+
cb = arguments[lastIndex]
|
|
49
47
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return cb.apply(null, arguments)
|
|
53
|
-
})
|
|
54
|
-
return request.apply(this, arguments)
|
|
55
|
-
} else {
|
|
56
|
-
const promise = request.apply(this, arguments)
|
|
57
|
-
if (promise && typeof promise.then === 'function') {
|
|
58
|
-
const onResolve = asyncResource.bind(() => finish(params))
|
|
59
|
-
const onReject = asyncResource.bind(e => finish(params, e))
|
|
48
|
+
if (typeof cb === 'function') {
|
|
49
|
+
cb = parentResource.bind(cb)
|
|
60
50
|
|
|
61
|
-
|
|
51
|
+
arguments[lastIndex] = asyncResource.bind(function (error) {
|
|
52
|
+
finish(params, error)
|
|
53
|
+
return cb.apply(null, arguments)
|
|
54
|
+
})
|
|
55
|
+
return request.apply(this, arguments)
|
|
62
56
|
} else {
|
|
63
|
-
|
|
57
|
+
const promise = request.apply(this, arguments)
|
|
58
|
+
if (promise && typeof promise.then === 'function') {
|
|
59
|
+
const onResolve = asyncResource.bind(() => finish(params))
|
|
60
|
+
const onReject = asyncResource.bind(e => finish(params, e))
|
|
61
|
+
|
|
62
|
+
promise.then(onResolve, onReject)
|
|
63
|
+
} else {
|
|
64
|
+
finish(params)
|
|
65
|
+
}
|
|
66
|
+
return promise
|
|
64
67
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
err.stack // trigger getting the stack at the original throwing point
|
|
69
|
-
errorCh.publish(err)
|
|
68
|
+
} catch (err) {
|
|
69
|
+
err.stack // trigger getting the stack at the original throwing point
|
|
70
|
+
errorCh.publish(err)
|
|
70
71
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
throw err
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
}
|
|
74
76
|
}
|
|
75
|
-
}
|
|
76
77
|
|
|
77
|
-
function finish (params, error) {
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
function finish (params, error) {
|
|
79
|
+
if (error) {
|
|
80
|
+
errorCh.publish(error)
|
|
81
|
+
}
|
|
82
|
+
finishCh.publish({ params })
|
|
80
83
|
}
|
|
81
|
-
finishCh.publish({ params })
|
|
82
84
|
}
|
|
85
|
+
|
|
86
|
+
module.exports = { createWrapRequest }
|
|
@@ -10,6 +10,7 @@ module.exports = {
|
|
|
10
10
|
'@jest/core': () => require('../jest'),
|
|
11
11
|
'@koa/router': () => require('../koa'),
|
|
12
12
|
'@node-redis/client': () => require('../redis'),
|
|
13
|
+
'@opensearch-project/opensearch': () => require('../opensearch'),
|
|
13
14
|
'@redis/client': () => require('../redis'),
|
|
14
15
|
'amqp10': () => require('../amqp10'),
|
|
15
16
|
'amqplib': () => require('../amqplib'),
|
|
@@ -8,82 +8,56 @@ const startCh = channel('apm:mariadb:query:start')
|
|
|
8
8
|
const finishCh = channel('apm:mariadb:query:finish')
|
|
9
9
|
const errorCh = channel('apm:mariadb:query:error')
|
|
10
10
|
|
|
11
|
-
function
|
|
12
|
-
return function (
|
|
13
|
-
if (!startCh.hasSubscribers) return
|
|
11
|
+
function wrapCommandStart (start) {
|
|
12
|
+
return function () {
|
|
13
|
+
if (!startCh.hasSubscribers) return start.apply(this, arguments)
|
|
14
14
|
|
|
15
|
-
const
|
|
16
|
-
const name = cmd && cmd.constructor && cmd.constructor.name
|
|
17
|
-
const isCommand = typeof cmd.start === 'function'
|
|
18
|
-
const isQuery = isCommand && (name === 'Execute' || name === 'Query')
|
|
19
|
-
|
|
20
|
-
// TODO: consider supporting all commands and not just queries
|
|
21
|
-
cmd.start = isQuery
|
|
22
|
-
? wrapStart(cmd, cmd.start, asyncResource, this.opts)
|
|
23
|
-
: bindStart(cmd, cmd.start, asyncResource)
|
|
24
|
-
|
|
25
|
-
return asyncResource.bind(addCommand, this).apply(this, arguments)
|
|
26
|
-
}
|
|
27
|
-
}
|
|
15
|
+
const callbackResource = new AsyncResource('bound-anonymous-fn')
|
|
28
16
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (this.resolve) {
|
|
32
|
-
this.resolve = asyncResource.bind(this.resolve)
|
|
33
|
-
}
|
|
17
|
+
const resolve = callbackResource.bind(this.resolve)
|
|
18
|
+
const reject = callbackResource.bind(this.reject)
|
|
34
19
|
|
|
35
|
-
|
|
36
|
-
this.reject = asyncResource.bind(this.reject)
|
|
37
|
-
}
|
|
20
|
+
const asyncResource = new AsyncResource('bound-anonymous-fn')
|
|
38
21
|
|
|
39
|
-
|
|
40
|
-
|
|
22
|
+
shimmer.wrap(this, 'resolve', function wrapResolve () {
|
|
23
|
+
return function () {
|
|
24
|
+
asyncResource.runInAsyncScope(() => {
|
|
25
|
+
finishCh.publish()
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
return resolve.apply(this, arguments)
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
shimmer.wrap(this, 'reject', function wrapReject () {
|
|
33
|
+
return function (error) {
|
|
34
|
+
asyncResource.runInAsyncScope(() => {
|
|
35
|
+
errorCh.publish(error)
|
|
36
|
+
finishCh.publish()
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
return reject.apply(this, arguments)
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
return asyncResource.runInAsyncScope(() => {
|
|
44
|
+
startCh.publish({ sql: this.sql, conf: this.opts })
|
|
45
|
+
return start.apply(this, arguments)
|
|
46
|
+
})
|
|
47
|
+
}
|
|
41
48
|
}
|
|
42
49
|
|
|
43
|
-
|
|
44
|
-
|
|
50
|
+
const name = 'mariadb'
|
|
51
|
+
const versions = ['>=2.0.3']
|
|
45
52
|
|
|
46
|
-
|
|
47
|
-
|
|
53
|
+
addHook({ name, file: 'lib/cmd/query.js', versions }, (Query) => {
|
|
54
|
+
shimmer.wrap(Query.prototype, 'start', wrapCommandStart)
|
|
48
55
|
|
|
49
|
-
|
|
56
|
+
return Query
|
|
57
|
+
})
|
|
50
58
|
|
|
51
|
-
|
|
59
|
+
addHook({ name, file: 'lib/cmd/execute.js', versions }, (Query) => {
|
|
60
|
+
shimmer.wrap(Query.prototype, 'start', wrapCommandStart)
|
|
52
61
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
this.resolve = asyncResource.bind(function () {
|
|
57
|
-
finishCh.publish(undefined)
|
|
58
|
-
resolve.apply(this, arguments)
|
|
59
|
-
}, 'bound-anonymous-fn', this)
|
|
60
|
-
|
|
61
|
-
this.reject = asyncResource.bind(function (error) {
|
|
62
|
-
errorCh.publish(error)
|
|
63
|
-
finishCh.publish(undefined)
|
|
64
|
-
reject.apply(this, arguments)
|
|
65
|
-
}, 'bound-anonymous-fn', this)
|
|
66
|
-
|
|
67
|
-
this.start = start
|
|
68
|
-
|
|
69
|
-
try {
|
|
70
|
-
return start.apply(this, arguments)
|
|
71
|
-
} catch (err) {
|
|
72
|
-
errorCh.publish(err)
|
|
73
|
-
}
|
|
74
|
-
}, cmd)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
addHook(
|
|
78
|
-
{
|
|
79
|
-
name: 'mariadb',
|
|
80
|
-
file: 'lib/connection.js',
|
|
81
|
-
versions: ['>=3']
|
|
82
|
-
},
|
|
83
|
-
(Connection) => {
|
|
84
|
-
shimmer.wrap(Connection.prototype, 'addCommandEnable', wrapConnectionAddCommand)
|
|
85
|
-
shimmer.wrap(Connection.prototype, 'addCommandEnablePipeline', wrapConnectionAddCommand)
|
|
86
|
-
|
|
87
|
-
return Connection
|
|
88
|
-
}
|
|
89
|
-
)
|
|
62
|
+
return Query
|
|
63
|
+
})
|
|
@@ -7,8 +7,8 @@ const skipCh = channel('ci:mocha:test:skip')
|
|
|
7
7
|
const testFinishCh = channel('ci:mocha:test:finish')
|
|
8
8
|
const parameterizedTestCh = channel('ci:mocha:test:parameterize')
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
const
|
|
10
|
+
const testSessionStartCh = channel('ci:mocha:session:start')
|
|
11
|
+
const testSessionFinishCh = channel('ci:mocha:session:finish')
|
|
12
12
|
|
|
13
13
|
const testSuiteStartCh = channel('ci:mocha:test-suite:start')
|
|
14
14
|
const testSuiteFinishCh = channel('ci:mocha:test-suite:finish')
|
|
@@ -92,13 +92,13 @@ function mochaHook (Runner) {
|
|
|
92
92
|
status = 'fail'
|
|
93
93
|
}
|
|
94
94
|
testFileToSuiteAr.clear()
|
|
95
|
-
|
|
95
|
+
testSessionFinishCh.publish(status)
|
|
96
96
|
}))
|
|
97
97
|
|
|
98
98
|
this.once('start', testRunAsyncResource.bind(function () {
|
|
99
99
|
const processArgv = process.argv.slice(2).join(' ')
|
|
100
100
|
const command = `mocha ${processArgv}`
|
|
101
|
-
|
|
101
|
+
testSessionStartCh.publish(command)
|
|
102
102
|
}))
|
|
103
103
|
|
|
104
104
|
this.on('suite', function (suite) {
|
|
@@ -245,13 +245,6 @@ function mochaHook (Runner) {
|
|
|
245
245
|
return run.apply(this, arguments)
|
|
246
246
|
})
|
|
247
247
|
|
|
248
|
-
shimmer.wrap(Runner.prototype, 'runTests', runTests => function () {
|
|
249
|
-
if (!testRunFinishCh.hasSubscribers) {
|
|
250
|
-
return runTests.apply(this, arguments)
|
|
251
|
-
}
|
|
252
|
-
return runTests.apply(this, arguments)
|
|
253
|
-
})
|
|
254
|
-
|
|
255
248
|
return Runner
|
|
256
249
|
}
|
|
257
250
|
|
|
@@ -285,6 +278,9 @@ addHook({
|
|
|
285
278
|
file: 'lib/runnable.js'
|
|
286
279
|
}, (Runnable) => {
|
|
287
280
|
shimmer.wrap(Runnable.prototype, 'run', run => function () {
|
|
281
|
+
if (!testStartCh.hasSubscribers) {
|
|
282
|
+
return run.apply(this, arguments)
|
|
283
|
+
}
|
|
288
284
|
const isBeforeEach = this.parent._beforeEach.includes(this)
|
|
289
285
|
const isAfterEach = this.parent._afterEach.includes(this)
|
|
290
286
|
|
|
@@ -300,13 +296,15 @@ addHook({
|
|
|
300
296
|
const test = isTestHook ? this.ctx.currentTest : this
|
|
301
297
|
const asyncResource = getTestAsyncResource(test)
|
|
302
298
|
|
|
303
|
-
|
|
304
|
-
|
|
299
|
+
if (asyncResource) {
|
|
300
|
+
// we bind the test fn to the correct async resource
|
|
301
|
+
const newFn = asyncResource.bind(this.fn)
|
|
305
302
|
|
|
306
|
-
|
|
307
|
-
|
|
303
|
+
// we store the original function, not to lose it
|
|
304
|
+
originalFns.set(newFn, this.fn)
|
|
308
305
|
|
|
309
|
-
|
|
306
|
+
this.fn = newFn
|
|
307
|
+
}
|
|
310
308
|
}
|
|
311
309
|
|
|
312
310
|
return run.apply(this, arguments)
|
|
@@ -318,5 +316,3 @@ addHook({
|
|
|
318
316
|
name: 'mocha-each',
|
|
319
317
|
versions: ['>=2.0.1']
|
|
320
318
|
}, mochaEachHook)
|
|
321
|
-
|
|
322
|
-
module.exports = { mochaHook, mochaEachHook }
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { addHook } = require('./helpers/instrument')
|
|
4
|
+
const shimmer = require('../../datadog-shimmer')
|
|
5
|
+
const { createWrapRequest } = require('./elasticsearch')
|
|
6
|
+
|
|
7
|
+
addHook({ name: '@opensearch-project/opensearch', file: 'lib/Transport.js', versions: ['1.1.0'] }, Transport => {
|
|
8
|
+
shimmer.wrap(Transport.prototype, 'request', createWrapRequest('opensearch'))
|
|
9
|
+
return Transport
|
|
10
|
+
})
|
|
@@ -40,9 +40,10 @@ function wrapQuery (query) {
|
|
|
40
40
|
const statement = pgQuery.text
|
|
41
41
|
const callbackResource = new AsyncResource('bound-anonymous-fn')
|
|
42
42
|
const asyncResource = new AsyncResource('bound-anonymous-fn')
|
|
43
|
+
const processId = this.processID
|
|
43
44
|
|
|
44
45
|
return asyncResource.runInAsyncScope(() => {
|
|
45
|
-
startCh.publish({ params: this.connectionParameters, statement })
|
|
46
|
+
startCh.publish({ params: this.connectionParameters, statement, processId })
|
|
46
47
|
|
|
47
48
|
const finish = asyncResource.bind(function (error) {
|
|
48
49
|
if (error) {
|
|
@@ -11,17 +11,22 @@ const circularBufferConstructor = Symbol('circularBufferConstructor')
|
|
|
11
11
|
const inFlightDeliveries = Symbol('inFlightDeliveries')
|
|
12
12
|
|
|
13
13
|
const patched = new WeakSet()
|
|
14
|
-
const dispatchCh = channel('apm:rhea:dispatch')
|
|
15
|
-
const errorCh = channel('apm:rhea:error')
|
|
16
|
-
const finishCh = channel('apm:rhea:finish')
|
|
17
14
|
|
|
18
|
-
const
|
|
15
|
+
const startSendCh = channel('apm:rhea:send:start')
|
|
16
|
+
const encodeSendCh = channel('apm:rhea:send:encode')
|
|
17
|
+
const errorSendCh = channel('apm:rhea:send:error')
|
|
18
|
+
const finishSendCh = channel('apm:rhea:send:finish')
|
|
19
|
+
|
|
20
|
+
const startReceiveCh = channel('apm:rhea:receive:start')
|
|
21
|
+
const dispatchReceiveCh = channel('apm:rhea:receive:dispatch')
|
|
22
|
+
const errorReceiveCh = channel('apm:rhea:receive:error')
|
|
23
|
+
const finishReceiveCh = channel('apm:rhea:receive:finish')
|
|
19
24
|
|
|
20
25
|
const contexts = new WeakMap()
|
|
21
26
|
|
|
22
27
|
addHook({ name: 'rhea', versions: ['>=1'] }, rhea => {
|
|
23
28
|
shimmer.wrap(rhea.message, 'encode', encode => function (msg) {
|
|
24
|
-
|
|
29
|
+
encodeSendCh.publish(msg)
|
|
25
30
|
return encode.apply(this, arguments)
|
|
26
31
|
})
|
|
27
32
|
|
|
@@ -29,9 +34,6 @@ addHook({ name: 'rhea', versions: ['>=1'] }, rhea => {
|
|
|
29
34
|
})
|
|
30
35
|
|
|
31
36
|
addHook({ name: 'rhea', versions: ['>=1'], file: 'lib/link.js' }, obj => {
|
|
32
|
-
const startSendCh = channel('apm:rhea:send:start')
|
|
33
|
-
const startReceiveCh = channel('apm:rhea:receive:start')
|
|
34
|
-
|
|
35
37
|
const Sender = obj.Sender
|
|
36
38
|
const Receiver = obj.Receiver
|
|
37
39
|
shimmer.wrap(Sender.prototype, 'send', send => function (msg, tag, format) {
|
|
@@ -58,7 +60,7 @@ addHook({ name: 'rhea', versions: ['>=1'], file: 'lib/link.js' }, obj => {
|
|
|
58
60
|
try {
|
|
59
61
|
return delivery
|
|
60
62
|
} catch (err) {
|
|
61
|
-
|
|
63
|
+
errorSendCh.publish(err)
|
|
62
64
|
|
|
63
65
|
throw err
|
|
64
66
|
}
|
|
@@ -87,7 +89,7 @@ addHook({ name: 'rhea', versions: ['>=1'], file: 'lib/link.js' }, obj => {
|
|
|
87
89
|
try {
|
|
88
90
|
return dispatch.apply(this, arguments)
|
|
89
91
|
} catch (err) {
|
|
90
|
-
|
|
92
|
+
errorReceiveCh.publish(err)
|
|
91
93
|
|
|
92
94
|
throw err
|
|
93
95
|
}
|
|
@@ -111,8 +113,9 @@ addHook({ name: 'rhea', versions: ['>=1'], file: 'lib/connection.js' }, Connecti
|
|
|
111
113
|
if (!asyncResource) return
|
|
112
114
|
|
|
113
115
|
asyncResource.runInAsyncScope(() => {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
+
errorReceiveCh.publish(error)
|
|
117
|
+
beforeFinish(delivery, null)
|
|
118
|
+
finishReceiveCh.publish()
|
|
116
119
|
})
|
|
117
120
|
})
|
|
118
121
|
}
|
|
@@ -148,7 +151,7 @@ function wrapDeliveryUpdate (obj, update) {
|
|
|
148
151
|
const cb = asyncResource.bind(update)
|
|
149
152
|
return AsyncResource.bind(function wrappedUpdate (settled, stateData) {
|
|
150
153
|
const state = getStateFromData(stateData)
|
|
151
|
-
|
|
154
|
+
dispatchReceiveCh.publish({ state })
|
|
152
155
|
return cb.apply(this, arguments)
|
|
153
156
|
})
|
|
154
157
|
}
|
|
@@ -184,7 +187,8 @@ function patchCircularBuffer (proto, Session) {
|
|
|
184
187
|
const state = remoteState && remoteState.constructor
|
|
185
188
|
? entry.remote_state.constructor.composite_type : undefined
|
|
186
189
|
asyncResource.runInAsyncScope(() => {
|
|
187
|
-
|
|
190
|
+
beforeFinish(entry, state)
|
|
191
|
+
finishSendCh.publish()
|
|
188
192
|
})
|
|
189
193
|
}
|
|
190
194
|
|
|
@@ -212,13 +216,12 @@ function addToInFlightDeliveries (connection, delivery) {
|
|
|
212
216
|
deliveries.add(delivery)
|
|
213
217
|
}
|
|
214
218
|
|
|
215
|
-
function
|
|
219
|
+
function beforeFinish (delivery, state) {
|
|
216
220
|
const obj = contexts.get(delivery)
|
|
217
221
|
if (obj) {
|
|
218
222
|
if (state) {
|
|
219
|
-
|
|
223
|
+
dispatchReceiveCh.publish({ state })
|
|
220
224
|
}
|
|
221
|
-
finishCh.publish(undefined)
|
|
222
225
|
if (obj.connection && obj.connection[inFlightDeliveries]) {
|
|
223
226
|
obj.connection[inFlightDeliveries].delete(delivery)
|
|
224
227
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const ConsumerPlugin = require('../../dd-trace/src/plugins/consumer')
|
|
4
|
+
const { getAddress, getShortName } = require('./util')
|
|
5
|
+
|
|
6
|
+
class Amqp10ConsumerPlugin extends ConsumerPlugin {
|
|
7
|
+
static get name () { return 'amqp10' }
|
|
8
|
+
static get system () { return 'amqp' }
|
|
9
|
+
|
|
10
|
+
start ({ link }) {
|
|
11
|
+
const source = getShortName(link)
|
|
12
|
+
const address = getAddress(link)
|
|
13
|
+
|
|
14
|
+
this.startSpan('amqp.receive', {
|
|
15
|
+
service: this.config.service || `${this.tracer._service}-amqp`,
|
|
16
|
+
resource: ['receive', source].filter(v => v).join(' '),
|
|
17
|
+
type: 'worker',
|
|
18
|
+
kind: 'consumer',
|
|
19
|
+
meta: {
|
|
20
|
+
'amqp.link.source.address': source,
|
|
21
|
+
'amqp.link.role': 'receiver',
|
|
22
|
+
'amqp.link.name': link.name,
|
|
23
|
+
'amqp.link.handle': link.handle,
|
|
24
|
+
'amqp.connection.host': address.host,
|
|
25
|
+
'amqp.connection.port': address.port,
|
|
26
|
+
'amqp.connection.user': address.user
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
module.exports = Amqp10ConsumerPlugin
|