dd-trace 2.1.1 → 2.3.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 +0 -2
- package/index.d.ts +28 -12
- package/package.json +3 -5
- package/packages/datadog-instrumentations/index.js +14 -3
- package/packages/datadog-instrumentations/src/bunyan.js +22 -0
- package/packages/datadog-instrumentations/src/couchbase.js +143 -0
- package/packages/datadog-instrumentations/src/cucumber.js +116 -0
- package/packages/datadog-instrumentations/src/elasticsearch.js +84 -0
- package/packages/datadog-instrumentations/src/generic-pool.js +48 -0
- package/packages/datadog-instrumentations/src/ioredis.js +52 -0
- package/packages/datadog-instrumentations/src/mongoose.js +30 -0
- package/packages/datadog-instrumentations/src/pino.js +105 -0
- package/packages/datadog-instrumentations/src/redis.js +118 -0
- package/packages/datadog-instrumentations/src/sharedb.js +78 -0
- package/packages/datadog-instrumentations/src/winston.js +57 -0
- package/packages/datadog-plugin-bunyan/src/index.js +5 -22
- package/packages/datadog-plugin-couchbase/src/index.js +51 -148
- package/packages/datadog-plugin-cucumber/src/index.js +83 -128
- package/packages/datadog-plugin-elasticsearch/src/index.js +41 -82
- package/packages/datadog-plugin-fastify/src/fastify.js +22 -1
- package/packages/datadog-plugin-fastify/src/find-my-way.js +0 -1
- package/packages/datadog-plugin-google-cloud-pubsub/src/index.js +8 -6
- package/packages/datadog-plugin-graphql/src/index.js +34 -28
- package/packages/datadog-plugin-grpc/src/client.js +20 -6
- package/packages/datadog-plugin-http2/src/server.js +2 -0
- package/packages/datadog-plugin-ioredis/src/index.js +5 -35
- package/packages/datadog-plugin-jest/src/jest-environment.js +26 -30
- package/packages/datadog-plugin-koa/src/index.js +6 -2
- package/packages/datadog-plugin-microgateway-core/src/index.js +1 -3
- package/packages/datadog-plugin-mocha/src/index.js +5 -3
- package/packages/datadog-plugin-mongodb-core/src/util.js +31 -7
- package/packages/datadog-plugin-next/src/index.js +9 -4
- package/packages/datadog-plugin-oracledb/src/index.js +10 -7
- package/packages/datadog-plugin-pino/src/index.js +5 -158
- package/packages/datadog-plugin-redis/src/index.js +96 -80
- package/packages/datadog-plugin-restify/src/index.js +18 -3
- package/packages/datadog-plugin-rhea/src/index.js +8 -5
- package/packages/datadog-plugin-router/src/index.js +23 -14
- package/packages/datadog-plugin-sharedb/src/index.js +47 -87
- package/packages/datadog-plugin-winston/src/index.js +5 -110
- package/packages/datadog-shimmer/src/shimmer.js +1 -1
- package/packages/dd-trace/lib/version.js +1 -1
- package/packages/dd-trace/src/appsec/index.js +6 -1
- package/packages/dd-trace/src/appsec/reporter.js +3 -2
- package/packages/dd-trace/src/config.js +7 -1
- package/packages/dd-trace/src/constants.js +1 -6
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +0 -34
- package/packages/dd-trace/src/opentracing/tracer.js +1 -1
- package/packages/dd-trace/src/plugins/index.js +0 -2
- package/packages/dd-trace/src/plugins/log_plugin.js +49 -0
- package/packages/dd-trace/src/plugins/plugin.js +7 -0
- package/packages/dd-trace/src/plugins/util/git.js +1 -1
- package/packages/dd-trace/src/plugins/util/web.js +102 -84
- package/packages/dd-trace/src/priority_sampler.js +1 -49
- package/packages/dd-trace/src/scope.js +47 -23
- package/packages/dd-trace/src/span_processor.js +22 -7
- package/packages/dd-trace/src/tagger.js +14 -21
- package/packages/dd-trace/src/tracer.js +1 -1
- package/NOTICE +0 -4
- package/packages/datadog-plugin-generic-pool/src/index.js +0 -52
- package/packages/datadog-plugin-mongoose/src/index.js +0 -51
- package/scripts/tracer-runner.js +0 -13
package/LICENSE-3rdparty.csv
CHANGED
|
@@ -22,8 +22,6 @@ require,path-to-regexp,MIT,Copyright 2014 Blake Embrey
|
|
|
22
22
|
require,performance-now,MIT,Copyright 2013 Braveg1rl
|
|
23
23
|
require,retry,MIT,Copyright 2011 Tim Koschützki Felix Geisendörfer
|
|
24
24
|
require,semver,ISC,Copyright Isaac Z. Schlueter and Contributors
|
|
25
|
-
require,source-map,BSD-3-Clause,Copyright 2009-2011 Mozilla Foundation and contributors
|
|
26
|
-
require,source-map-resolve,MIT,Copyright 2014-2020 Simon Lydell 2019 Jinxiang
|
|
27
25
|
dev,autocannon,MIT,Copyright 2016 Matteo Collina
|
|
28
26
|
dev,axios,MIT,Copyright 2014-present Matt Zabriskie
|
|
29
27
|
dev,benchmark,MIT,Copyright 2010-2016 Mathias Bynens Robert Kieffer John-David Dalton
|
package/index.d.ts
CHANGED
|
@@ -186,18 +186,6 @@ export declare interface SamplingRule {
|
|
|
186
186
|
* List of options available to the tracer.
|
|
187
187
|
*/
|
|
188
188
|
export declare interface TracerOptions {
|
|
189
|
-
/**
|
|
190
|
-
* Whether to enable the tracer.
|
|
191
|
-
* @default true
|
|
192
|
-
*/
|
|
193
|
-
enabled?: boolean;
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Enable debug logging in the tracer.
|
|
197
|
-
* @default false
|
|
198
|
-
*/
|
|
199
|
-
debug?: boolean;
|
|
200
|
-
|
|
201
189
|
/**
|
|
202
190
|
* Whether to enable trace ID injection in log records to be able to correlate
|
|
203
191
|
* traces with logs.
|
|
@@ -278,6 +266,12 @@ export declare interface TracerOptions {
|
|
|
278
266
|
*/
|
|
279
267
|
flushInterval?: number;
|
|
280
268
|
|
|
269
|
+
/**
|
|
270
|
+
* Number of spans before partially exporting a trace. This prevents keeping all the spans in memory for very large traces.
|
|
271
|
+
* @default 1000
|
|
272
|
+
*/
|
|
273
|
+
flushMinSpans?: number;
|
|
274
|
+
|
|
281
275
|
/**
|
|
282
276
|
* Whether to enable runtime metrics.
|
|
283
277
|
* @default false
|
|
@@ -406,6 +400,28 @@ export declare interface TracerOptions {
|
|
|
406
400
|
* @default true
|
|
407
401
|
*/
|
|
408
402
|
orphanable?: boolean
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Configuration of the AppSec protection. Can be a boolean as an alias to `appsec.enabled`.
|
|
406
|
+
*/
|
|
407
|
+
appsec?: boolean | {
|
|
408
|
+
/**
|
|
409
|
+
* Whether to enable AppSec.
|
|
410
|
+
* @default false
|
|
411
|
+
*/
|
|
412
|
+
enabled?: boolean,
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Specifies a path to a custom rules file.
|
|
416
|
+
*/
|
|
417
|
+
rules?: string,
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Controls the maximum amount of traces sampled by AppSec attacks, per second.
|
|
421
|
+
* @default 100
|
|
422
|
+
*/
|
|
423
|
+
rateLimit?: number
|
|
424
|
+
};
|
|
409
425
|
}
|
|
410
426
|
|
|
411
427
|
/** @hidden */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dd-trace",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Datadog APM tracing client for JavaScript",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"crypto-randomuuid": "^1.0.0",
|
|
70
70
|
"diagnostics_channel": "^1.1.0",
|
|
71
71
|
"form-data": "^3.0.0",
|
|
72
|
-
"import-in-the-middle": "^1.1
|
|
72
|
+
"import-in-the-middle": "^1.2.1",
|
|
73
73
|
"koalas": "^1.0.2",
|
|
74
74
|
"limiter": "^1.1.4",
|
|
75
75
|
"lodash.kebabcase": "^4.1.1",
|
|
@@ -83,9 +83,7 @@
|
|
|
83
83
|
"path-to-regexp": "^0.1.2",
|
|
84
84
|
"performance-now": "^2.1.0",
|
|
85
85
|
"retry": "^0.10.1",
|
|
86
|
-
"semver": "^5.5.0"
|
|
87
|
-
"source-map": "^0.7.3",
|
|
88
|
-
"source-map-resolve": "^0.6.0"
|
|
86
|
+
"semver": "^5.5.0"
|
|
89
87
|
},
|
|
90
88
|
"devDependencies": {
|
|
91
89
|
"autocannon": "^4.5.2",
|
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
require('./src/bluebird')
|
|
4
|
+
require('./src/bunyan')
|
|
5
|
+
require('./src/couchbase')
|
|
6
|
+
require('./src/cucumber')
|
|
3
7
|
require('./src/dns')
|
|
8
|
+
require('./src/elasticsearch')
|
|
9
|
+
require('./src/generic-pool')
|
|
10
|
+
require('./src/ioredis')
|
|
4
11
|
require('./src/memcached')
|
|
12
|
+
require('./src/mongoose')
|
|
5
13
|
require('./src/mysql')
|
|
6
14
|
require('./src/mysql2')
|
|
7
|
-
require('./src/
|
|
8
|
-
require('./src/when')
|
|
15
|
+
require('./src/pino')
|
|
9
16
|
require('./src/promise')
|
|
10
|
-
require('./src/q')
|
|
11
17
|
require('./src/promise-js')
|
|
18
|
+
require('./src/q')
|
|
19
|
+
require('./src/redis')
|
|
20
|
+
require('./src/sharedb')
|
|
21
|
+
require('./src/when')
|
|
22
|
+
require('./src/winston')
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
channel,
|
|
5
|
+
addHook
|
|
6
|
+
} = require('./helpers/instrument')
|
|
7
|
+
const shimmer = require('../../datadog-shimmer')
|
|
8
|
+
|
|
9
|
+
addHook({ name: 'bunyan', versions: ['>=1'] }, Logger => {
|
|
10
|
+
const logCh = channel('apm:bunyan:log')
|
|
11
|
+
shimmer.wrap(Logger.prototype, '_emit', emit => {
|
|
12
|
+
return function wrappedEmit (rec) {
|
|
13
|
+
if (logCh.hasSubscribers) {
|
|
14
|
+
const payload = { message: rec }
|
|
15
|
+
logCh.publish(payload)
|
|
16
|
+
arguments[0] = payload.message
|
|
17
|
+
}
|
|
18
|
+
return emit.apply(this, arguments)
|
|
19
|
+
}
|
|
20
|
+
})
|
|
21
|
+
return Logger
|
|
22
|
+
})
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
channel,
|
|
5
|
+
addHook,
|
|
6
|
+
AsyncResource
|
|
7
|
+
} = require('./helpers/instrument')
|
|
8
|
+
const shimmer = require('../../datadog-shimmer')
|
|
9
|
+
|
|
10
|
+
addHook({ name: 'couchbase', file: 'lib/bucket.js', versions: ['^2.6.5'] }, Bucket => {
|
|
11
|
+
const startCh = channel('apm:couchbase:query:start')
|
|
12
|
+
const asyncEndCh = channel('apm:couchbase:query:async-end')
|
|
13
|
+
const endCh = channel('apm:couchbase:query:end')
|
|
14
|
+
const errorCh = channel('apm:couchbase:query:error')
|
|
15
|
+
|
|
16
|
+
Bucket.prototype._maybeInvoke = wrapMaybeInvoke(Bucket.prototype._maybeInvoke)
|
|
17
|
+
Bucket.prototype.query = wrapQuery(Bucket.prototype.query)
|
|
18
|
+
|
|
19
|
+
shimmer.wrap(Bucket.prototype, '_n1qlReq', _n1qlReq => function (host, q, adhoc, emitter) {
|
|
20
|
+
if (!startCh.hasSubscribers) {
|
|
21
|
+
return _n1qlReq.apply(this, arguments)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (!emitter || !emitter.once) return _n1qlReq.apply(this, arguments)
|
|
25
|
+
|
|
26
|
+
const n1qlQuery = q && q.statement
|
|
27
|
+
|
|
28
|
+
startCh.publish({ resource: n1qlQuery, bucket: this })
|
|
29
|
+
|
|
30
|
+
emitter.once('rows', AsyncResource.bind(() => {
|
|
31
|
+
asyncEndCh.publish(undefined)
|
|
32
|
+
}))
|
|
33
|
+
|
|
34
|
+
emitter.once('error', AsyncResource.bind((error) => {
|
|
35
|
+
errorCh.publish(error)
|
|
36
|
+
asyncEndCh.publish(undefined)
|
|
37
|
+
}))
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
return _n1qlReq.apply(this, arguments)
|
|
41
|
+
} catch (err) {
|
|
42
|
+
err.stack // trigger getting the stack at the original throwing point
|
|
43
|
+
errorCh.publish(err)
|
|
44
|
+
|
|
45
|
+
throw err
|
|
46
|
+
} finally {
|
|
47
|
+
endCh.publish(undefined)
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
Bucket.prototype.upsert = wrap('apm:couchbase:upsert', Bucket.prototype.upsert)
|
|
52
|
+
Bucket.prototype.insert = wrap('apm:couchbase:insert', Bucket.prototype.insert)
|
|
53
|
+
Bucket.prototype.replace = wrap('apm:couchbase:replace', Bucket.prototype.replace)
|
|
54
|
+
Bucket.prototype.append = wrap('apm:couchbase:append', Bucket.prototype.append)
|
|
55
|
+
Bucket.prototype.prepend = wrap('apm:couchbase:prepend', Bucket.prototype.prepend)
|
|
56
|
+
|
|
57
|
+
return Bucket
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
addHook({ name: 'couchbase', file: 'lib/cluster.js', versions: ['^2.6.5'] }, Cluster => {
|
|
61
|
+
Cluster.prototype._maybeInvoke = wrapMaybeInvoke(Cluster.prototype._maybeInvoke)
|
|
62
|
+
Cluster.prototype.query = wrapQuery(Cluster.prototype.query)
|
|
63
|
+
|
|
64
|
+
return Cluster
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
function findCallbackIndex (args) {
|
|
68
|
+
for (let i = args.length - 1; i >= 2; i--) {
|
|
69
|
+
if (typeof args[i] === 'function') return i
|
|
70
|
+
}
|
|
71
|
+
return -1
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function wrapMaybeInvoke (_maybeInvoke) {
|
|
75
|
+
const wrapped = function (fn, args) {
|
|
76
|
+
if (!Array.isArray(args)) return _maybeInvoke.apply(this, arguments)
|
|
77
|
+
|
|
78
|
+
const callbackIndex = args.length - 1
|
|
79
|
+
const callback = args[callbackIndex]
|
|
80
|
+
|
|
81
|
+
if (callback instanceof Function) {
|
|
82
|
+
args[callbackIndex] = AsyncResource.bind(callback)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return _maybeInvoke.apply(this, arguments)
|
|
86
|
+
}
|
|
87
|
+
return shimmer.wrap(_maybeInvoke, wrapped)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function wrapQuery (query) {
|
|
91
|
+
const wrapped = function (q, params, callback) {
|
|
92
|
+
callback = AsyncResource.bind(arguments[arguments.length - 1])
|
|
93
|
+
|
|
94
|
+
if (typeof callback === 'function') {
|
|
95
|
+
arguments[arguments.length - 1] = callback
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const res = query.apply(this, arguments)
|
|
99
|
+
return res
|
|
100
|
+
}
|
|
101
|
+
return shimmer.wrap(query, wrapped)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function wrap (prefix, fn) {
|
|
105
|
+
const startCh = channel(prefix + ':start')
|
|
106
|
+
const endCh = channel(prefix + ':end')
|
|
107
|
+
const asyncEndCh = channel(prefix + ':async-end')
|
|
108
|
+
const errorCh = channel(prefix + ':error')
|
|
109
|
+
|
|
110
|
+
const wrapped = function (key, value, options, callback) {
|
|
111
|
+
if (!startCh.hasSubscribers) {
|
|
112
|
+
return fn.apply(this, arguments)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const callbackIndex = findCallbackIndex(arguments)
|
|
116
|
+
|
|
117
|
+
if (callbackIndex < 0) return fn.apply(this, arguments)
|
|
118
|
+
|
|
119
|
+
const cb = arguments[callbackIndex]
|
|
120
|
+
|
|
121
|
+
startCh.publish({ bucket: this })
|
|
122
|
+
|
|
123
|
+
arguments[callbackIndex] = function (error, result) {
|
|
124
|
+
if (error) {
|
|
125
|
+
errorCh.publish(error)
|
|
126
|
+
}
|
|
127
|
+
asyncEndCh.publish(result)
|
|
128
|
+
return cb.apply(this, arguments)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
try {
|
|
132
|
+
return fn.apply(this, arguments)
|
|
133
|
+
} catch (error) {
|
|
134
|
+
error.stack // trigger getting the stack at the original throwing point
|
|
135
|
+
errorCh.publish(error)
|
|
136
|
+
|
|
137
|
+
throw error
|
|
138
|
+
} finally {
|
|
139
|
+
endCh.publish(undefined)
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return shimmer.wrap(fn, wrapped)
|
|
143
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { addHook, channel } = require('./helpers/instrument')
|
|
4
|
+
const shimmer = require('../../datadog-shimmer')
|
|
5
|
+
|
|
6
|
+
const runStartCh = channel('ci:cucumber:run:start')
|
|
7
|
+
const runEndCh = channel('ci:cucumber:run:end')
|
|
8
|
+
const runAsyncEndCh = channel('ci:cucumber:run:async-end')
|
|
9
|
+
const runStepStartCh = channel('ci:cucumber:run-step:start')
|
|
10
|
+
const runStepEndCh = channel('ci:cucumber:run-step:end')
|
|
11
|
+
const errorCh = channel('ci:cucumber:error')
|
|
12
|
+
|
|
13
|
+
function getStatusFromResult (result) {
|
|
14
|
+
if (result.status === 1) {
|
|
15
|
+
return { status: 'pass' }
|
|
16
|
+
}
|
|
17
|
+
if (result.status === 2) {
|
|
18
|
+
return { status: 'skip' }
|
|
19
|
+
}
|
|
20
|
+
if (result.status === 4) {
|
|
21
|
+
return { status: 'skip', skipReason: 'not implemented' }
|
|
22
|
+
}
|
|
23
|
+
return { status: 'fail', errorMessage: result.message }
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function getStatusFromResultLatest (result) {
|
|
27
|
+
if (result.status === 'PASSED') {
|
|
28
|
+
return { status: 'pass' }
|
|
29
|
+
}
|
|
30
|
+
if (result.status === 'SKIPPED' || result.status === 'PENDING') {
|
|
31
|
+
return { status: 'skip' }
|
|
32
|
+
}
|
|
33
|
+
if (result.status === 'UNDEFINED') {
|
|
34
|
+
return { status: 'skip', skipReason: 'not implemented' }
|
|
35
|
+
}
|
|
36
|
+
return { status: 'fail', errorMessage: result.message }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function wrapRun (pl, isLatestVersion) {
|
|
40
|
+
shimmer.wrap(pl.prototype, 'run', run => function () {
|
|
41
|
+
if (!runStartCh.hasSubscribers) {
|
|
42
|
+
return run.apply(this, arguments)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
runStartCh.publish({ pickleName: this.pickle.name, pickleUri: this.pickle.uri })
|
|
46
|
+
try {
|
|
47
|
+
const promise = run.apply(this, arguments)
|
|
48
|
+
promise.finally(() => {
|
|
49
|
+
const result = this.getWorstStepResult()
|
|
50
|
+
const { status, skipReason, errorMessage } = isLatestVersion
|
|
51
|
+
? getStatusFromResultLatest(result) : getStatusFromResult(result)
|
|
52
|
+
|
|
53
|
+
runAsyncEndCh.publish({ status, skipReason, errorMessage })
|
|
54
|
+
})
|
|
55
|
+
return promise
|
|
56
|
+
} catch (err) {
|
|
57
|
+
errorCh.publish(err)
|
|
58
|
+
} finally {
|
|
59
|
+
runEndCh.publish(undefined)
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
shimmer.wrap(pl.prototype, 'runStep', runStep => function () {
|
|
63
|
+
if (!runStepStartCh.hasSubscribers) {
|
|
64
|
+
return runStep.apply(this, arguments)
|
|
65
|
+
}
|
|
66
|
+
const testStep = arguments[0]
|
|
67
|
+
let resource
|
|
68
|
+
|
|
69
|
+
if (isLatestVersion) {
|
|
70
|
+
resource = testStep.text
|
|
71
|
+
} else {
|
|
72
|
+
resource = testStep.isHook ? 'hook' : testStep.pickleStep.text
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
runStepStartCh.publish({ resource })
|
|
76
|
+
try {
|
|
77
|
+
const promise = runStep.apply(this, arguments)
|
|
78
|
+
|
|
79
|
+
promise.then((result) => {
|
|
80
|
+
const { status, skipReason, errorMessage } = isLatestVersion
|
|
81
|
+
? getStatusFromResultLatest(result) : getStatusFromResult(result)
|
|
82
|
+
|
|
83
|
+
runAsyncEndCh.publish({ isStep: true, status, skipReason, errorMessage })
|
|
84
|
+
})
|
|
85
|
+
return promise
|
|
86
|
+
} catch (err) {
|
|
87
|
+
errorCh.publish(err)
|
|
88
|
+
} finally {
|
|
89
|
+
runStepEndCh.publish(undefined)
|
|
90
|
+
}
|
|
91
|
+
})
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
addHook({
|
|
95
|
+
name: '@cucumber/cucumber',
|
|
96
|
+
versions: ['7.0.0 - 7.2.1'],
|
|
97
|
+
file: 'lib/runtime/pickle_runner.js'
|
|
98
|
+
}, (PickleRunner) => {
|
|
99
|
+
const pl = PickleRunner.default
|
|
100
|
+
|
|
101
|
+
wrapRun(pl, false)
|
|
102
|
+
|
|
103
|
+
return PickleRunner
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
addHook({
|
|
107
|
+
name: '@cucumber/cucumber',
|
|
108
|
+
versions: ['>=7.3.0'],
|
|
109
|
+
file: 'lib/runtime/test_case_runner.js'
|
|
110
|
+
}, (TestCaseRunner) => {
|
|
111
|
+
const pl = TestCaseRunner.default
|
|
112
|
+
|
|
113
|
+
wrapRun(pl, true)
|
|
114
|
+
|
|
115
|
+
return TestCaseRunner
|
|
116
|
+
})
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
channel,
|
|
5
|
+
addHook,
|
|
6
|
+
AsyncResource
|
|
7
|
+
} = require('./helpers/instrument')
|
|
8
|
+
const shimmer = require('../../datadog-shimmer')
|
|
9
|
+
|
|
10
|
+
const startCh = channel('apm:elasticsearch:query:start')
|
|
11
|
+
const asyncEndCh = channel('apm:elasticsearch:query:async-end')
|
|
12
|
+
const endCh = channel('apm:elasticsearch:query:end')
|
|
13
|
+
const errorCh = channel('apm:elasticsearch:query:error')
|
|
14
|
+
|
|
15
|
+
addHook({ name: '@elastic/transport', file: 'lib/Transport.js', versions: ['>=8'] }, (exports) => {
|
|
16
|
+
shimmer.wrap(exports.default.prototype, 'request', wrapRequest)
|
|
17
|
+
return exports
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
addHook({ name: '@elastic/elasticsearch', file: 'lib/Transport.js', versions: ['>=5.6.16 <8', '>=8'] }, Transport => {
|
|
21
|
+
shimmer.wrap(Transport.prototype, 'request', wrapRequest)
|
|
22
|
+
return Transport
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
addHook({ name: 'elasticsearch', file: 'src/lib/transport.js', versions: ['>=10'] }, Transport => {
|
|
26
|
+
shimmer.wrap(Transport.prototype, 'request', wrapRequest)
|
|
27
|
+
return Transport
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
function wrapRequest (request) {
|
|
31
|
+
return function (params, options, cb) {
|
|
32
|
+
if (!startCh.hasSubscribers) {
|
|
33
|
+
return request.apply(this, arguments)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (!params) return request.apply(this, arguments)
|
|
37
|
+
|
|
38
|
+
const parentResource = new AsyncResource('bound-anonymous-fn')
|
|
39
|
+
|
|
40
|
+
startCh.publish({ params })
|
|
41
|
+
|
|
42
|
+
const asyncResource = new AsyncResource('bound-anonymous-fn')
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
const lastIndex = arguments.length - 1
|
|
46
|
+
cb = arguments[lastIndex]
|
|
47
|
+
|
|
48
|
+
if (typeof cb === 'function') {
|
|
49
|
+
cb = parentResource.bind(cb)
|
|
50
|
+
|
|
51
|
+
arguments[lastIndex] = asyncResource.bind(function (error) {
|
|
52
|
+
finish(params, error)
|
|
53
|
+
return cb.apply(null, arguments)
|
|
54
|
+
})
|
|
55
|
+
return request.apply(this, arguments)
|
|
56
|
+
} else {
|
|
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
|
|
67
|
+
}
|
|
68
|
+
} catch (err) {
|
|
69
|
+
err.stack // trigger getting the stack at the original throwing point
|
|
70
|
+
errorCh.publish(err)
|
|
71
|
+
|
|
72
|
+
throw err
|
|
73
|
+
} finally {
|
|
74
|
+
endCh.publish(undefined)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function finish (params, error) {
|
|
80
|
+
if (error) {
|
|
81
|
+
errorCh.publish(error)
|
|
82
|
+
}
|
|
83
|
+
asyncEndCh.publish({ params })
|
|
84
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { addHook, AsyncResource } = require('./helpers/instrument')
|
|
4
|
+
const shimmer = require('../../datadog-shimmer')
|
|
5
|
+
|
|
6
|
+
function createWrapAcquire () {
|
|
7
|
+
return function wrapAcquire (acquire) {
|
|
8
|
+
return function acquireWithTrace (callback, priority) {
|
|
9
|
+
if (typeof callback === 'function') {
|
|
10
|
+
arguments[0] = AsyncResource.bind(callback)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return acquire.apply(this, arguments)
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function createWrapPool () {
|
|
19
|
+
return function wrapPool (Pool) {
|
|
20
|
+
if (typeof Pool !== 'function') return Pool
|
|
21
|
+
|
|
22
|
+
return function PoolWithTrace (factory) {
|
|
23
|
+
const pool = Pool.apply(this, arguments)
|
|
24
|
+
|
|
25
|
+
if (pool && typeof pool.acquire === 'function') {
|
|
26
|
+
shimmer.wrap(pool, 'acquire', createWrapAcquire())
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return pool
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
addHook({
|
|
35
|
+
name: 'generic-pool',
|
|
36
|
+
versions: ['^2.4']
|
|
37
|
+
}, genericPool => {
|
|
38
|
+
shimmer.wrap(genericPool.Pool.prototype, 'acquire', createWrapAcquire())
|
|
39
|
+
return genericPool
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
addHook({
|
|
43
|
+
name: 'generic-pool',
|
|
44
|
+
versions: ['2 - 2.3']
|
|
45
|
+
}, genericPool => {
|
|
46
|
+
shimmer.wrap(genericPool, 'Pool', createWrapPool())
|
|
47
|
+
return genericPool
|
|
48
|
+
})
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
channel,
|
|
5
|
+
addHook,
|
|
6
|
+
AsyncResource
|
|
7
|
+
} = require('./helpers/instrument')
|
|
8
|
+
const shimmer = require('../../datadog-shimmer')
|
|
9
|
+
|
|
10
|
+
const startCh = channel('apm:ioredis:command:start')
|
|
11
|
+
const asyncEndCh = channel('apm:ioredis:command:async-end')
|
|
12
|
+
const endCh = channel('apm:ioredis:command:end')
|
|
13
|
+
const errorCh = channel('apm:ioredis:command:error')
|
|
14
|
+
|
|
15
|
+
addHook({ name: 'ioredis', versions: ['>=2'] }, Redis => {
|
|
16
|
+
shimmer.wrap(Redis.prototype, 'sendCommand', sendCommand => function (command, stream) {
|
|
17
|
+
if (!startCh.hasSubscribers) return sendCommand.apply(this, arguments)
|
|
18
|
+
|
|
19
|
+
if (!command || !command.promise) return sendCommand.apply(this, arguments)
|
|
20
|
+
|
|
21
|
+
const options = this.options || {}
|
|
22
|
+
const connectionName = options.connectionName
|
|
23
|
+
const db = options.db
|
|
24
|
+
const connectionOptions = { host: options.host, port: options.port }
|
|
25
|
+
|
|
26
|
+
startCh.publish({ db, command: command.name, args: command.args, connectionOptions, connectionName })
|
|
27
|
+
|
|
28
|
+
const asyncResource = new AsyncResource('bound-anonymous-fn')
|
|
29
|
+
const onResolve = asyncResource.bind(() => finish(asyncEndCh, errorCh))
|
|
30
|
+
const onReject = asyncResource.bind(err => finish(asyncEndCh, errorCh, err))
|
|
31
|
+
|
|
32
|
+
command.promise.then(onResolve, onReject)
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
return sendCommand.apply(this, arguments)
|
|
36
|
+
} catch (err) {
|
|
37
|
+
errorCh.publish(err)
|
|
38
|
+
|
|
39
|
+
throw err
|
|
40
|
+
} finally {
|
|
41
|
+
endCh.publish(undefined)
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
return Redis
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
function finish (asyncEndCh, errorCh, error) {
|
|
48
|
+
if (error) {
|
|
49
|
+
errorCh.publish(error)
|
|
50
|
+
}
|
|
51
|
+
asyncEndCh.publish(undefined)
|
|
52
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { addHook } = require('./helpers/instrument')
|
|
4
|
+
const { wrapThen } = require('./helpers/promise')
|
|
5
|
+
const { AsyncResource } = require('./helpers/instrument')
|
|
6
|
+
const shimmer = require('../../datadog-shimmer')
|
|
7
|
+
|
|
8
|
+
function wrapAddQueue (addQueue) {
|
|
9
|
+
return function addQueueWithTrace (name) {
|
|
10
|
+
if (typeof name === 'function') {
|
|
11
|
+
arguments[0] = AsyncResource.bind(name)
|
|
12
|
+
} else if (typeof this[name] === 'function') {
|
|
13
|
+
arguments[0] = AsyncResource.bind((...args) => this[name](...args))
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return addQueue.apply(this, arguments)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
addHook({
|
|
21
|
+
name: 'mongoose',
|
|
22
|
+
versions: ['>=4.6.4']
|
|
23
|
+
}, mongoose => {
|
|
24
|
+
if (mongoose.Promise !== global.Promise) {
|
|
25
|
+
shimmer.wrap(mongoose.Promise.prototype, 'then', wrapThen)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
shimmer.wrap(mongoose.Collection.prototype, 'addQueue', wrapAddQueue)
|
|
29
|
+
return mongoose
|
|
30
|
+
})
|