dd-trace 5.0.0-pre-0fb796c → 5.0.0-pre-2fed3ce
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 +4 -3
- package/index.d.ts +13 -0
- package/package.json +4 -4
- package/packages/datadog-instrumentations/src/aws-sdk.js +5 -0
- package/packages/datadog-instrumentations/src/cassandra-driver.js +6 -3
- package/packages/datadog-instrumentations/src/elasticsearch.js +39 -1
- package/packages/datadog-instrumentations/src/express.js +23 -0
- package/packages/datadog-instrumentations/src/helpers/hooks.js +3 -0
- package/packages/datadog-instrumentations/src/http2/client.js +25 -26
- package/packages/datadog-instrumentations/src/kafkajs.js +13 -4
- package/packages/datadog-instrumentations/src/opensearch.js +2 -1
- package/packages/datadog-instrumentations/src/passport-http.js +22 -0
- package/packages/datadog-instrumentations/src/passport-local.js +22 -0
- package/packages/datadog-instrumentations/src/passport-utils.js +36 -0
- package/packages/datadog-instrumentations/src/pg.js +17 -4
- package/packages/datadog-instrumentations/src/redis.js +48 -5
- package/packages/datadog-plugin-aws-sdk/src/base.js +3 -3
- package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +1 -0
- package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +1 -0
- package/packages/datadog-plugin-aws-sdk/src/services/s3.js +1 -0
- package/packages/datadog-plugin-aws-sdk/src/services/sns.js +1 -0
- package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +1 -0
- package/packages/datadog-plugin-cassandra-driver/src/index.js +4 -4
- package/packages/datadog-plugin-cypress/src/plugin.js +1 -1
- package/packages/datadog-plugin-grpc/src/client.js +8 -2
- package/packages/datadog-plugin-grpc/src/server.js +2 -2
- package/packages/datadog-plugin-http2/src/client.js +46 -29
- package/packages/datadog-plugin-kafkajs/src/consumer.js +6 -1
- package/packages/datadog-plugin-kafkajs/src/producer.js +14 -2
- package/packages/datadog-plugin-mocha/src/index.js +3 -3
- package/packages/datadog-plugin-moleculer/src/client.js +2 -2
- package/packages/datadog-plugin-moleculer/src/server.js +2 -2
- package/packages/datadog-plugin-mongodb-core/src/index.js +13 -2
- package/packages/datadog-plugin-next/src/index.js +50 -52
- package/packages/datadog-plugin-openai/src/index.js +9 -2
- package/packages/datadog-plugin-openai/src/services.js +14 -10
- package/packages/datadog-plugin-oracledb/src/index.js +1 -0
- package/packages/datadog-plugin-pg/src/index.js +1 -1
- package/packages/datadog-plugin-router/src/index.js +1 -1
- package/packages/dd-trace/src/appsec/channels.js +1 -0
- package/packages/dd-trace/src/appsec/iast/taint-tracking/origin-types.js +3 -2
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +12 -2
- package/packages/dd-trace/src/appsec/index.js +20 -0
- package/packages/dd-trace/src/appsec/passport.js +110 -0
- package/packages/dd-trace/src/appsec/sdk/track_event.js +14 -5
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +6 -5
- package/packages/dd-trace/src/ci-visibility/test-api-manual/test-api-manual-plugin.js +45 -0
- package/packages/dd-trace/src/config.js +27 -1
- package/packages/dd-trace/src/data_streams_context.js +15 -0
- package/packages/dd-trace/src/datastreams/pathway.js +58 -0
- package/packages/dd-trace/src/datastreams/processor.js +194 -0
- package/packages/dd-trace/src/datastreams/writer.js +66 -0
- package/packages/dd-trace/src/dogstatsd.js +14 -1
- package/packages/dd-trace/src/metrics.js +2 -2
- package/packages/dd-trace/src/plugin_manager.js +7 -2
- package/packages/dd-trace/src/plugins/ci_plugin.js +6 -1
- package/packages/dd-trace/src/plugins/client.js +1 -0
- package/packages/dd-trace/src/plugins/database.js +2 -1
- package/packages/dd-trace/src/plugins/index.js +1 -0
- package/packages/dd-trace/src/plugins/outbound.js +7 -2
- package/packages/dd-trace/src/plugins/plugin.js +28 -0
- package/packages/dd-trace/src/plugins/server.js +2 -0
- package/packages/dd-trace/src/plugins/tracing.js +36 -14
- package/packages/dd-trace/src/plugins/util/ci.js +1 -1
- package/packages/dd-trace/src/plugins/util/git.js +37 -5
- package/packages/dd-trace/src/plugins/util/test.js +55 -11
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +14 -1
- package/packages/dd-trace/src/profiling/config.js +34 -7
- package/packages/dd-trace/src/proxy.js +6 -0
- package/packages/dd-trace/src/service-naming/index.js +13 -1
- package/packages/dd-trace/src/service-naming/schemas/v0/index.js +2 -1
- package/packages/dd-trace/src/service-naming/schemas/v0/web.js +27 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/index.js +2 -1
- package/packages/dd-trace/src/service-naming/schemas/v1/web.js +26 -0
- package/packages/dd-trace/src/telemetry/metrics.js +76 -20
- package/packages/dd-trace/src/tracer.js +19 -1
- package/packages/diagnostics_channel/src/index.js +64 -0
package/LICENSE-3rdparty.csv
CHANGED
|
@@ -11,6 +11,7 @@ require,crypto-randomuuid,MIT,Copyright 2021 Node.js Foundation and contributors
|
|
|
11
11
|
require,diagnostics_channel,MIT,Copyright 2021 Simon D.
|
|
12
12
|
require,ignore,MIT,Copyright 2013 Kael Zhang and contributors
|
|
13
13
|
require,import-in-the-middle,Apache license 2.0,Copyright 2021 Datadog Inc.
|
|
14
|
+
require,int64-buffer,MIT,Copyright 2015-2016 Yusuke Kawasaki
|
|
14
15
|
require,ipaddr.js,MIT,Copyright 2011-2017 whitequark
|
|
15
16
|
require,istanbul-lib-coverage,BSD-3-Clause,Copyright 2012-2015 Yahoo! Inc.
|
|
16
17
|
require,koalas,MIT,Copyright 2013-2017 Brian Woodward
|
|
@@ -22,6 +23,7 @@ require,lodash.uniq,MIT,Copyright JS Foundation and other contributors
|
|
|
22
23
|
require,lru-cache,ISC,Copyright (c) 2010-2022 Isaac Z. Schlueter and Contributors
|
|
23
24
|
require,methods,MIT,Copyright 2013-2014 TJ Holowaychuk
|
|
24
25
|
require,module-details-from-path,MIT,Copyright 2016 Thomas Watson Steen
|
|
26
|
+
require,msgpack-lite,MIT,Copyright 2015 Yusuke Kawasaki
|
|
25
27
|
require,node-abort-controller,MIT,Copyright (c) 2019 Steve Faulkner
|
|
26
28
|
require,opentracing,MIT,Copyright 2016 Resonance Labs Inc
|
|
27
29
|
require,path-to-regexp,MIT,Copyright 2014 Blake Embrey
|
|
@@ -51,13 +53,11 @@ dev,express,MIT,Copyright 2009-2014 TJ Holowaychuk 2013-2014 Roman Shtylman 2014
|
|
|
51
53
|
dev,get-port,MIT,Copyright Sindre Sorhus
|
|
52
54
|
dev,glob,ISC,Copyright Isaac Z. Schlueter and Contributors
|
|
53
55
|
dev,graphql,MIT,Copyright 2015 Facebook Inc.
|
|
54
|
-
dev,int64-buffer,MIT,Copyright 2015-2016 Yusuke Kawasaki
|
|
55
56
|
dev,jszip,MIT,Copyright 2015-2016 Stuart Knightley and contributors
|
|
56
57
|
dev,knex,MIT,Copyright (c) 2013-present Tim Griesser
|
|
57
58
|
dev,mkdirp,MIT,Copyright 2010 James Halliday
|
|
58
59
|
dev,mocha,MIT,Copyright 2011-2018 JS Foundation and contributors https://js.foundation
|
|
59
60
|
dev,multer,MIT,Copyright 2014 Hage Yaapa
|
|
60
|
-
dev,msgpack-lite,MIT,Copyright 2015 Yusuke Kawasaki
|
|
61
61
|
dev,nock,MIT,Copyright 2017 Pedro Teixeira and other contributors
|
|
62
62
|
dev,nyc,ISC,Copyright 2015 Contributors
|
|
63
63
|
dev,pprof-format,MIT,Copyright 2022 Stephen Belanger
|
|
@@ -67,5 +67,6 @@ dev,sinon,BSD-3-Clause,Copyright 2010-2017 Christian Johansen
|
|
|
67
67
|
dev,sinon-chai,WTFPL and BSD-2-Clause,Copyright 2004 Sam Hocevar 2012–2017 Domenic Denicola
|
|
68
68
|
dev,tap,ISC,Copyright 2011-2022 Isaac Z. Schlueter and Contributors
|
|
69
69
|
dev,tape,MIT,Copyright James Halliday
|
|
70
|
-
file,aws-lambda-nodejs-runtime-interface-client,Apache 2.0,Copyright 2019 Amazon.com
|
|
70
|
+
file,aws-lambda-nodejs-runtime-interface-client,Apache 2.0,Copyright 2019 Amazon.com Inc. or its affiliates. All Rights Reserved.
|
|
71
71
|
file,profile.proto,Apache license 2.0,Copyright 2016 Google Inc.
|
|
72
|
+
file,is-git-url,MIT,Copyright (c) 2017 Jon Schlinkert.
|
package/index.d.ts
CHANGED
|
@@ -556,6 +556,19 @@ export declare interface TracerOptions {
|
|
|
556
556
|
* Specifies a path to a custom blocking template json file.
|
|
557
557
|
*/
|
|
558
558
|
blockedTemplateJson?: string,
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* Controls the automated user event tracking configuration
|
|
562
|
+
*/
|
|
563
|
+
eventTracking?: {
|
|
564
|
+
/**
|
|
565
|
+
* Controls the automated user event tracking mode. Possible values are disabled, safe and extended.
|
|
566
|
+
* On safe mode, any detected Personally Identifiable Information (PII) about the user will be redacted from the event.
|
|
567
|
+
* On extended mode, no redaction will take place.
|
|
568
|
+
* @default 'safe'
|
|
569
|
+
*/
|
|
570
|
+
mode?: 'safe' | 'extended' | 'disabled'
|
|
571
|
+
}
|
|
559
572
|
};
|
|
560
573
|
|
|
561
574
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dd-trace",
|
|
3
|
-
"version": "5.0.0-pre-
|
|
3
|
+
"version": "5.0.0-pre-2fed3ce",
|
|
4
4
|
"description": "Datadog APM tracing client for JavaScript",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"test:appsec:ci": "nyc --no-clean --include \"packages/dd-trace/src/appsec/**/*.js\" --exclude \"packages/dd-trace/test/appsec/**/*.plugin.spec.js\" -- npm run test:appsec",
|
|
20
20
|
"test:appsec:plugins": "mocha --colors --exit -r \"packages/dd-trace/test/setup/mocha.js\" \"packages/dd-trace/test/appsec/**/*.@($(echo $PLUGINS)).plugin.spec.js\"",
|
|
21
21
|
"test:appsec:plugins:ci": "yarn services && nyc --no-clean --include \"packages/dd-trace/test/appsec/**/*.@($(echo $PLUGINS)).plugin.spec.js\" -- npm run test:appsec:plugins",
|
|
22
|
-
"test:trace:core": "tap packages/dd-trace/test/*.spec.js \"packages/dd-trace/test/{ci-visibility,
|
|
22
|
+
"test:trace:core": "tap packages/dd-trace/test/*.spec.js \"packages/dd-trace/test/{ci-visibility,encode,exporters,opentelemetry,opentracing,plugins,service-naming,telemetry}/**/*.spec.js\"",
|
|
23
23
|
"test:trace:core:ci": "npm run test:trace:core -- --coverage --nyc-arg=--include=\"packages/dd-trace/src/**/*.js\"",
|
|
24
24
|
"test:instrumentations": "mocha --colors -r 'packages/dd-trace/test/setup/mocha.js' 'packages/datadog-instrumentations/test/**/*.spec.js'",
|
|
25
25
|
"test:instrumentations:ci": "nyc --no-clean --include 'packages/datadog-instrumentations/src/**/*.js' -- npm run test:instrumentations",
|
|
@@ -78,6 +78,7 @@
|
|
|
78
78
|
"diagnostics_channel": "^1.1.0",
|
|
79
79
|
"ignore": "^5.2.0",
|
|
80
80
|
"import-in-the-middle": "^1.3.5",
|
|
81
|
+
"int64-buffer": "^0.1.9",
|
|
81
82
|
"ipaddr.js": "^2.0.1",
|
|
82
83
|
"istanbul-lib-coverage": "3.2.0",
|
|
83
84
|
"koalas": "^1.0.2",
|
|
@@ -89,6 +90,7 @@
|
|
|
89
90
|
"lru-cache": "^7.14.0",
|
|
90
91
|
"methods": "^1.1.2",
|
|
91
92
|
"module-details-from-path": "^1.0.3",
|
|
93
|
+
"msgpack-lite": "^0.1.26",
|
|
92
94
|
"node-abort-controller": "^3.0.1",
|
|
93
95
|
"opentracing": ">=0.12.1",
|
|
94
96
|
"path-to-regexp": "^0.1.2",
|
|
@@ -120,12 +122,10 @@
|
|
|
120
122
|
"get-port": "^3.2.0",
|
|
121
123
|
"glob": "^7.1.6",
|
|
122
124
|
"graphql": "0.13.2",
|
|
123
|
-
"int64-buffer": "^0.1.9",
|
|
124
125
|
"jszip": "^3.5.0",
|
|
125
126
|
"knex": "^2.4.2",
|
|
126
127
|
"mkdirp": "^0.5.1",
|
|
127
128
|
"mocha": "8",
|
|
128
|
-
"msgpack-lite": "^0.1.26",
|
|
129
129
|
"multer": "^1.4.5-lts.1",
|
|
130
130
|
"nock": "^11.3.3",
|
|
131
131
|
"nyc": "^15.1.0",
|
|
@@ -166,6 +166,11 @@ function getChannelSuffix (name) {
|
|
|
166
166
|
].includes(name) ? name : 'default'
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
+
addHook({ name: '@smithy/smithy-client', versions: ['>=1.0.3'] }, smithy => {
|
|
170
|
+
shimmer.wrap(smithy.Client.prototype, 'send', wrapSmithySend)
|
|
171
|
+
return smithy
|
|
172
|
+
})
|
|
173
|
+
|
|
169
174
|
addHook({ name: '@aws-sdk/smithy-client', versions: ['>=3'] }, smithy => {
|
|
170
175
|
shimmer.wrap(smithy.Client.prototype, 'send', wrapSmithySend)
|
|
171
176
|
return smithy
|
|
@@ -28,7 +28,8 @@ addHook({ name: 'cassandra-driver', versions: ['>=3.0.0'] }, cassandra => {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
return asyncResource.runInAsyncScope(() => {
|
|
31
|
-
|
|
31
|
+
const contactPoints = this.options && this.options.contactPoints
|
|
32
|
+
startCh.publish({ keyspace: this.keyspace, query: queries, contactPoints })
|
|
32
33
|
try {
|
|
33
34
|
const res = batch.apply(this, arguments)
|
|
34
35
|
if (typeof res === 'function' || !res) {
|
|
@@ -56,7 +57,8 @@ addHook({ name: 'cassandra-driver', versions: ['>=4.4'] }, cassandra => {
|
|
|
56
57
|
}
|
|
57
58
|
const asyncResource = new AsyncResource('bound-anonymous-fn')
|
|
58
59
|
return asyncResource.runInAsyncScope(() => {
|
|
59
|
-
|
|
60
|
+
const contactPoints = this.options && this.options.contactPoints
|
|
61
|
+
startCh.publish({ keyspace: this.keyspace, query, contactPoints })
|
|
60
62
|
const promise = _execute.apply(this, arguments)
|
|
61
63
|
|
|
62
64
|
const promiseAsyncResource = new AsyncResource('bound-anonymous-fn')
|
|
@@ -88,7 +90,8 @@ addHook({ name: 'cassandra-driver', versions: ['3 - 4.3'] }, cassandra => {
|
|
|
88
90
|
}
|
|
89
91
|
|
|
90
92
|
return asyncResource.runInAsyncScope(() => {
|
|
91
|
-
|
|
93
|
+
const contactPoints = this.options && this.options.contactPoints
|
|
94
|
+
startCh.publish({ keyspace: this.keyspace, query, contactPoints })
|
|
92
95
|
|
|
93
96
|
const lastIndex = arguments.length - 1
|
|
94
97
|
let cb = arguments[lastIndex]
|
|
@@ -9,11 +9,13 @@ const shimmer = require('../../datadog-shimmer')
|
|
|
9
9
|
|
|
10
10
|
addHook({ name: '@elastic/transport', file: 'lib/Transport.js', versions: ['>=8'] }, (exports) => {
|
|
11
11
|
shimmer.wrap(exports.default.prototype, 'request', createWrapRequest('elasticsearch'))
|
|
12
|
+
shimmer.wrap(exports.default.prototype, 'getConnection', createWrapGetConnection('elasticsearch'))
|
|
12
13
|
return exports
|
|
13
14
|
})
|
|
14
15
|
|
|
15
16
|
addHook({ name: '@elastic/elasticsearch', file: 'lib/Transport.js', versions: ['>=5.6.16 <8', '>=8'] }, Transport => {
|
|
16
17
|
shimmer.wrap(Transport.prototype, 'request', createWrapRequest('elasticsearch'))
|
|
18
|
+
shimmer.wrap(Transport.prototype, 'getConnection', createWrapGetConnection('elasticsearch'))
|
|
17
19
|
return Transport
|
|
18
20
|
})
|
|
19
21
|
|
|
@@ -22,6 +24,42 @@ addHook({ name: 'elasticsearch', file: 'src/lib/transport.js', versions: ['>=10'
|
|
|
22
24
|
return Transport
|
|
23
25
|
})
|
|
24
26
|
|
|
27
|
+
addHook({ name: 'elasticsearch', file: 'src/lib/connection_pool.js', versions: ['>=10'] }, ConnectionPool => {
|
|
28
|
+
shimmer.wrap(ConnectionPool.prototype, 'select', createWrapSelect('elasticsearch'))
|
|
29
|
+
return ConnectionPool
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
function createWrapGetConnection (name) {
|
|
33
|
+
const connectCh = channel(`apm:${name}:query:connect`)
|
|
34
|
+
return function wrapRequest (request) {
|
|
35
|
+
return function () {
|
|
36
|
+
const connection = request.apply(this, arguments)
|
|
37
|
+
if (connectCh.hasSubscribers && connection && connection.url) {
|
|
38
|
+
connectCh.publish(connection.url)
|
|
39
|
+
}
|
|
40
|
+
return connection
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function createWrapSelect () {
|
|
46
|
+
const connectCh = channel('apm:elasticsearch:query:connect')
|
|
47
|
+
return function wrapRequest (request) {
|
|
48
|
+
return function () {
|
|
49
|
+
if (arguments.length === 1) {
|
|
50
|
+
const cb = arguments[0]
|
|
51
|
+
arguments[0] = function (err, connection) {
|
|
52
|
+
if (connectCh.hasSubscribers && connection && connection.host) {
|
|
53
|
+
connectCh.publish({ hostname: connection.host.host, port: connection.host.port })
|
|
54
|
+
}
|
|
55
|
+
cb(err, connection)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return request.apply(this, arguments)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
25
63
|
function createWrapRequest (name) {
|
|
26
64
|
const startCh = channel(`apm:${name}:query:start`)
|
|
27
65
|
const finishCh = channel(`apm:${name}:query:finish`)
|
|
@@ -83,4 +121,4 @@ function createWrapRequest (name) {
|
|
|
83
121
|
}
|
|
84
122
|
}
|
|
85
123
|
|
|
86
|
-
module.exports = { createWrapRequest }
|
|
124
|
+
module.exports = { createWrapRequest, createWrapGetConnection }
|
|
@@ -57,3 +57,26 @@ addHook({
|
|
|
57
57
|
})
|
|
58
58
|
})
|
|
59
59
|
})
|
|
60
|
+
|
|
61
|
+
const processParamsStartCh = channel('datadog:express:process_params:start')
|
|
62
|
+
const wrapProcessParamsMethod = (requestPositionInArguments) => {
|
|
63
|
+
return (original) => {
|
|
64
|
+
return function () {
|
|
65
|
+
if (processParamsStartCh.hasSubscribers) {
|
|
66
|
+
processParamsStartCh.publish({ req: arguments[requestPositionInArguments] })
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return original.apply(this, arguments)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
addHook({ name: 'express', versions: ['>=4.0.0 <4.3.0'] }, express => {
|
|
75
|
+
shimmer.wrap(express.Router, 'process_params', wrapProcessParamsMethod(1))
|
|
76
|
+
return express
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
addHook({ name: 'express', versions: ['>=4.3.0'] }, express => {
|
|
80
|
+
shimmer.wrap(express.Router, 'process_params', wrapProcessParamsMethod(2))
|
|
81
|
+
return express
|
|
82
|
+
})
|
|
@@ -16,6 +16,7 @@ module.exports = {
|
|
|
16
16
|
'@opensearch-project/opensearch': () => require('../opensearch'),
|
|
17
17
|
'@opentelemetry/sdk-trace-node': () => require('../otel-sdk-trace'),
|
|
18
18
|
'@redis/client': () => require('../redis'),
|
|
19
|
+
'@smithy/smithy-client': () => require('../aws-sdk'),
|
|
19
20
|
'amqp10': () => require('../amqp10'),
|
|
20
21
|
'amqplib': () => require('../amqplib'),
|
|
21
22
|
'aws-sdk': () => require('../aws-sdk'),
|
|
@@ -71,6 +72,8 @@ module.exports = {
|
|
|
71
72
|
'oracledb': () => require('../oracledb'),
|
|
72
73
|
'openai': () => require('../openai'),
|
|
73
74
|
'paperplane': () => require('../paperplane'),
|
|
75
|
+
'passport-http': () => require('../passport-http'),
|
|
76
|
+
'passport-local': () => require('../passport-local'),
|
|
74
77
|
'pg': () => require('../pg'),
|
|
75
78
|
'pino': () => require('../pino'),
|
|
76
79
|
'pino-pretty': () => require('../pino'),
|
|
@@ -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
|
}
|
|
@@ -16,10 +16,19 @@ const consumerFinishCh = channel('apm:kafkajs:consume:finish')
|
|
|
16
16
|
const consumerErrorCh = channel('apm:kafkajs:consume:error')
|
|
17
17
|
|
|
18
18
|
addHook({ name: 'kafkajs', versions: ['>=1.4'] }, (obj) => {
|
|
19
|
-
|
|
19
|
+
class Kafka extends obj.Kafka {
|
|
20
|
+
constructor (options) {
|
|
21
|
+
super(options)
|
|
22
|
+
this._brokers = (options.brokers && typeof options.brokers !== 'function')
|
|
23
|
+
? options.brokers.join(',') : undefined
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
obj.Kafka = Kafka
|
|
27
|
+
|
|
20
28
|
shimmer.wrap(Kafka.prototype, 'producer', createProducer => function () {
|
|
21
29
|
const producer = createProducer.apply(this, arguments)
|
|
22
30
|
const send = producer.send
|
|
31
|
+
const bootstrapServers = this._brokers
|
|
23
32
|
|
|
24
33
|
producer.send = function () {
|
|
25
34
|
const innerAsyncResource = new AsyncResource('bound-anonymous-fn')
|
|
@@ -36,7 +45,7 @@ addHook({ name: 'kafkajs', versions: ['>=1.4'] }, (obj) => {
|
|
|
36
45
|
message.headers = message.headers || {}
|
|
37
46
|
}
|
|
38
47
|
}
|
|
39
|
-
producerStartCh.publish({ topic, messages })
|
|
48
|
+
producerStartCh.publish({ topic, messages, bootstrapServers })
|
|
40
49
|
|
|
41
50
|
const result = send.apply(this, arguments)
|
|
42
51
|
|
|
@@ -69,6 +78,7 @@ addHook({ name: 'kafkajs', versions: ['>=1.4'] }, (obj) => {
|
|
|
69
78
|
const consumer = createConsumer.apply(this, arguments)
|
|
70
79
|
const run = consumer.run
|
|
71
80
|
|
|
81
|
+
const groupId = arguments[0].groupId
|
|
72
82
|
consumer.run = function ({ eachMessage, ...runArgs }) {
|
|
73
83
|
if (typeof eachMessage !== 'function') return run({ eachMessage, ...runArgs })
|
|
74
84
|
|
|
@@ -77,10 +87,9 @@ addHook({ name: 'kafkajs', versions: ['>=1.4'] }, (obj) => {
|
|
|
77
87
|
const innerAsyncResource = new AsyncResource('bound-anonymous-fn')
|
|
78
88
|
return innerAsyncResource.runInAsyncScope(() => {
|
|
79
89
|
const { topic, partition, message } = eachMessageArgs[0]
|
|
80
|
-
consumerStartCh.publish({ topic, partition, message })
|
|
90
|
+
consumerStartCh.publish({ topic, partition, message, groupId })
|
|
81
91
|
try {
|
|
82
92
|
const result = eachMessage.apply(this, eachMessageArgs)
|
|
83
|
-
|
|
84
93
|
if (result && typeof result.then === 'function') {
|
|
85
94
|
result.then(
|
|
86
95
|
innerAsyncResource.bind(() => consumerFinishCh.publish(undefined)),
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
const { addHook } = require('./helpers/instrument')
|
|
4
4
|
const shimmer = require('../../datadog-shimmer')
|
|
5
|
-
const { createWrapRequest } = require('./elasticsearch')
|
|
5
|
+
const { createWrapRequest, createWrapGetConnection } = require('./elasticsearch')
|
|
6
6
|
|
|
7
7
|
addHook({ name: '@opensearch-project/opensearch', file: 'lib/Transport.js', versions: ['>=1'] }, Transport => {
|
|
8
8
|
shimmer.wrap(Transport.prototype, 'request', createWrapRequest('opensearch'))
|
|
9
|
+
shimmer.wrap(Transport.prototype, 'getConnection', createWrapGetConnection('opensearch'))
|
|
9
10
|
return Transport
|
|
10
11
|
})
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const shimmer = require('../../datadog-shimmer')
|
|
4
|
+
const { addHook } = require('./helpers/instrument')
|
|
5
|
+
const { wrapVerify } = require('./passport-utils')
|
|
6
|
+
|
|
7
|
+
addHook({
|
|
8
|
+
name: 'passport-http',
|
|
9
|
+
file: 'lib/passport-http/strategies/basic.js',
|
|
10
|
+
versions: ['>=0.3.0']
|
|
11
|
+
}, BasicStrategy => {
|
|
12
|
+
return shimmer.wrap(BasicStrategy, function () {
|
|
13
|
+
const type = 'http'
|
|
14
|
+
|
|
15
|
+
if (typeof arguments[0] === 'function') {
|
|
16
|
+
arguments[0] = wrapVerify(arguments[0], false, type)
|
|
17
|
+
} else {
|
|
18
|
+
arguments[1] = wrapVerify(arguments[1], (arguments[0] && arguments[0].passReqToCallback), type)
|
|
19
|
+
}
|
|
20
|
+
return BasicStrategy.apply(this, arguments)
|
|
21
|
+
})
|
|
22
|
+
})
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const shimmer = require('../../datadog-shimmer')
|
|
4
|
+
const { addHook } = require('./helpers/instrument')
|
|
5
|
+
const { wrapVerify } = require('./passport-utils')
|
|
6
|
+
|
|
7
|
+
addHook({
|
|
8
|
+
name: 'passport-local',
|
|
9
|
+
file: 'lib/strategy.js',
|
|
10
|
+
versions: ['>=1.0.0']
|
|
11
|
+
}, Strategy => {
|
|
12
|
+
return shimmer.wrap(Strategy, function () {
|
|
13
|
+
const type = 'local'
|
|
14
|
+
|
|
15
|
+
if (typeof arguments[0] === 'function') {
|
|
16
|
+
arguments[0] = wrapVerify(arguments[0], false, type)
|
|
17
|
+
} else {
|
|
18
|
+
arguments[1] = wrapVerify(arguments[1], (arguments[0] && arguments[0].passReqToCallback), type)
|
|
19
|
+
}
|
|
20
|
+
return Strategy.apply(this, arguments)
|
|
21
|
+
})
|
|
22
|
+
})
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const shimmer = require('../../datadog-shimmer')
|
|
4
|
+
const { channel } = require('./helpers/instrument')
|
|
5
|
+
|
|
6
|
+
const passportVerifyChannel = channel('datadog:passport:verify:finish')
|
|
7
|
+
|
|
8
|
+
function wrapVerifiedAndPublish (username, password, verified, type) {
|
|
9
|
+
if (!passportVerifyChannel.hasSubscribers) {
|
|
10
|
+
return verified
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return shimmer.wrap(verified, function (err, user, info) {
|
|
14
|
+
const credentials = { type, username }
|
|
15
|
+
passportVerifyChannel.publish({ credentials, user })
|
|
16
|
+
return verified.apply(this, arguments)
|
|
17
|
+
})
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function wrapVerify (verify, passReq, type) {
|
|
21
|
+
if (passReq) {
|
|
22
|
+
return function (req, username, password, verified) {
|
|
23
|
+
arguments[3] = wrapVerifiedAndPublish(username, password, verified, type)
|
|
24
|
+
return verify.apply(this, arguments)
|
|
25
|
+
}
|
|
26
|
+
} else {
|
|
27
|
+
return function (username, password, verified) {
|
|
28
|
+
arguments[2] = wrapVerifiedAndPublish(username, password, verified, type)
|
|
29
|
+
return verify.apply(this, arguments)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
module.exports = {
|
|
35
|
+
wrapVerify
|
|
36
|
+
}
|
|
@@ -31,10 +31,23 @@ function wrapQuery (query) {
|
|
|
31
31
|
const asyncResource = new AsyncResource('bound-anonymous-fn')
|
|
32
32
|
const processId = this.processID
|
|
33
33
|
|
|
34
|
-
const pgQuery = arguments[0] && typeof arguments[0] === 'object'
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
const pgQuery = arguments[0] && typeof arguments[0] === 'object'
|
|
35
|
+
? arguments[0]
|
|
36
|
+
: { text: arguments[0] }
|
|
37
|
+
|
|
38
|
+
// The query objects passed in can be pretty complex. They can be instances of EventEmitter.
|
|
39
|
+
// For this reason we can't make a shallow clone of the object.
|
|
40
|
+
// Some libraries, such as sql-template-tags, can provide a getter .text property.
|
|
41
|
+
// For this reason we can't replace the .text property.
|
|
42
|
+
// Instead, we create a new object, and set the original query as the prototype.
|
|
43
|
+
// This allows any existing methods to still work and lets us easily provide a new query.
|
|
44
|
+
let newQuery = {
|
|
45
|
+
__ddInjectableQuery: '',
|
|
46
|
+
get text () {
|
|
47
|
+
return this.__ddInjectableQuery || Object.getPrototypeOf(this).text
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
Object.setPrototypeOf(newQuery, pgQuery)
|
|
38
51
|
|
|
39
52
|
return asyncResource.runInAsyncScope(() => {
|
|
40
53
|
startCh.publish({
|
|
@@ -11,6 +11,8 @@ const startCh = channel('apm:redis:command:start')
|
|
|
11
11
|
const finishCh = channel('apm:redis:command:finish')
|
|
12
12
|
const errorCh = channel('apm:redis:command:error')
|
|
13
13
|
|
|
14
|
+
let createClientUrl
|
|
15
|
+
|
|
14
16
|
function wrapAddCommand (addCommand) {
|
|
15
17
|
return function (command) {
|
|
16
18
|
if (!startCh.hasSubscribers) {
|
|
@@ -22,7 +24,7 @@ function wrapAddCommand (addCommand) {
|
|
|
22
24
|
|
|
23
25
|
const asyncResource = new AsyncResource('bound-anonymous-fn')
|
|
24
26
|
return asyncResource.runInAsyncScope(() => {
|
|
25
|
-
start(this, name, args)
|
|
27
|
+
start(this, name, args, this._url)
|
|
26
28
|
|
|
27
29
|
const res = addCommand.apply(this, arguments)
|
|
28
30
|
const onResolve = asyncResource.bind(() => finish(finishCh, errorCh))
|
|
@@ -35,12 +37,53 @@ function wrapAddCommand (addCommand) {
|
|
|
35
37
|
}
|
|
36
38
|
}
|
|
37
39
|
|
|
38
|
-
|
|
40
|
+
function wrapCommandQueueClass (cls) {
|
|
41
|
+
const ret = class RedisCommandQueue extends cls {
|
|
42
|
+
constructor () {
|
|
43
|
+
super(arguments)
|
|
44
|
+
if (createClientUrl) {
|
|
45
|
+
try {
|
|
46
|
+
const parsed = new URL(createClientUrl)
|
|
47
|
+
if (parsed) {
|
|
48
|
+
this._url = { host: parsed.hostname, port: +parsed.port || 6379 }
|
|
49
|
+
}
|
|
50
|
+
} catch (error) {
|
|
51
|
+
// ignore
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
this._url = this._url || { host: 'localhost', port: 6379 }
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return ret
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function wrapCreateClient (request) {
|
|
61
|
+
return function (opts) {
|
|
62
|
+
createClientUrl = opts && opts.url
|
|
63
|
+
const ret = request.apply(this, arguments)
|
|
64
|
+
createClientUrl = undefined
|
|
65
|
+
return ret
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
addHook({ name: '@node-redis/client', file: 'dist/lib/client/commands-queue.js', versions: ['>=1'] }, redis => {
|
|
70
|
+
redis.default = wrapCommandQueueClass(redis.default)
|
|
39
71
|
shimmer.wrap(redis.default.prototype, 'addCommand', wrapAddCommand)
|
|
40
72
|
return redis
|
|
41
73
|
})
|
|
42
74
|
|
|
43
|
-
addHook({ name: '@node-redis/client', file: 'dist/lib/client/
|
|
75
|
+
addHook({ name: '@node-redis/client', file: 'dist/lib/client/index.js', versions: ['>=1'] }, redis => {
|
|
76
|
+
shimmer.wrap(redis.default, 'create', wrapCreateClient)
|
|
77
|
+
return redis
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
addHook({ name: '@redis/client', file: 'dist/lib/client/index.js', versions: ['>=1.1'] }, redis => {
|
|
81
|
+
shimmer.wrap(redis.default, 'create', wrapCreateClient)
|
|
82
|
+
return redis
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
addHook({ name: '@redis/client', file: 'dist/lib/client/commands-queue.js', versions: ['>=1.1'] }, redis => {
|
|
86
|
+
redis.default = wrapCommandQueueClass(redis.default)
|
|
44
87
|
shimmer.wrap(redis.default.prototype, 'addCommand', wrapAddCommand)
|
|
45
88
|
return redis
|
|
46
89
|
})
|
|
@@ -106,9 +149,9 @@ addHook({ name: 'redis', versions: ['>=0.12 <2.6'] }, redis => {
|
|
|
106
149
|
return redis
|
|
107
150
|
})
|
|
108
151
|
|
|
109
|
-
function start (client, command, args) {
|
|
152
|
+
function start (client, command, args, url = {}) {
|
|
110
153
|
const db = client.selected_db
|
|
111
|
-
const connectionOptions = client.connection_options || client.connection_option || client.connectionOption ||
|
|
154
|
+
const connectionOptions = client.connection_options || client.connection_option || client.connectionOption || url
|
|
112
155
|
startCh.publish({ db, command, args, connectionOptions })
|
|
113
156
|
}
|
|
114
157
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const analyticsSampler = require('../../dd-trace/src/analytics_sampler')
|
|
4
|
-
const
|
|
4
|
+
const ClientPlugin = require('../../dd-trace/src/plugins/client')
|
|
5
5
|
const { storage } = require('../../datadog-core')
|
|
6
6
|
const { isTrue } = require('../../dd-trace/src/util')
|
|
7
7
|
|
|
8
|
-
class BaseAwsSdkPlugin extends
|
|
8
|
+
class BaseAwsSdkPlugin extends ClientPlugin {
|
|
9
9
|
static get id () { return 'aws' }
|
|
10
10
|
|
|
11
11
|
get serviceIdentifier () {
|
|
@@ -116,7 +116,7 @@ class BaseAwsSdkPlugin extends Plugin {
|
|
|
116
116
|
this.config.hooks.request(span, response)
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
super.finish()
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
configure (config) {
|
|
@@ -3,6 +3,7 @@ const log = require('../../../dd-trace/src/log')
|
|
|
3
3
|
const BaseAwsSdkPlugin = require('../base')
|
|
4
4
|
class Kinesis extends BaseAwsSdkPlugin {
|
|
5
5
|
static get id () { return 'kinesis' }
|
|
6
|
+
static get peerServicePrecursors () { return ['streamname'] }
|
|
6
7
|
|
|
7
8
|
generateTags (params, operation, response) {
|
|
8
9
|
if (!params || !params.StreamName) return {}
|