dd-trace 5.100.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/index.d.ts +14 -0
- package/package.json +11 -9
- 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/cypress.js +5 -3
- 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 +26 -9
- package/packages/datadog-instrumentations/src/http/server.js +9 -9
- package/packages/datadog-instrumentations/src/jest.js +93 -63
- 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 +7 -4
- package/packages/datadog-instrumentations/src/mocha/main.js +37 -14
- package/packages/datadog-instrumentations/src/mocha/utils.js +133 -16
- package/packages/datadog-instrumentations/src/mocha/worker.js +12 -7
- 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/otel-sdk-trace.js +11 -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-bullmq/src/consumer.js +2 -2
- package/packages/datadog-plugin-bullmq/src/producer.js +14 -20
- 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 +18 -4
- package/packages/datadog-plugin-cypress/src/plugin.js +5 -14
- 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-kafkajs/src/consumer.js +2 -9
- package/packages/datadog-plugin-kafkajs/src/producer.js +2 -8
- 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 +7 -2
- 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/ci-visibility/lage.js +2 -1
- package/packages/dd-trace/src/ci-visibility/requests/request.js +11 -33
- package/packages/dd-trace/src/config/config-types.d.ts +0 -2
- package/packages/dd-trace/src/config/git_properties.js +2 -2
- package/packages/dd-trace/src/config/index.js +1 -55
- package/packages/dd-trace/src/datastreams/checkpointer.js +4 -10
- package/packages/dd-trace/src/datastreams/encoding.js +39 -28
- package/packages/dd-trace/src/datastreams/index.js +2 -1
- package/packages/dd-trace/src/datastreams/pathway.js +29 -26
- package/packages/dd-trace/src/datastreams/processor.js +18 -17
- package/packages/dd-trace/src/datastreams/size.js +6 -2
- package/packages/dd-trace/src/debugger/config.js +5 -2
- package/packages/dd-trace/src/debugger/devtools_client/index.js +2 -5
- package/packages/dd-trace/src/debugger/devtools_client/send.js +2 -1
- package/packages/dd-trace/src/debugger/devtools_client/snapshot-pruner.js +1 -0
- package/packages/dd-trace/src/dogstatsd.js +10 -7
- package/packages/dd-trace/src/encode/0.4.js +759 -234
- package/packages/dd-trace/src/encode/0.5.js +15 -9
- package/packages/dd-trace/src/encode/agentless-json.js +2 -2
- package/packages/dd-trace/src/encode/tags-processors.js +2 -27
- package/packages/dd-trace/src/exporters/common/request.js +22 -11
- package/packages/dd-trace/src/exporters/common/retry.js +104 -0
- package/packages/dd-trace/src/git_metadata.js +66 -0
- package/packages/dd-trace/src/git_metadata_tagger.js +13 -5
- package/packages/dd-trace/src/id.js +15 -26
- package/packages/dd-trace/src/llmobs/constants/tags.js +2 -0
- package/packages/dd-trace/src/llmobs/plugins/ai/util.js +1 -2
- package/packages/dd-trace/src/llmobs/plugins/anthropic/index.js +27 -16
- package/packages/dd-trace/src/llmobs/plugins/anthropic/util.js +3 -0
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +33 -13
- package/packages/dd-trace/src/llmobs/plugins/openai/index.js +20 -50
- package/packages/dd-trace/src/llmobs/sdk.js +29 -27
- package/packages/dd-trace/src/llmobs/span_processor.js +52 -6
- package/packages/dd-trace/src/llmobs/tagger.js +42 -0
- package/packages/dd-trace/src/llmobs/telemetry.js +29 -0
- package/packages/dd-trace/src/llmobs/util.js +81 -5
- 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/active-span-proxy.js +42 -0
- package/packages/dd-trace/src/opentelemetry/bridge-span-base.js +106 -0
- package/packages/dd-trace/src/opentelemetry/context_manager.js +11 -2
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_transformer_base.js +1 -2
- package/packages/dd-trace/src/opentelemetry/span-helpers.js +188 -50
- package/packages/dd-trace/src/opentelemetry/span.js +42 -80
- package/packages/dd-trace/src/opentelemetry/tracer.js +0 -22
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +65 -27
- package/packages/dd-trace/src/opentracing/propagation/text_map_dsm.js +2 -11
- package/packages/dd-trace/src/opentracing/propagation/tracestate.js +58 -22
- package/packages/dd-trace/src/opentracing/span.js +56 -48
- package/packages/dd-trace/src/opentracing/span_context.js +1 -0
- 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/priority_sampler.js +6 -4
- package/packages/dd-trace/src/profiling/config.js +5 -4
- 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/remote_config/index.js +5 -3
- 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/span_format.js +52 -5
- package/packages/dd-trace/src/span_processor.js +0 -4
- package/packages/dd-trace/src/spanleak.js +0 -1
- package/packages/dd-trace/src/tracer.js +7 -7
- package/packages/dd-trace/src/util.js +17 -0
|
@@ -38,14 +38,14 @@ function entityWrapper (method) {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
function entityHandler (handler, entityName) {
|
|
41
|
-
return function () {
|
|
42
|
-
if (!azureDurableFunctionsChannel.hasSubscribers) return handler.apply(this,
|
|
41
|
+
return function (...args) {
|
|
42
|
+
if (!azureDurableFunctionsChannel.hasSubscribers) return handler.apply(this, args)
|
|
43
43
|
|
|
44
|
-
const entityContext =
|
|
44
|
+
const entityContext = args[0]
|
|
45
45
|
return azureDurableFunctionsChannel.traceSync(
|
|
46
46
|
handler,
|
|
47
47
|
{ trigger: 'Entity', functionName: entityName, operationName: entityContext?.df?.operationName },
|
|
48
|
-
this, ...
|
|
48
|
+
this, ...args)
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -55,19 +55,19 @@ function activityHandler (method) {
|
|
|
55
55
|
const isAsync =
|
|
56
56
|
handler && handler.constructor && handler.constructor.name === 'AsyncFunction'
|
|
57
57
|
|
|
58
|
-
return function () {
|
|
59
|
-
if (!azureDurableFunctionsChannel.hasSubscribers) return handler.apply(this,
|
|
58
|
+
return function (...args) {
|
|
59
|
+
if (!azureDurableFunctionsChannel.hasSubscribers) return handler.apply(this, args)
|
|
60
60
|
|
|
61
61
|
// use tracePromise if this is an async handler. otherwise, use traceSync
|
|
62
62
|
return isAsync
|
|
63
63
|
? azureDurableFunctionsChannel.tracePromise(
|
|
64
64
|
handler,
|
|
65
65
|
{ trigger: 'Activity', functionName: activityName },
|
|
66
|
-
this, ...
|
|
66
|
+
this, ...args)
|
|
67
67
|
: azureDurableFunctionsChannel.traceSync(
|
|
68
68
|
handler,
|
|
69
69
|
{ trigger: 'Activity', functionName: activityName },
|
|
70
|
-
this, ...
|
|
70
|
+
this, ...args)
|
|
71
71
|
}
|
|
72
72
|
})
|
|
73
73
|
return method.apply(this, arguments)
|
|
@@ -6,8 +6,8 @@ const { wrapThen } = require('./helpers/promise')
|
|
|
6
6
|
|
|
7
7
|
function createGetNewLibraryCopyWrap (originalLib) {
|
|
8
8
|
return function wrapGetNewLibraryCopy (getNewLibraryCopy) {
|
|
9
|
-
return function getNewLibraryCopyWithTrace () {
|
|
10
|
-
const libraryCopy = getNewLibraryCopy.apply(this,
|
|
9
|
+
return function getNewLibraryCopyWithTrace (...args) {
|
|
10
|
+
const libraryCopy = getNewLibraryCopy.apply(this, args)
|
|
11
11
|
shimmer.wrap(libraryCopy.prototype, '_then', wrapThen)
|
|
12
12
|
shimmer.wrap(libraryCopy, 'getNewLibraryCopy', createGetNewLibraryCopyWrap(originalLib))
|
|
13
13
|
return libraryCopy
|
|
@@ -6,7 +6,7 @@ const { channel, addHook, AsyncResource } = require('./helpers/instrument')
|
|
|
6
6
|
const bodyParserReadCh = channel('datadog:body-parser:read:finish')
|
|
7
7
|
|
|
8
8
|
function publishRequestBodyAndNext (req, res, next) {
|
|
9
|
-
return shimmer.wrapFunction(next, next => function () {
|
|
9
|
+
return shimmer.wrapFunction(next, next => function (...args) {
|
|
10
10
|
if (bodyParserReadCh.hasSubscribers && req) {
|
|
11
11
|
const abortController = new AbortController()
|
|
12
12
|
const body = req.body
|
|
@@ -16,7 +16,7 @@ function publishRequestBodyAndNext (req, res, next) {
|
|
|
16
16
|
if (abortController.signal.aborted) return
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
return next.apply(this,
|
|
19
|
+
return next.apply(this, args)
|
|
20
20
|
})
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -100,13 +100,13 @@ addHook({ name: 'cassandra-driver', versions: ['3 - 4.3'], patchDefault: false }
|
|
|
100
100
|
})
|
|
101
101
|
|
|
102
102
|
addHook({ name: 'cassandra-driver', versions: ['>=3.3'], file: 'lib/request-execution.js' }, RequestExecution => {
|
|
103
|
-
shimmer.wrap(RequestExecution.prototype, '_sendOnConnection', _sendOnConnection => function () {
|
|
103
|
+
shimmer.wrap(RequestExecution.prototype, '_sendOnConnection', _sendOnConnection => function (...args) {
|
|
104
104
|
if (!startCh.hasSubscribers) {
|
|
105
|
-
return _sendOnConnection.apply(this,
|
|
105
|
+
return _sendOnConnection.apply(this, args)
|
|
106
106
|
}
|
|
107
107
|
startCtx = { hostname: this._connection.address, port: this._connection.port, ...startCtx }
|
|
108
108
|
connectCh.publish(startCtx)
|
|
109
|
-
return _sendOnConnection.apply(this,
|
|
109
|
+
return _sendOnConnection.apply(this, args)
|
|
110
110
|
})
|
|
111
111
|
return RequestExecution
|
|
112
112
|
})
|
|
@@ -122,9 +122,9 @@ addHook({ name: 'cassandra-driver', versions: ['3.3 - 4.3'], file: 'lib/request-
|
|
|
122
122
|
return start.apply(this, arguments)
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
arguments[0] = function () {
|
|
125
|
+
arguments[0] = function (...args) {
|
|
126
126
|
startCtx = { hostname: execution._connection.address, port: execution._connection.port, ...startCtx }
|
|
127
|
-
return connectCh.runStores(startCtx, getHostCallback, this, ...
|
|
127
|
+
return connectCh.runStores(startCtx, getHostCallback, this, ...args)
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
return start.apply(this, arguments)
|
|
@@ -143,9 +143,9 @@ addHook({ name: 'cassandra-driver', versions: ['3 - 3.2'], file: 'lib/request-ha
|
|
|
143
143
|
return send.apply(this, arguments)
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
arguments[2] = function () {
|
|
146
|
+
arguments[2] = function (...args) {
|
|
147
147
|
startCtx = { hostname: handler.connection.address, port: handler.connection.port, ...startCtx }
|
|
148
|
-
return connectCh.runStores(startCtx, callback, this, ...
|
|
148
|
+
return connectCh.runStores(startCtx, callback, this, ...args)
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
return send.apply(this, arguments)
|
|
@@ -82,12 +82,12 @@ function createContextFromChildProcessInfo (childProcessInfo) {
|
|
|
82
82
|
|
|
83
83
|
function wrapChildProcessSyncMethod (returnError, shell = false) {
|
|
84
84
|
return function wrapMethod (childProcessMethod) {
|
|
85
|
-
return function () {
|
|
86
|
-
if (!childProcessChannel.start.hasSubscribers ||
|
|
87
|
-
return childProcessMethod.apply(this,
|
|
85
|
+
return function (...args) {
|
|
86
|
+
if (!childProcessChannel.start.hasSubscribers || args.length === 0) {
|
|
87
|
+
return childProcessMethod.apply(this, args)
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
const callArgs = [...
|
|
90
|
+
const callArgs = [...args]
|
|
91
91
|
const childProcessInfo = normalizeArgs(callArgs, shell)
|
|
92
92
|
const context = createContextFromChildProcessInfo(childProcessInfo)
|
|
93
93
|
context.callArgs = callArgs
|
|
@@ -118,12 +118,12 @@ function wrapChildProcessSyncMethod (returnError, shell = false) {
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
function wrapChildProcessCustomPromisifyMethod (customPromisifyMethod, shell) {
|
|
121
|
-
return function () {
|
|
122
|
-
if (!childProcessChannel.start.hasSubscribers ||
|
|
123
|
-
return customPromisifyMethod.apply(this,
|
|
121
|
+
return function (...args) {
|
|
122
|
+
if (!childProcessChannel.start.hasSubscribers || args.length === 0) {
|
|
123
|
+
return customPromisifyMethod.apply(this, args)
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
const callArgs = [...
|
|
126
|
+
const callArgs = [...args]
|
|
127
127
|
const childProcessInfo = normalizeArgs(callArgs, shell)
|
|
128
128
|
|
|
129
129
|
const context = createContextFromChildProcessInfo(childProcessInfo)
|
|
@@ -170,12 +170,12 @@ function wrapChildProcessCustomPromisifyMethod (customPromisifyMethod, shell) {
|
|
|
170
170
|
|
|
171
171
|
function wrapChildProcessAsyncMethod (ChildProcess, shell = false) {
|
|
172
172
|
return function wrapMethod (childProcessMethod) {
|
|
173
|
-
function wrappedChildProcessMethod () {
|
|
174
|
-
if (!childProcessChannel.start.hasSubscribers ||
|
|
175
|
-
return childProcessMethod.apply(this,
|
|
173
|
+
function wrappedChildProcessMethod (...args) {
|
|
174
|
+
if (!childProcessChannel.start.hasSubscribers || args.length === 0) {
|
|
175
|
+
return childProcessMethod.apply(this, args)
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
const callArgs = [...
|
|
178
|
+
const callArgs = [...args]
|
|
179
179
|
const childProcessInfo = normalizeArgs(callArgs, shell)
|
|
180
180
|
|
|
181
181
|
const context = createContextFromChildProcessInfo(childProcessInfo)
|
|
@@ -47,8 +47,8 @@ function instrumentBaseModule (module) {
|
|
|
47
47
|
// Helper function to wrap producer classes
|
|
48
48
|
function wrapProducerClass (ProducerClass, className) {
|
|
49
49
|
return shimmer.wrap(module, className, function wrapProducer (Original) {
|
|
50
|
-
return function wrappedProducer () {
|
|
51
|
-
const producer = new Original(...
|
|
50
|
+
return function wrappedProducer (...args) {
|
|
51
|
+
const producer = new Original(...args)
|
|
52
52
|
|
|
53
53
|
// Hook the produce method
|
|
54
54
|
if (typeof producer?.produce === 'function') {
|
|
@@ -94,9 +94,9 @@ function instrumentBaseModule (module) {
|
|
|
94
94
|
// Helper function to wrap consumer classes
|
|
95
95
|
function wrapConsumerClass (ConsumerClass, className) {
|
|
96
96
|
return shimmer.wrap(module, className, function wrapConsumer (Original) {
|
|
97
|
-
return function wrappedConsumer () {
|
|
98
|
-
const consumer = new Original(...
|
|
99
|
-
const groupId = this.groupId || (
|
|
97
|
+
return function wrappedConsumer (...args) {
|
|
98
|
+
const consumer = new Original(...args)
|
|
99
|
+
const groupId = this.groupId || (args[0]?.['group.id'])
|
|
100
100
|
|
|
101
101
|
// Wrap the consume method
|
|
102
102
|
if (typeof consumer?.consume === 'function') {
|
|
@@ -196,11 +196,11 @@ function instrumentKafkaJS (kafkaJS) {
|
|
|
196
196
|
// Wrap the producer method if it exists
|
|
197
197
|
if (typeof kafka?.producer === 'function') {
|
|
198
198
|
shimmer.wrap(kafka, 'producer', function wrapProducerMethod (producerMethod) {
|
|
199
|
-
return function wrappedProducerMethod () {
|
|
200
|
-
const producer = producerMethod.apply(this,
|
|
199
|
+
return function wrappedProducerMethod (...args) {
|
|
200
|
+
const producer = producerMethod.apply(this, args)
|
|
201
201
|
|
|
202
|
-
if (!brokers &&
|
|
203
|
-
kafka._ddBrokers =
|
|
202
|
+
if (!brokers && args?.[0]?.['bootstrap.servers']) {
|
|
203
|
+
kafka._ddBrokers = args[0]['bootstrap.servers']
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
// Wrap the send method of the producer
|
|
@@ -59,16 +59,16 @@ function wrapLayerHandle (layer) {
|
|
|
59
59
|
|
|
60
60
|
const original = layer.handle
|
|
61
61
|
|
|
62
|
-
return shimmer.wrapFunction(original, original => function () {
|
|
63
|
-
if (!enterChannel.hasSubscribers) return original.apply(this,
|
|
62
|
+
return shimmer.wrapFunction(original, original => function (...args) {
|
|
63
|
+
if (!enterChannel.hasSubscribers) return original.apply(this, args)
|
|
64
64
|
|
|
65
|
-
const lastIndex =
|
|
65
|
+
const lastIndex = args.length - 1
|
|
66
66
|
const name = original._name || original.name
|
|
67
|
-
const req =
|
|
68
|
-
const next =
|
|
67
|
+
const req = args[args.length > 3 ? 1 : 0]
|
|
68
|
+
const next = args[lastIndex]
|
|
69
69
|
|
|
70
70
|
if (typeof next === 'function') {
|
|
71
|
-
|
|
71
|
+
args[lastIndex] = wrapNext(req, next)
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
const route = layer.route
|
|
@@ -76,7 +76,7 @@ function wrapLayerHandle (layer) {
|
|
|
76
76
|
enterChannel.publish({ name, req, route })
|
|
77
77
|
|
|
78
78
|
try {
|
|
79
|
-
return original.apply(this,
|
|
79
|
+
return original.apply(this, args)
|
|
80
80
|
} catch (error) {
|
|
81
81
|
errorChannel.publish({ req, error })
|
|
82
82
|
nextChannel.publish({ req })
|
|
@@ -6,7 +6,7 @@ const { channel, addHook } = require('./helpers/instrument')
|
|
|
6
6
|
const cookieParserReadCh = channel('datadog:cookie-parser:read:finish')
|
|
7
7
|
|
|
8
8
|
function publishRequestCookieAndNext (req, res, next) {
|
|
9
|
-
return shimmer.wrapFunction(next, next => function cookieParserWrapper () {
|
|
9
|
+
return shimmer.wrapFunction(next, next => function cookieParserWrapper (...args) {
|
|
10
10
|
if (cookieParserReadCh.hasSubscribers && req) {
|
|
11
11
|
const abortController = new AbortController()
|
|
12
12
|
|
|
@@ -17,7 +17,7 @@ function publishRequestCookieAndNext (req, res, next) {
|
|
|
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
|
|
|
@@ -25,8 +25,8 @@ addHook({
|
|
|
25
25
|
name: 'cookie-parser',
|
|
26
26
|
versions: ['>=1.0.0'],
|
|
27
27
|
}, cookieParser => {
|
|
28
|
-
return shimmer.wrapFunction(cookieParser, cookieParser => function () {
|
|
29
|
-
const cookieMiddleware = cookieParser.apply(this,
|
|
28
|
+
return shimmer.wrapFunction(cookieParser, cookieParser => function (...args) {
|
|
29
|
+
const cookieMiddleware = cookieParser.apply(this, args)
|
|
30
30
|
|
|
31
31
|
return shimmer.wrapFunction(cookieMiddleware, cookieMiddleware => function (req, res, next) {
|
|
32
32
|
arguments[2] = publishRequestCookieAndNext(req, res, next)
|
|
@@ -6,8 +6,8 @@ const { channel, addHook } = require('./helpers/instrument')
|
|
|
6
6
|
const cookieParseCh = channel('datadog:cookie:parse:finish')
|
|
7
7
|
|
|
8
8
|
function wrapParse (originalParse) {
|
|
9
|
-
return function () {
|
|
10
|
-
const cookies = originalParse.apply(this,
|
|
9
|
+
return function (...args) {
|
|
10
|
+
const cookies = originalParse.apply(this, args)
|
|
11
11
|
if (cookieParseCh.hasSubscribers && cookies) {
|
|
12
12
|
cookieParseCh.publish({ cookies })
|
|
13
13
|
}
|
|
@@ -77,25 +77,25 @@ function wrap (prefix, fn) {
|
|
|
77
77
|
const finishCh = channel(prefix + ':finish')
|
|
78
78
|
const errorCh = channel(prefix + ':error')
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
return function (...args) {
|
|
81
81
|
if (!startCh.hasSubscribers) {
|
|
82
|
-
return fn.apply(this,
|
|
82
|
+
return fn.apply(this, args)
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
const callbackIndex = findCallbackIndex(
|
|
85
|
+
const callbackIndex = findCallbackIndex(args, 1)
|
|
86
86
|
|
|
87
|
-
if (callbackIndex < 0) return fn.apply(this,
|
|
87
|
+
if (callbackIndex < 0) return fn.apply(this, args)
|
|
88
88
|
|
|
89
89
|
const ctx = { bucket: { name: this.name || this._name }, seedNodes: this._dd_hosts }
|
|
90
90
|
return startCh.runStores(ctx, () => {
|
|
91
|
-
const cb =
|
|
91
|
+
const cb = args[callbackIndex]
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
return wrapCallbackFinish(cb, this,
|
|
93
|
+
args[callbackIndex] = shimmer.wrapFunction(cb, (cb) => {
|
|
94
|
+
return wrapCallbackFinish(cb, this, args, errorCh, finishCh, ctx, prefix)
|
|
95
95
|
})
|
|
96
96
|
|
|
97
97
|
try {
|
|
98
|
-
return fn.apply(this,
|
|
98
|
+
return fn.apply(this, args)
|
|
99
99
|
} catch (error) {
|
|
100
100
|
ctx.error = error
|
|
101
101
|
void error.stack // trigger getting the stack at the original throwing point
|
|
@@ -105,7 +105,6 @@ function wrap (prefix, fn) {
|
|
|
105
105
|
}
|
|
106
106
|
})
|
|
107
107
|
}
|
|
108
|
-
return wrapped
|
|
109
108
|
}
|
|
110
109
|
|
|
111
110
|
// semver >=2 <3
|
|
@@ -174,12 +173,12 @@ function wrapCBandPromise (fn, name, startData, thisArg, args) {
|
|
|
174
173
|
|
|
175
174
|
function wrapWithName (name) {
|
|
176
175
|
return function (operation) {
|
|
177
|
-
return function () { // no arguments used by us
|
|
176
|
+
return function (...args) { // no arguments used by us
|
|
178
177
|
return wrapCBandPromise(operation, name, {
|
|
179
178
|
collection: { name: this._name || '_default' },
|
|
180
179
|
bucket: { name: this._scope._bucket._name },
|
|
181
180
|
seedNodes: this._dd_connStr,
|
|
182
|
-
}, this,
|
|
181
|
+
}, this, args)
|
|
183
182
|
}
|
|
184
183
|
}
|
|
185
184
|
}
|
|
@@ -240,8 +239,6 @@ addHook({ name: 'couchbase', file: 'lib/bucket.js', versions: ['^2.6.12'] }, Buc
|
|
|
240
239
|
wrapAllNames(['upsert', 'insert', 'replace', 'append', 'prepend'], name => {
|
|
241
240
|
shimmer.wrap(Bucket.prototype, name, fn => wrap(`apm:couchbase:${name}`, fn))
|
|
242
241
|
})
|
|
243
|
-
|
|
244
|
-
return Bucket
|
|
245
242
|
})
|
|
246
243
|
|
|
247
244
|
addHook({ name: 'couchbase', file: 'lib/cluster.js', versions: ['^2.6.12'] }, Cluster => {
|
|
@@ -251,42 +248,36 @@ addHook({ name: 'couchbase', file: 'lib/cluster.js', versions: ['^2.6.12'] }, Cl
|
|
|
251
248
|
|
|
252
249
|
shimmer.wrap(Cluster.prototype, 'query', query => wrapQuery(query))
|
|
253
250
|
shimmer.wrap(Cluster.prototype, 'openBucket', openBucket => {
|
|
254
|
-
return function () {
|
|
255
|
-
const bucket = openBucket.apply(this,
|
|
251
|
+
return function (...args) {
|
|
252
|
+
const bucket = openBucket.apply(this, args)
|
|
256
253
|
const hosts = this.dsnObj.hosts
|
|
257
254
|
bucket._dd_hosts = hosts.map(hostAndPort => hostAndPort.join(':')).join(',')
|
|
258
255
|
return bucket
|
|
259
256
|
}
|
|
260
257
|
})
|
|
261
|
-
return Cluster
|
|
262
258
|
})
|
|
263
259
|
|
|
264
260
|
// semver >=3 <3.2.0
|
|
265
261
|
|
|
266
262
|
addHook({ name: 'couchbase', file: 'lib/bucket.js', versions: ['^3.0.7', '^3.1.3'] }, Bucket => {
|
|
267
263
|
shimmer.wrap(Bucket.prototype, 'collection', getCollection => {
|
|
268
|
-
return function () {
|
|
269
|
-
const collection = getCollection.apply(this,
|
|
264
|
+
return function (...args) {
|
|
265
|
+
const collection = getCollection.apply(this, args)
|
|
270
266
|
const connStr = this._cluster._connStr
|
|
271
267
|
collection._dd_connStr = connStr
|
|
272
268
|
return collection
|
|
273
269
|
}
|
|
274
270
|
})
|
|
275
|
-
|
|
276
|
-
return Bucket
|
|
277
271
|
})
|
|
278
272
|
|
|
279
273
|
addHook({ name: 'couchbase', file: 'lib/collection.js', versions: ['^3.0.7', '^3.1.3'] }, Collection => {
|
|
280
274
|
wrapAllNames(['upsert', 'insert', 'replace'], name => {
|
|
281
275
|
shimmer.wrap(Collection.prototype, name, wrapWithName(name))
|
|
282
276
|
})
|
|
283
|
-
|
|
284
|
-
return Collection
|
|
285
277
|
})
|
|
286
278
|
|
|
287
279
|
addHook({ name: 'couchbase', file: 'lib/cluster.js', versions: ['^3.0.7', '^3.1.3'] }, Cluster => {
|
|
288
280
|
shimmer.wrap(Cluster.prototype, 'query', wrapV3Query)
|
|
289
|
-
return Cluster
|
|
290
281
|
})
|
|
291
282
|
|
|
292
283
|
// semver >=3.2.2
|
|
@@ -298,27 +289,22 @@ addHook({ name: 'couchbase', file: 'dist/collection.js', versions: ['>=3.2.2'] }
|
|
|
298
289
|
wrapAllNames(['upsert', 'insert', 'replace'], name => {
|
|
299
290
|
shimmer.wrap(Collection.prototype, name, wrapWithName(name))
|
|
300
291
|
})
|
|
301
|
-
|
|
302
|
-
return collection
|
|
303
292
|
})
|
|
304
293
|
|
|
305
294
|
addHook({ name: 'couchbase', file: 'dist/bucket.js', versions: ['>=3.2.2'] }, bucket => {
|
|
306
295
|
const Bucket = bucket.Bucket
|
|
307
296
|
shimmer.wrap(Bucket.prototype, 'collection', getCollection => {
|
|
308
|
-
return function () {
|
|
309
|
-
const collection = getCollection.apply(this,
|
|
297
|
+
return function (...args) {
|
|
298
|
+
const collection = getCollection.apply(this, args)
|
|
310
299
|
const connStr = this._cluster._connStr
|
|
311
300
|
collection._dd_connStr = connStr
|
|
312
301
|
return collection
|
|
313
302
|
}
|
|
314
303
|
})
|
|
315
|
-
|
|
316
|
-
return bucket
|
|
317
304
|
})
|
|
318
305
|
|
|
319
306
|
addHook({ name: 'couchbase', file: 'dist/cluster.js', versions: ['>=3.2.2'] }, (cluster) => {
|
|
320
307
|
const Cluster = cluster.Cluster
|
|
321
308
|
|
|
322
309
|
shimmer.wrap(Cluster.prototype, 'query', wrapV3Query)
|
|
323
|
-
return cluster
|
|
324
310
|
})
|
|
@@ -47,12 +47,12 @@ addHook({ name: 'crypto' }, crypto => {
|
|
|
47
47
|
|
|
48
48
|
function wrapCryptoMethod (channel) {
|
|
49
49
|
function wrapMethod (cryptoMethod) {
|
|
50
|
-
return function () {
|
|
51
|
-
if (channel.hasSubscribers &&
|
|
52
|
-
const algorithm =
|
|
50
|
+
return function (...args) {
|
|
51
|
+
if (channel.hasSubscribers && args.length > 0) {
|
|
52
|
+
const algorithm = args[0]
|
|
53
53
|
channel.publish({ algorithm })
|
|
54
54
|
}
|
|
55
|
-
return cryptoMethod.apply(this,
|
|
55
|
+
return cryptoMethod.apply(this, args)
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
return wrapMethod
|