dd-trace 5.101.0 → 5.102.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/package.json +9 -7
- package/packages/datadog-instrumentations/src/aerospike.js +2 -2
- package/packages/datadog-instrumentations/src/ai.js +8 -8
- package/packages/datadog-instrumentations/src/amqplib.js +6 -7
- package/packages/datadog-instrumentations/src/anthropic.js +10 -10
- package/packages/datadog-instrumentations/src/apollo-server-core.js +3 -3
- package/packages/datadog-instrumentations/src/apollo-server.js +5 -5
- package/packages/datadog-instrumentations/src/avsc.js +6 -6
- package/packages/datadog-instrumentations/src/aws-sdk.js +151 -67
- package/packages/datadog-instrumentations/src/azure-durable-functions.js +8 -8
- package/packages/datadog-instrumentations/src/bluebird.js +2 -2
- package/packages/datadog-instrumentations/src/body-parser.js +2 -2
- package/packages/datadog-instrumentations/src/cassandra-driver.js +7 -7
- package/packages/datadog-instrumentations/src/child_process.js +12 -12
- package/packages/datadog-instrumentations/src/confluentinc-kafka-javascript.js +9 -9
- package/packages/datadog-instrumentations/src/connect.js +7 -7
- package/packages/datadog-instrumentations/src/cookie-parser.js +4 -4
- package/packages/datadog-instrumentations/src/cookie.js +2 -2
- package/packages/datadog-instrumentations/src/couchbase.js +16 -30
- package/packages/datadog-instrumentations/src/crypto.js +4 -4
- package/packages/datadog-instrumentations/src/cucumber.js +77 -16
- package/packages/datadog-instrumentations/src/dns.js +0 -3
- package/packages/datadog-instrumentations/src/elasticsearch.js +8 -11
- package/packages/datadog-instrumentations/src/express-mongo-sanitize.js +6 -6
- package/packages/datadog-instrumentations/src/express-session.js +4 -4
- package/packages/datadog-instrumentations/src/express.js +10 -11
- package/packages/datadog-instrumentations/src/fastify.js +2 -2
- package/packages/datadog-instrumentations/src/fs.js +14 -14
- package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +5 -7
- package/packages/datadog-instrumentations/src/google-genai.js +4 -4
- package/packages/datadog-instrumentations/src/grpc/server.js +2 -2
- package/packages/datadog-instrumentations/src/hapi.js +2 -2
- package/packages/datadog-instrumentations/src/helpers/callback-instrumentor.js +8 -8
- package/packages/datadog-instrumentations/src/helpers/promise.js +2 -2
- package/packages/datadog-instrumentations/src/hono.js +2 -2
- package/packages/datadog-instrumentations/src/http/client.js +6 -6
- package/packages/datadog-instrumentations/src/http/server.js +9 -9
- package/packages/datadog-instrumentations/src/jest.js +31 -31
- package/packages/datadog-instrumentations/src/kafkajs.js +9 -9
- package/packages/datadog-instrumentations/src/knex.js +17 -17
- package/packages/datadog-instrumentations/src/koa.js +12 -12
- package/packages/datadog-instrumentations/src/ldapjs.js +5 -5
- package/packages/datadog-instrumentations/src/light-my-request.js +2 -2
- package/packages/datadog-instrumentations/src/limitd-client.js +4 -4
- package/packages/datadog-instrumentations/src/lodash.js +4 -4
- package/packages/datadog-instrumentations/src/mariadb.js +13 -13
- package/packages/datadog-instrumentations/src/memcached.js +2 -2
- package/packages/datadog-instrumentations/src/microgateway-core.js +2 -2
- package/packages/datadog-instrumentations/src/mocha/common.js +3 -3
- package/packages/datadog-instrumentations/src/mocha/main.js +12 -10
- package/packages/datadog-instrumentations/src/mocha/utils.js +133 -16
- package/packages/datadog-instrumentations/src/mocha/worker.js +7 -5
- package/packages/datadog-instrumentations/src/mongodb-core.js +9 -22
- package/packages/datadog-instrumentations/src/mongodb.js +5 -5
- package/packages/datadog-instrumentations/src/mongoose.js +21 -21
- package/packages/datadog-instrumentations/src/mquery.js +5 -5
- package/packages/datadog-instrumentations/src/multer.js +4 -4
- package/packages/datadog-instrumentations/src/mysql.js +16 -16
- package/packages/datadog-instrumentations/src/mysql2.js +4 -4
- package/packages/datadog-instrumentations/src/net.js +14 -8
- package/packages/datadog-instrumentations/src/nyc.js +5 -5
- package/packages/datadog-instrumentations/src/openai.js +19 -19
- package/packages/datadog-instrumentations/src/oracledb.js +6 -6
- package/packages/datadog-instrumentations/src/passport-utils.js +5 -5
- package/packages/datadog-instrumentations/src/pg.js +15 -15
- package/packages/datadog-instrumentations/src/pino.js +6 -10
- package/packages/datadog-instrumentations/src/playwright.js +20 -15
- package/packages/datadog-instrumentations/src/protobufjs.js +16 -16
- package/packages/datadog-instrumentations/src/redis.js +1 -2
- package/packages/datadog-instrumentations/src/restify.js +2 -2
- package/packages/datadog-instrumentations/src/router.js +12 -12
- package/packages/datadog-instrumentations/src/stripe.js +12 -12
- package/packages/datadog-instrumentations/src/vitest.js +107 -26
- package/packages/datadog-instrumentations/src/winston.js +4 -4
- package/packages/datadog-instrumentations/src/ws.js +7 -7
- package/packages/datadog-plugin-aws-sdk/src/base.js +52 -4
- package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +19 -12
- package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +45 -35
- package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +33 -22
- package/packages/datadog-plugin-aws-sdk/src/services/sns.js +12 -13
- package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +73 -54
- package/packages/datadog-plugin-aws-sdk/src/services/stepfunctions.js +19 -17
- package/packages/datadog-plugin-aws-sdk/src/util.js +22 -0
- package/packages/datadog-plugin-child_process/src/scrub-cmd-params.js +6 -6
- package/packages/datadog-plugin-cucumber/src/index.js +4 -0
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +1 -4
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +1 -5
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +3 -1
- package/packages/datadog-plugin-http/src/client.js +1 -5
- package/packages/datadog-plugin-jest/src/util.js +1 -2
- package/packages/datadog-plugin-mocha/src/index.js +4 -0
- package/packages/datadog-plugin-mongodb-core/src/index.js +2 -1
- package/packages/datadog-plugin-openai/src/tracing.js +12 -23
- package/packages/datadog-plugin-playwright/src/index.js +1 -1
- package/packages/datadog-plugin-vitest/src/index.js +8 -1
- package/packages/datadog-shimmer/src/shimmer.js +7 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-password-rules.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-secret-rules.js +81 -81
- package/packages/dd-trace/src/appsec/iast/security-controls/index.js +2 -2
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugins/kafka.js +2 -2
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +2 -2
- package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +2 -2
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +2 -0
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/index.js +1 -3
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/utils.js +83 -48
- package/packages/dd-trace/src/appsec/index.js +21 -24
- package/packages/dd-trace/src/appsec/reporter.js +3 -1
- package/packages/dd-trace/src/appsec/rule_manager.js +4 -2
- package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +31 -16
- package/packages/dd-trace/src/config/git_properties.js +2 -2
- package/packages/dd-trace/src/datastreams/index.js +2 -1
- package/packages/dd-trace/src/datastreams/processor.js +1 -2
- package/packages/dd-trace/src/debugger/devtools_client/snapshot-pruner.js +1 -0
- package/packages/dd-trace/src/encode/0.4.js +757 -232
- package/packages/dd-trace/src/encode/0.5.js +13 -7
- package/packages/dd-trace/src/llmobs/plugins/ai/util.js +1 -2
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +6 -3
- package/packages/dd-trace/src/llmobs/sdk.js +24 -26
- package/packages/dd-trace/src/llmobs/span_processor.js +25 -5
- package/packages/dd-trace/src/llmobs/util.js +1 -0
- package/packages/dd-trace/src/msgpack/chunk.js +6 -3
- package/packages/dd-trace/src/openfeature/noop.js +40 -36
- package/packages/dd-trace/src/openfeature/writers/exposures.js +33 -52
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_transformer_base.js +1 -2
- package/packages/dd-trace/src/opentelemetry/tracer.js +0 -22
- package/packages/dd-trace/src/opentracing/propagation/text_map_dsm.js +2 -11
- package/packages/dd-trace/src/plugins/util/ci.js +1 -1
- package/packages/dd-trace/src/plugins/util/git-cache.js +3 -5
- package/packages/dd-trace/src/plugins/util/test.js +19 -7
- package/packages/dd-trace/src/plugins/util/url.js +1 -3
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +1 -1
- package/packages/dd-trace/src/plugins/util/web.js +5 -7
- package/packages/dd-trace/src/profiling/profilers/events.js +3 -23
- package/packages/dd-trace/src/profiling/profilers/wall.js +4 -5
- package/packages/dd-trace/src/runtime_metrics/index.js +2 -2
- package/packages/dd-trace/src/scope.js +3 -10
- package/packages/dd-trace/src/serverless.js +1 -4
- package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +7 -1
- package/packages/dd-trace/src/service-naming/schemas/v1/messaging.js +4 -0
- package/packages/dd-trace/src/tracer.js +7 -7
|
@@ -18,8 +18,6 @@ const rrtypes = {
|
|
|
18
18
|
resolveSoa: 'SOA',
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
const rrtypeMap = new WeakMap()
|
|
22
|
-
|
|
23
21
|
addHook({ name: 'dns' }, dns => {
|
|
24
22
|
const lookup = createCallbackInstrumentor('apm:dns:lookup', { captureResult: true })
|
|
25
23
|
const lookupService = createCallbackInstrumentor('apm:dns:lookup_service', { captureResult: true })
|
|
@@ -46,7 +44,6 @@ addHook({ name: 'dns' }, dns => {
|
|
|
46
44
|
function patchResolveShorthands (prototype, resolve) {
|
|
47
45
|
for (const method of Object.keys(rrtypes)) {
|
|
48
46
|
if (prototype[method]) {
|
|
49
|
-
rrtypeMap.set(prototype[method], rrtypes[method])
|
|
50
47
|
shimmer.wrap(prototype, method, resolve(buildArgsContext(rrtypes[method])))
|
|
51
48
|
}
|
|
52
49
|
}
|
|
@@ -24,24 +24,21 @@ function wrapTransportPrototype (Transport) {
|
|
|
24
24
|
addHook({ name: '@elastic/elasticsearch', file: 'lib/Transport.js', versions: ['>=5.6.16 <8', '>=8'] }, Transport => {
|
|
25
25
|
shimmer.wrap(Transport.prototype, 'request', createWrapRequest('elasticsearch'))
|
|
26
26
|
shimmer.wrap(Transport.prototype, 'getConnection', createWrapGetConnection('elasticsearch'))
|
|
27
|
-
return Transport
|
|
28
27
|
})
|
|
29
28
|
|
|
30
29
|
addHook({ name: 'elasticsearch', file: 'src/lib/transport.js', versions: ['>=10'] }, Transport => {
|
|
31
30
|
shimmer.wrap(Transport.prototype, 'request', createWrapRequest('elasticsearch'))
|
|
32
|
-
return Transport
|
|
33
31
|
})
|
|
34
32
|
|
|
35
33
|
addHook({ name: 'elasticsearch', file: 'src/lib/connection_pool.js', versions: ['>=10'] }, ConnectionPool => {
|
|
36
|
-
shimmer.wrap(ConnectionPool.prototype, 'select', createWrapSelect(
|
|
37
|
-
return ConnectionPool
|
|
34
|
+
shimmer.wrap(ConnectionPool.prototype, 'select', createWrapSelect())
|
|
38
35
|
})
|
|
39
36
|
|
|
40
37
|
function createWrapGetConnection (name) {
|
|
41
38
|
const connectCh = channel(`apm:${name}:query:connect`)
|
|
42
39
|
return function wrapRequest (request) {
|
|
43
|
-
return function () {
|
|
44
|
-
const connection = request.apply(this,
|
|
40
|
+
return function (...args) {
|
|
41
|
+
const connection = request.apply(this, args)
|
|
45
42
|
if (connectCh.hasSubscribers && connection && connection.url) {
|
|
46
43
|
connectCh.publish(connection.url)
|
|
47
44
|
}
|
|
@@ -53,17 +50,17 @@ function createWrapGetConnection (name) {
|
|
|
53
50
|
function createWrapSelect () {
|
|
54
51
|
const connectCh = channel('apm:elasticsearch:query:connect')
|
|
55
52
|
return function wrapRequest (request) {
|
|
56
|
-
return function () {
|
|
57
|
-
if (
|
|
58
|
-
const cb =
|
|
59
|
-
|
|
53
|
+
return function (...args) {
|
|
54
|
+
if (args.length === 1) {
|
|
55
|
+
const cb = args[0]
|
|
56
|
+
args[0] = shimmer.wrapFunction(cb, cb => function (err, connection) {
|
|
60
57
|
if (connectCh.hasSubscribers && connection && connection.host) {
|
|
61
58
|
connectCh.publish({ hostname: connection.host.host, port: connection.host.port })
|
|
62
59
|
}
|
|
63
60
|
cb(err, connection)
|
|
64
61
|
})
|
|
65
62
|
}
|
|
66
|
-
return request.apply(this,
|
|
63
|
+
return request.apply(this, args)
|
|
67
64
|
}
|
|
68
65
|
}
|
|
69
66
|
}
|
|
@@ -12,8 +12,8 @@ const sanitizeMiddlewareFinished = channel('datadog:express-mongo-sanitize:filte
|
|
|
12
12
|
const propertiesToSanitize = ['body', 'params', 'headers', 'query']
|
|
13
13
|
|
|
14
14
|
addHook({ name: 'express-mongo-sanitize', versions: ['>=1.0.0'] }, expressMongoSanitize => {
|
|
15
|
-
shimmer.wrap(expressMongoSanitize, 'sanitize', sanitize => function () {
|
|
16
|
-
const sanitizedObject = sanitize.apply(this,
|
|
15
|
+
shimmer.wrap(expressMongoSanitize, 'sanitize', sanitize => function (...args) {
|
|
16
|
+
const sanitizedObject = sanitize.apply(this, args)
|
|
17
17
|
|
|
18
18
|
if (sanitizeMethodFinished.hasSubscribers) {
|
|
19
19
|
sanitizeMethodFinished.publish({ sanitizedObject })
|
|
@@ -22,21 +22,21 @@ addHook({ name: 'express-mongo-sanitize', versions: ['>=1.0.0'] }, expressMongoS
|
|
|
22
22
|
return sanitizedObject
|
|
23
23
|
})
|
|
24
24
|
|
|
25
|
-
return shimmer.wrapFunction(expressMongoSanitize, expressMongoSanitize => function () {
|
|
26
|
-
const middleware = expressMongoSanitize.apply(this,
|
|
25
|
+
return shimmer.wrapFunction(expressMongoSanitize, expressMongoSanitize => function (...args) {
|
|
26
|
+
const middleware = expressMongoSanitize.apply(this, args)
|
|
27
27
|
|
|
28
28
|
return shimmer.wrapFunction(middleware, middleware => function (req, res, next) {
|
|
29
29
|
if (!sanitizeMiddlewareFinished.hasSubscribers) {
|
|
30
30
|
return middleware.apply(this, arguments)
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
const wrappedNext = shimmer.wrapFunction(next, next => function () {
|
|
33
|
+
const wrappedNext = shimmer.wrapFunction(next, next => function (...args) {
|
|
34
34
|
sanitizeMiddlewareFinished.publish({
|
|
35
35
|
sanitizedProperties: propertiesToSanitize,
|
|
36
36
|
req,
|
|
37
37
|
})
|
|
38
38
|
|
|
39
|
-
return next.apply(this,
|
|
39
|
+
return next.apply(this, args)
|
|
40
40
|
})
|
|
41
41
|
|
|
42
42
|
return middleware.call(this, req, res, wrappedNext)
|
|
@@ -8,7 +8,7 @@ const sessionMiddlewareFinishCh = channel('datadog:express-session:middleware:fi
|
|
|
8
8
|
function wrapSessionMiddleware (sessionMiddleware) {
|
|
9
9
|
return function wrappedSessionMiddleware (req, res, next) {
|
|
10
10
|
shimmer.wrap(arguments, 2, function wrapNext (next) {
|
|
11
|
-
return function wrappedNext () {
|
|
11
|
+
return function wrappedNext (...args) {
|
|
12
12
|
if (sessionMiddlewareFinishCh.hasSubscribers) {
|
|
13
13
|
const abortController = new AbortController()
|
|
14
14
|
|
|
@@ -17,7 +17,7 @@ function wrapSessionMiddleware (sessionMiddleware) {
|
|
|
17
17
|
if (abortController.signal.aborted) return
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
return next.apply(this,
|
|
20
|
+
return next.apply(this, args)
|
|
21
21
|
}
|
|
22
22
|
})
|
|
23
23
|
|
|
@@ -26,8 +26,8 @@ function wrapSessionMiddleware (sessionMiddleware) {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
function wrapSession (session) {
|
|
29
|
-
return function wrappedSession () {
|
|
30
|
-
const sessionMiddleware = session.apply(this,
|
|
29
|
+
return function wrappedSession (...args) {
|
|
30
|
+
const sessionMiddleware = session.apply(this, args)
|
|
31
31
|
|
|
32
32
|
return shimmer.wrapFunction(sessionMiddleware, wrapSessionMiddleware)
|
|
33
33
|
}
|
|
@@ -54,13 +54,12 @@ function wrapResponseRender (render) {
|
|
|
54
54
|
|
|
55
55
|
const abortController = new AbortController()
|
|
56
56
|
return responseRenderChannel.traceSync(
|
|
57
|
-
function () {
|
|
57
|
+
function (...args) {
|
|
58
58
|
if (abortController.signal.aborted) {
|
|
59
|
-
|
|
60
|
-
throw error
|
|
59
|
+
throw abortController.signal.reason || new Error('Aborted')
|
|
61
60
|
}
|
|
62
61
|
|
|
63
|
-
return render.apply(this,
|
|
62
|
+
return render.apply(this, args)
|
|
64
63
|
},
|
|
65
64
|
{
|
|
66
65
|
req: this.req,
|
|
@@ -173,7 +172,7 @@ addHook({ name: 'express', versions: ['4'], file: 'lib/express.js' }, express =>
|
|
|
173
172
|
const queryParserReadCh = channel('datadog:query:read:finish')
|
|
174
173
|
|
|
175
174
|
function publishQueryParsedAndNext (req, res, next) {
|
|
176
|
-
return shimmer.wrapFunction(next, next => function () {
|
|
175
|
+
return shimmer.wrapFunction(next, next => function (...args) {
|
|
177
176
|
if (queryParserReadCh.hasSubscribers && req) {
|
|
178
177
|
const abortController = new AbortController()
|
|
179
178
|
const query = req.query
|
|
@@ -183,7 +182,7 @@ function publishQueryParsedAndNext (req, res, next) {
|
|
|
183
182
|
if (abortController.signal.aborted) return
|
|
184
183
|
}
|
|
185
184
|
|
|
186
|
-
return next.apply(this,
|
|
185
|
+
return next.apply(this, args)
|
|
187
186
|
})
|
|
188
187
|
}
|
|
189
188
|
|
|
@@ -192,8 +191,8 @@ addHook({
|
|
|
192
191
|
versions: ['4'],
|
|
193
192
|
file: 'lib/middleware/query.js',
|
|
194
193
|
}, query => {
|
|
195
|
-
return shimmer.wrapFunction(query, query => function () {
|
|
196
|
-
const queryMiddleware = query.apply(this,
|
|
194
|
+
return shimmer.wrapFunction(query, query => function (...args) {
|
|
195
|
+
const queryMiddleware = query.apply(this, args)
|
|
197
196
|
|
|
198
197
|
return shimmer.wrapFunction(queryMiddleware, queryMiddleware => function (req, res, next) {
|
|
199
198
|
arguments[2] = publishQueryParsedAndNext(req, res, next)
|
|
@@ -205,9 +204,9 @@ addHook({
|
|
|
205
204
|
const processParamsStartCh = channel('datadog:express:process_params:start')
|
|
206
205
|
function wrapProcessParamsMethod (requestPositionInArguments) {
|
|
207
206
|
return function wrapProcessParams (original) {
|
|
208
|
-
return function wrappedProcessParams () {
|
|
207
|
+
return function wrappedProcessParams (...args) {
|
|
209
208
|
if (processParamsStartCh.hasSubscribers) {
|
|
210
|
-
const req =
|
|
209
|
+
const req = args[requestPositionInArguments]
|
|
211
210
|
const abortController = new AbortController()
|
|
212
211
|
|
|
213
212
|
processParamsStartCh.publish({
|
|
@@ -220,7 +219,7 @@ function wrapProcessParamsMethod (requestPositionInArguments) {
|
|
|
220
219
|
if (abortController.signal.aborted) return
|
|
221
220
|
}
|
|
222
221
|
|
|
223
|
-
return original.apply(this,
|
|
222
|
+
return original.apply(this, args)
|
|
224
223
|
}
|
|
225
224
|
}
|
|
226
225
|
}
|
|
@@ -25,8 +25,8 @@ const bodyPublished = new WeakSet()
|
|
|
25
25
|
function wrapFastify (fastify, hasParsingEvents) {
|
|
26
26
|
if (typeof fastify !== 'function') return fastify
|
|
27
27
|
|
|
28
|
-
return function fastifyWithTrace () {
|
|
29
|
-
const app = fastify.apply(this,
|
|
28
|
+
return function fastifyWithTrace (...args) {
|
|
29
|
+
const app = fastify.apply(this, args)
|
|
30
30
|
|
|
31
31
|
if (!app || typeof app.addHook !== 'function') return app
|
|
32
32
|
|
|
@@ -165,13 +165,13 @@ function initDirAsyncIteratorProperties (iterator) {
|
|
|
165
165
|
|
|
166
166
|
function createWrapDirAsyncIterator () {
|
|
167
167
|
return function wrapDirAsyncIterator (asyncIterator) {
|
|
168
|
-
return function wrappedAsyncIterator () {
|
|
168
|
+
return function wrappedAsyncIterator (...args) {
|
|
169
169
|
if (!kDirReadPromisified || !kDirClosePromisified) {
|
|
170
170
|
initDirAsyncIteratorProperties(this)
|
|
171
171
|
}
|
|
172
172
|
wrap(this, kDirReadPromisified, createWrapFunction('dir.', 'read'))
|
|
173
173
|
wrap(this, kDirClosePromisified, createWrapFunction('dir.', 'close'))
|
|
174
|
-
return asyncIterator.apply(this,
|
|
174
|
+
return asyncIterator.apply(this, args)
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
}
|
|
@@ -231,12 +231,12 @@ function createWatchWrapFunction (override = '') {
|
|
|
231
231
|
const name = override || original.name
|
|
232
232
|
const method = name
|
|
233
233
|
const operation = name
|
|
234
|
-
return function () {
|
|
235
|
-
if (!startChannel.hasSubscribers) return original.apply(this,
|
|
236
|
-
const ctx = getMessage(method, watchMethods[operation],
|
|
234
|
+
return function (...args) {
|
|
235
|
+
if (!startChannel.hasSubscribers) return original.apply(this, args)
|
|
236
|
+
const ctx = getMessage(method, watchMethods[operation], args, this)
|
|
237
237
|
return startChannel.runStores(ctx, () => {
|
|
238
238
|
try {
|
|
239
|
-
const result = original.apply(this,
|
|
239
|
+
const result = original.apply(this, args)
|
|
240
240
|
finishChannel.runStores(ctx, () => {})
|
|
241
241
|
return result
|
|
242
242
|
} catch (error) {
|
|
@@ -256,14 +256,14 @@ function createWrapFunction (prefix = '', override = '') {
|
|
|
256
256
|
const method = `${prefix}${name}`
|
|
257
257
|
const operation = name.match(/^(.+?)(Sync)?(\.native)?$/)[1]
|
|
258
258
|
|
|
259
|
-
return function () {
|
|
260
|
-
if (!startChannel.hasSubscribers) return original.apply(this,
|
|
259
|
+
return function (...args) {
|
|
260
|
+
if (!startChannel.hasSubscribers) return original.apply(this, args)
|
|
261
261
|
|
|
262
|
-
const lastIndex =
|
|
263
|
-
const cb = typeof
|
|
262
|
+
const lastIndex = args.length - 1
|
|
263
|
+
const cb = typeof args[lastIndex] === 'function' && args[lastIndex]
|
|
264
264
|
const params = getMethodParamsRelationByPrefix(prefix)[operation]
|
|
265
265
|
const abortController = new AbortController()
|
|
266
|
-
const ctx = { ...getMessage(method, params,
|
|
266
|
+
const ctx = { ...getMessage(method, params, args, this), abortController }
|
|
267
267
|
|
|
268
268
|
const finish = function (error, cb = () => {}) {
|
|
269
269
|
if (error !== null && typeof error === 'object') { // fs.exists receives a boolean
|
|
@@ -274,7 +274,7 @@ function createWrapFunction (prefix = '', override = '') {
|
|
|
274
274
|
}
|
|
275
275
|
|
|
276
276
|
if (cb) {
|
|
277
|
-
|
|
277
|
+
args[lastIndex] = shimmer.wrapFunction(cb, cb => function (e) {
|
|
278
278
|
return finish(e, () => cb.apply(this, arguments))
|
|
279
279
|
})
|
|
280
280
|
}
|
|
@@ -290,13 +290,13 @@ function createWrapFunction (prefix = '', override = '') {
|
|
|
290
290
|
finish(error)
|
|
291
291
|
throw error
|
|
292
292
|
} else if (cb) {
|
|
293
|
-
|
|
293
|
+
args[lastIndex](error)
|
|
294
294
|
return
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
297
|
|
|
298
298
|
try {
|
|
299
|
-
const result = original.apply(this,
|
|
299
|
+
const result = original.apply(this, args)
|
|
300
300
|
if (cb) return result
|
|
301
301
|
if (result && typeof result.then === 'function') {
|
|
302
302
|
// TODO method open returning promise and filehandle prototype not initialized, initialize it
|
|
@@ -167,17 +167,17 @@ addHook({ name: '@google-cloud/pubsub', versions: ['>=1.2'], file: 'build/src/su
|
|
|
167
167
|
* Flow: message.ack() -> store context -> acknowledge() API -> retrieve context
|
|
168
168
|
*/
|
|
169
169
|
if (Message?.prototype?.ack) {
|
|
170
|
-
shimmer.wrap(Message.prototype, 'ack', originalAck => function () {
|
|
170
|
+
shimmer.wrap(Message.prototype, 'ack', originalAck => function (...args) {
|
|
171
171
|
if (this.ackId) {
|
|
172
172
|
const ctx = {
|
|
173
173
|
message: this,
|
|
174
174
|
ackId: this.ackId,
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
return messageAckStoreCh.runStores(ctx, originalAck, this, ...
|
|
177
|
+
return messageAckStoreCh.runStores(ctx, originalAck, this, ...args)
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
-
return originalAck.apply(this,
|
|
180
|
+
return originalAck.apply(this, args)
|
|
181
181
|
})
|
|
182
182
|
}
|
|
183
183
|
|
|
@@ -212,7 +212,7 @@ addHook({ name: '@google-cloud/pubsub', versions: ['>=1.2'], file: 'build/src/le
|
|
|
212
212
|
return receiveFinishCh.runStores(ctx || { message }, remove, this, ...arguments)
|
|
213
213
|
})
|
|
214
214
|
|
|
215
|
-
shimmer.wrap(LeaseManager.prototype, 'clear', clear => function () {
|
|
215
|
+
shimmer.wrap(LeaseManager.prototype, 'clear', clear => function (...args) {
|
|
216
216
|
if (this._messages) {
|
|
217
217
|
for (const message of this._messages.values()) {
|
|
218
218
|
const ctx = messageContexts.get(message)
|
|
@@ -222,10 +222,8 @@ addHook({ name: '@google-cloud/pubsub', versions: ['>=1.2'], file: 'build/src/le
|
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
|
-
return clear.apply(this,
|
|
225
|
+
return clear.apply(this, args)
|
|
226
226
|
})
|
|
227
|
-
|
|
228
|
-
return obj
|
|
229
227
|
})
|
|
230
228
|
|
|
231
229
|
/**
|
|
@@ -46,10 +46,10 @@ function wrapGenerateContent (method) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
function wrapStreamIterator (iterator, ctx) {
|
|
49
|
-
return function () {
|
|
50
|
-
const itr = iterator.apply(this,
|
|
51
|
-
shimmer.wrap(itr, 'next', next => function () {
|
|
52
|
-
return next.apply(this,
|
|
49
|
+
return function (...args) {
|
|
50
|
+
const itr = iterator.apply(this, args)
|
|
51
|
+
shimmer.wrap(itr, 'next', next => function (...args) {
|
|
52
|
+
return next.apply(this, args)
|
|
53
53
|
.then(res => {
|
|
54
54
|
const { done, value: chunk } = res
|
|
55
55
|
onStreamedChunkCh.publish({ ctx, chunk, done })
|
|
@@ -49,9 +49,9 @@ function wrapHandler (func, name) {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
shimmer.wrap(call, 'emit', emit => {
|
|
52
|
-
return function () {
|
|
52
|
+
return function (...args) {
|
|
53
53
|
return emitChannel.runStores(ctx, () => {
|
|
54
|
-
return emit.apply(this,
|
|
54
|
+
return emit.apply(this, args)
|
|
55
55
|
})
|
|
56
56
|
}
|
|
57
57
|
})
|
|
@@ -28,12 +28,12 @@ function wrapServer (server) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
function wrapStart (start) {
|
|
31
|
-
return shimmer.wrapFunction(start, start => function () {
|
|
31
|
+
return shimmer.wrapFunction(start, start => function (...args) {
|
|
32
32
|
if (this && typeof this.ext === 'function') {
|
|
33
33
|
this.ext('onPreResponse', onPreResponse)
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
return start.apply(this,
|
|
36
|
+
return start.apply(this, args)
|
|
37
37
|
})
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -32,20 +32,20 @@ function createCallbackInstrumentor (prefix, { captureResult = false } = {}) {
|
|
|
32
32
|
|
|
33
33
|
return function instrument (buildContext) {
|
|
34
34
|
return function wrap (fn) {
|
|
35
|
-
return function () {
|
|
36
|
-
const lastIndex =
|
|
37
|
-
const cb =
|
|
35
|
+
return function (...args) {
|
|
36
|
+
const lastIndex = args.length - 1
|
|
37
|
+
const cb = args[lastIndex]
|
|
38
38
|
if (!startCh.hasSubscribers || typeof cb !== 'function') {
|
|
39
|
-
return fn.apply(this,
|
|
39
|
+
return fn.apply(this, args)
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
const ctx = buildContext(this,
|
|
42
|
+
const ctx = buildContext(this, args)
|
|
43
43
|
if (ctx === undefined) {
|
|
44
|
-
return fn.apply(this,
|
|
44
|
+
return fn.apply(this, args)
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
return startCh.runStores(ctx, () => {
|
|
48
|
-
|
|
48
|
+
args[lastIndex] = shimmer.wrapFunction(cb, cb => function (error, ...rest) {
|
|
49
49
|
if (error) {
|
|
50
50
|
ctx.error = error
|
|
51
51
|
errorCh.publish(ctx)
|
|
@@ -57,7 +57,7 @@ function createCallbackInstrumentor (prefix, { captureResult = false } = {}) {
|
|
|
57
57
|
})
|
|
58
58
|
|
|
59
59
|
try {
|
|
60
|
-
return fn.apply(this,
|
|
60
|
+
return fn.apply(this, args)
|
|
61
61
|
} catch (error) {
|
|
62
62
|
void error.stack // trigger getting the stack at the original throwing point
|
|
63
63
|
ctx.error = error
|
|
@@ -21,9 +21,9 @@ exports.wrapThen = function wrapThen (origThen) {
|
|
|
21
21
|
function wrapCallback (ar, callback) {
|
|
22
22
|
if (typeof callback !== 'function') return callback
|
|
23
23
|
|
|
24
|
-
return function () {
|
|
24
|
+
return function (...args) {
|
|
25
25
|
return ar.runInAsyncScope(() => {
|
|
26
|
-
return callback.apply(this,
|
|
26
|
+
return callback.apply(this, args)
|
|
27
27
|
})
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -56,10 +56,10 @@ function wrapNext (req, route, next) {
|
|
|
56
56
|
return shimmer.wrapFunction(
|
|
57
57
|
next,
|
|
58
58
|
(next) =>
|
|
59
|
-
function () {
|
|
59
|
+
function (...args) {
|
|
60
60
|
nextChannel.publish({ req, route })
|
|
61
61
|
|
|
62
|
-
return next.apply(this,
|
|
62
|
+
return next.apply(this, args)
|
|
63
63
|
}
|
|
64
64
|
)
|
|
65
65
|
}
|
|
@@ -107,8 +107,8 @@ function setupResponseInstrumentation (ctx, res) {
|
|
|
107
107
|
// For 'readable' events, wrap the read() method
|
|
108
108
|
if (eventName === 'readable' && !originalRead && !dataListenerAdded && typeof res.read === 'function') {
|
|
109
109
|
originalRead = res.read
|
|
110
|
-
res.read = function () {
|
|
111
|
-
const chunk = originalRead.apply(this,
|
|
110
|
+
res.read = function (...args) {
|
|
111
|
+
const chunk = originalRead.apply(this, args)
|
|
112
112
|
if (!dataListenerAdded) {
|
|
113
113
|
dataReadStarted = true
|
|
114
114
|
collectChunk(chunk)
|
|
@@ -189,9 +189,9 @@ function patch (http, methodName) {
|
|
|
189
189
|
let callback = args.callback
|
|
190
190
|
|
|
191
191
|
if (callback) {
|
|
192
|
-
callback = shimmer.wrapFunction(args.callback, cb => function () {
|
|
192
|
+
callback = shimmer.wrapFunction(args.callback, cb => function (...args) {
|
|
193
193
|
return asyncStartChannel.runStores(ctx, () => {
|
|
194
|
-
return cb.apply(this,
|
|
194
|
+
return cb.apply(this, args)
|
|
195
195
|
})
|
|
196
196
|
})
|
|
197
197
|
}
|
|
@@ -214,9 +214,9 @@ function patch (http, methodName) {
|
|
|
214
214
|
|
|
215
215
|
// tracked to accurately discern custom request socket timeout
|
|
216
216
|
let customRequestTimeout = false
|
|
217
|
-
req.setTimeout = function () {
|
|
217
|
+
req.setTimeout = function (...args) {
|
|
218
218
|
customRequestTimeout = true
|
|
219
|
-
return setTimeout.apply(this,
|
|
219
|
+
return setTimeout.apply(this, args)
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
req.emit = function (eventName, arg) {
|
|
@@ -126,9 +126,9 @@ function wrapWriteHead (writeHead) {
|
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
function wrapWrite (write) {
|
|
129
|
-
return function wrappedWrite () {
|
|
129
|
+
return function wrappedWrite (...args) {
|
|
130
130
|
if (!startWriteHeadCh.hasSubscribers) {
|
|
131
|
-
return write.apply(this,
|
|
131
|
+
return write.apply(this, args)
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
const abortController = new AbortController()
|
|
@@ -147,7 +147,7 @@ function wrapWrite (write) {
|
|
|
147
147
|
return true
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
return write.apply(this,
|
|
150
|
+
return write.apply(this, args)
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
|
|
@@ -177,9 +177,9 @@ function wrapSetHeader (setHeader) {
|
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
function wrapAppendOrRemoveHeader (originalMethod) {
|
|
180
|
-
return function wrappedAppendOrRemoveHeader () {
|
|
180
|
+
return function wrappedAppendOrRemoveHeader (...args) {
|
|
181
181
|
if (!startSetHeaderCh.hasSubscribers) {
|
|
182
|
-
return originalMethod.apply(this,
|
|
182
|
+
return originalMethod.apply(this, args)
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
const abortController = new AbortController()
|
|
@@ -189,14 +189,14 @@ function wrapAppendOrRemoveHeader (originalMethod) {
|
|
|
189
189
|
return this
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
-
return originalMethod.apply(this,
|
|
192
|
+
return originalMethod.apply(this, args)
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
function wrapEnd (end) {
|
|
197
|
-
return function wrappedEnd () {
|
|
197
|
+
return function wrappedEnd (...args) {
|
|
198
198
|
if (!startWriteHeadCh.hasSubscribers) {
|
|
199
|
-
return end.apply(this,
|
|
199
|
+
return end.apply(this, args)
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
const abortController = new AbortController()
|
|
@@ -215,6 +215,6 @@ function wrapEnd (end) {
|
|
|
215
215
|
return this
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
-
return end.apply(this,
|
|
218
|
+
return end.apply(this, args)
|
|
219
219
|
}
|
|
220
220
|
}
|