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
|
@@ -26,13 +26,13 @@ const {
|
|
|
26
26
|
recordAttemptToFixExecution,
|
|
27
27
|
logAttemptToFixTestExecution,
|
|
28
28
|
logTestOptimizationSummary,
|
|
29
|
+
getEfdRetryCount,
|
|
29
30
|
} = require('../../dd-trace/src/plugins/util/test')
|
|
30
31
|
const {
|
|
31
32
|
SEED_SUFFIX_RE,
|
|
32
33
|
getFormattedJestTestParameters,
|
|
33
34
|
getJestTestName,
|
|
34
35
|
getJestSuitesToRun,
|
|
35
|
-
getEfdRetryCount,
|
|
36
36
|
} = require('../../datadog-plugin-jest/src/util')
|
|
37
37
|
const { addHook, channel } = require('./helpers/instrument')
|
|
38
38
|
|
|
@@ -521,13 +521,13 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
|
|
|
521
521
|
const setNameToParams = (name, params) => { this.nameToParams[name] = [...params] }
|
|
522
522
|
|
|
523
523
|
if (event.name === 'setup' && this.global.test) {
|
|
524
|
-
shimmer.wrap(this.global.test, 'each', each => function () {
|
|
525
|
-
const testParameters = getFormattedJestTestParameters(
|
|
526
|
-
const eachBind = each.apply(this,
|
|
527
|
-
return function () {
|
|
528
|
-
const [testName] =
|
|
524
|
+
shimmer.wrap(this.global.test, 'each', each => function (...args) {
|
|
525
|
+
const testParameters = getFormattedJestTestParameters(args)
|
|
526
|
+
const eachBind = each.apply(this, args)
|
|
527
|
+
return function (...args) {
|
|
528
|
+
const [testName] = args
|
|
529
529
|
setNameToParams(testName, testParameters)
|
|
530
|
-
return eachBind.apply(this,
|
|
530
|
+
return eachBind.apply(this, args)
|
|
531
531
|
}
|
|
532
532
|
})
|
|
533
533
|
}
|
|
@@ -624,16 +624,16 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
|
|
|
624
624
|
} else {
|
|
625
625
|
originalHookFns.set(hook, hookFn)
|
|
626
626
|
}
|
|
627
|
-
const newHookFn = shimmer.wrapFunction(hookFn, hookFn => function () {
|
|
628
|
-
return testFnCh.runStores(ctx, () => hookFn.apply(this,
|
|
627
|
+
const newHookFn = shimmer.wrapFunction(hookFn, hookFn => function (...args) {
|
|
628
|
+
return testFnCh.runStores(ctx, () => hookFn.apply(this, args))
|
|
629
629
|
})
|
|
630
630
|
hook.fn = newHookFn
|
|
631
631
|
}
|
|
632
632
|
const originalFn = event.test.fn
|
|
633
633
|
originalTestFns.set(event.test, originalFn)
|
|
634
634
|
|
|
635
|
-
const newFn = shimmer.wrapFunction(event.test.fn, testFn => function () {
|
|
636
|
-
return testFnCh.runStores(ctx, () => testFn.apply(this,
|
|
635
|
+
const newFn = shimmer.wrapFunction(event.test.fn, testFn => function (...args) {
|
|
636
|
+
return testFnCh.runStores(ctx, () => testFn.apply(this, args))
|
|
637
637
|
})
|
|
638
638
|
|
|
639
639
|
event.test.fn = newFn
|
|
@@ -648,8 +648,8 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
|
|
|
648
648
|
} else {
|
|
649
649
|
originalHookFns.set(event.hook, hookFn)
|
|
650
650
|
}
|
|
651
|
-
event.hook.fn = shimmer.wrapFunction(hookFn, hookFn => function () {
|
|
652
|
-
return testSuiteHookFnCh.runStores(ctx, () => hookFn.apply(this,
|
|
651
|
+
event.hook.fn = shimmer.wrapFunction(hookFn, hookFn => function (...args) {
|
|
652
|
+
return testSuiteHookFnCh.runStores(ctx, () => hookFn.apply(this, args))
|
|
653
653
|
})
|
|
654
654
|
}
|
|
655
655
|
|
|
@@ -1544,14 +1544,14 @@ function coverageReporterWrapper (coverageReporter) {
|
|
|
1544
1544
|
* in which case we'll leave it.
|
|
1545
1545
|
*/
|
|
1546
1546
|
// `_addUntestedFiles` is an async function
|
|
1547
|
-
shimmer.wrap(CoverageReporter.prototype, '_addUntestedFiles', addUntestedFiles => function () {
|
|
1547
|
+
shimmer.wrap(CoverageReporter.prototype, '_addUntestedFiles', addUntestedFiles => function (...args) {
|
|
1548
1548
|
if (DD_TEST_TIA_KEEP_COV_CONFIG) {
|
|
1549
|
-
return addUntestedFiles.apply(this,
|
|
1549
|
+
return addUntestedFiles.apply(this, args)
|
|
1550
1550
|
}
|
|
1551
1551
|
if (isCodeCoverageEnabledBecauseOfUs) {
|
|
1552
1552
|
return Promise.resolve()
|
|
1553
1553
|
}
|
|
1554
|
-
return addUntestedFiles.apply(this,
|
|
1554
|
+
return addUntestedFiles.apply(this, args)
|
|
1555
1555
|
})
|
|
1556
1556
|
|
|
1557
1557
|
return coverageReporter
|
|
@@ -1594,8 +1594,8 @@ addHook({
|
|
|
1594
1594
|
name: '@jest/test-sequencer',
|
|
1595
1595
|
versions: ['>=28'],
|
|
1596
1596
|
}, (sequencerPackage, frameworkVersion) => {
|
|
1597
|
-
shimmer.wrap(sequencerPackage.default.prototype, 'shard', shard => function () {
|
|
1598
|
-
const shardedTests = shard.apply(this,
|
|
1597
|
+
shimmer.wrap(sequencerPackage.default.prototype, 'shard', shard => function (...args) {
|
|
1598
|
+
const shardedTests = shard.apply(this, args)
|
|
1599
1599
|
|
|
1600
1600
|
if (!shardedTests.length || !isSuitesSkippingEnabled || !skippableSuites.length) {
|
|
1601
1601
|
return shardedTests
|
|
@@ -1642,10 +1642,10 @@ addHook({
|
|
|
1642
1642
|
|
|
1643
1643
|
function jestAdapterWrapper (jestAdapter, jestVersion) {
|
|
1644
1644
|
const adapter = jestAdapter.default ?? jestAdapter
|
|
1645
|
-
const newAdapter = shimmer.wrapFunction(adapter, adapter => function () {
|
|
1646
|
-
const environment =
|
|
1645
|
+
const newAdapter = shimmer.wrapFunction(adapter, adapter => function (...args) {
|
|
1646
|
+
const environment = args[2]
|
|
1647
1647
|
if (!environment || !environment.testEnvironmentOptions) {
|
|
1648
|
-
return adapter.apply(this,
|
|
1648
|
+
return adapter.apply(this, args)
|
|
1649
1649
|
}
|
|
1650
1650
|
testSuiteStartCh.publish({
|
|
1651
1651
|
testSuite: environment.testSuite,
|
|
@@ -1655,7 +1655,7 @@ function jestAdapterWrapper (jestAdapter, jestVersion) {
|
|
|
1655
1655
|
frameworkVersion: jestVersion,
|
|
1656
1656
|
testSuiteAbsolutePath: environment.testSuiteAbsolutePath,
|
|
1657
1657
|
})
|
|
1658
|
-
return adapter.apply(this,
|
|
1658
|
+
return adapter.apply(this, args).then(suiteResults => {
|
|
1659
1659
|
const { numFailingTests, skipped, failureMessage: errorMessage } = suiteResults
|
|
1660
1660
|
let status = 'pass'
|
|
1661
1661
|
if (skipped) {
|
|
@@ -1773,8 +1773,8 @@ function jestConfigAsyncWrapper (jestConfig) {
|
|
|
1773
1773
|
}
|
|
1774
1774
|
|
|
1775
1775
|
function jestConfigSyncWrapper (jestConfig) {
|
|
1776
|
-
return shimmer.wrap(jestConfig, 'readConfigs', readConfigs => function () {
|
|
1777
|
-
const readConfigsResult = readConfigs.apply(this,
|
|
1776
|
+
return shimmer.wrap(jestConfig, 'readConfigs', readConfigs => function (...args) {
|
|
1777
|
+
const readConfigsResult = readConfigs.apply(this, args)
|
|
1778
1778
|
configureTestEnvironment(readConfigsResult)
|
|
1779
1779
|
return readConfigsResult
|
|
1780
1780
|
})
|
|
@@ -1983,10 +1983,10 @@ addHook({
|
|
|
1983
1983
|
})
|
|
1984
1984
|
|
|
1985
1985
|
function onMessageWrapper (onMessage) {
|
|
1986
|
-
return function () {
|
|
1987
|
-
const response =
|
|
1986
|
+
return function (...args) {
|
|
1987
|
+
const response = args[0]
|
|
1988
1988
|
if (!Array.isArray(response)) {
|
|
1989
|
-
return onMessage.apply(this,
|
|
1989
|
+
return onMessage.apply(this, args)
|
|
1990
1990
|
}
|
|
1991
1991
|
|
|
1992
1992
|
const [code, data] = response
|
|
@@ -2013,7 +2013,7 @@ function onMessageWrapper (onMessage) {
|
|
|
2013
2013
|
}
|
|
2014
2014
|
return
|
|
2015
2015
|
}
|
|
2016
|
-
return onMessage.apply(this,
|
|
2016
|
+
return onMessage.apply(this, args)
|
|
2017
2017
|
}
|
|
2018
2018
|
}
|
|
2019
2019
|
|
|
@@ -2077,8 +2077,8 @@ function wrapWorker (worker) {
|
|
|
2077
2077
|
}
|
|
2078
2078
|
|
|
2079
2079
|
function enqueueWrapper (enqueue) {
|
|
2080
|
-
return function () {
|
|
2081
|
-
shimmer.wrap(
|
|
2080
|
+
return function (...args) {
|
|
2081
|
+
shimmer.wrap(args[0], 'onStart', onStart => function (worker) {
|
|
2082
2082
|
if (worker) {
|
|
2083
2083
|
const currentChannel = worker._child || worker._worker
|
|
2084
2084
|
const previousChannel = wrappedWorkerChannels.get(worker)
|
|
@@ -2095,7 +2095,7 @@ function enqueueWrapper (enqueue) {
|
|
|
2095
2095
|
}
|
|
2096
2096
|
return onStart.apply(this, arguments)
|
|
2097
2097
|
})
|
|
2098
|
-
return enqueue.apply(this,
|
|
2098
|
+
return enqueue.apply(this, args)
|
|
2099
2099
|
}
|
|
2100
2100
|
}
|
|
2101
2101
|
|
|
@@ -34,16 +34,16 @@ addHook({ name: 'kafkajs', file: 'src/index.js', versions: ['>=1.4'] }, (BaseKaf
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
shimmer.wrap(Kafka.prototype, 'producer', createProducer => function () {
|
|
38
|
-
const producer = createProducer.apply(this,
|
|
37
|
+
shimmer.wrap(Kafka.prototype, 'producer', createProducer => function (...args) {
|
|
38
|
+
const producer = createProducer.apply(this, args)
|
|
39
39
|
const send = producer.send
|
|
40
40
|
const bootstrapServers = this._brokers
|
|
41
41
|
|
|
42
42
|
const kafkaClusterIdPromise = getKafkaClusterId(this)
|
|
43
43
|
|
|
44
|
-
producer.send = function () {
|
|
44
|
+
producer.send = function (...args) {
|
|
45
45
|
const wrappedSend = (clusterId) => {
|
|
46
|
-
const { topic, messages = [] } =
|
|
46
|
+
const { topic, messages = [] } = args[0]
|
|
47
47
|
|
|
48
48
|
const ctx = {
|
|
49
49
|
bootstrapServers,
|
|
@@ -61,7 +61,7 @@ addHook({ name: 'kafkajs', file: 'src/index.js', versions: ['>=1.4'] }, (BaseKaf
|
|
|
61
61
|
|
|
62
62
|
return producerStartCh.runStores(ctx, () => {
|
|
63
63
|
try {
|
|
64
|
-
const result = send.apply(this,
|
|
64
|
+
const result = send.apply(this, args)
|
|
65
65
|
result.then(
|
|
66
66
|
(res) => {
|
|
67
67
|
ctx.result = res
|
|
@@ -110,9 +110,9 @@ addHook({ name: 'kafkajs', file: 'src/index.js', versions: ['>=1.4'] }, (BaseKaf
|
|
|
110
110
|
return producer
|
|
111
111
|
})
|
|
112
112
|
|
|
113
|
-
shimmer.wrap(Kafka.prototype, 'consumer', createConsumer => function () {
|
|
113
|
+
shimmer.wrap(Kafka.prototype, 'consumer', createConsumer => function (...args) {
|
|
114
114
|
if (!consumerStartCh.hasSubscribers) {
|
|
115
|
-
return createConsumer.apply(this,
|
|
115
|
+
return createConsumer.apply(this, args)
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
const kafkaClusterIdPromise = getKafkaClusterId(this)
|
|
@@ -129,7 +129,7 @@ addHook({ name: 'kafkajs', file: 'src/index.js', versions: ['>=1.4'] }, (BaseKaf
|
|
|
129
129
|
return { topic, partition, messages, groupId, clusterId }
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
const consumer = createConsumer.apply(this,
|
|
132
|
+
const consumer = createConsumer.apply(this, args)
|
|
133
133
|
|
|
134
134
|
consumer.on(consumer.events.COMMIT_OFFSETS, (event) => {
|
|
135
135
|
const { payload: { groupId: commitGroupId, topics } } = event
|
|
@@ -149,7 +149,7 @@ addHook({ name: 'kafkajs', file: 'src/index.js', versions: ['>=1.4'] }, (BaseKaf
|
|
|
149
149
|
})
|
|
150
150
|
|
|
151
151
|
const run = consumer.run
|
|
152
|
-
const groupId =
|
|
152
|
+
const groupId = args[0].groupId
|
|
153
153
|
|
|
154
154
|
consumer.run = function ({ eachMessage, eachBatch, ...runArgs }) {
|
|
155
155
|
const wrapConsume = (clusterId) => {
|
|
@@ -32,41 +32,41 @@ addHook({
|
|
|
32
32
|
versions: ['>=2'],
|
|
33
33
|
file: 'lib/knex-builder/Knex.js',
|
|
34
34
|
}, Knex => {
|
|
35
|
-
shimmer.wrap(Knex.Client.prototype, 'raw', raw => function () {
|
|
35
|
+
shimmer.wrap(Knex.Client.prototype, 'raw', raw => function (...args) {
|
|
36
36
|
if (!startRawQueryCh.hasSubscribers) {
|
|
37
|
-
return raw.apply(this,
|
|
37
|
+
return raw.apply(this, args)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
const sql =
|
|
40
|
+
const sql = args[0]
|
|
41
41
|
|
|
42
42
|
// Skip query done by Knex to get the value used for undefined
|
|
43
43
|
if (sql === 'DEFAULT') {
|
|
44
|
-
return raw.apply(this,
|
|
44
|
+
return raw.apply(this, args)
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
const context = { sql, dialect: this.dialect }
|
|
48
48
|
return startRawQueryCh.runStores(context, () => {
|
|
49
|
-
const rawResult = raw.apply(this,
|
|
50
|
-
shimmer.wrap(rawResult, 'then', originalThen => function () {
|
|
49
|
+
const rawResult = raw.apply(this, args)
|
|
50
|
+
shimmer.wrap(rawResult, 'then', originalThen => function (...args) {
|
|
51
51
|
return rawQuerySubscribes.runStores(context, () => {
|
|
52
|
-
|
|
53
|
-
if (
|
|
52
|
+
args[0] = wrapCallbackWithFinish(args[0], finish, context)
|
|
53
|
+
if (args[1]) args[1] = wrapCallbackWithFinish(args[1], finish, context)
|
|
54
54
|
|
|
55
|
-
const originalThenResult = originalThen.apply(this,
|
|
55
|
+
const originalThenResult = originalThen.apply(this, args)
|
|
56
56
|
|
|
57
|
-
shimmer.wrap(originalThenResult, 'catch', originalCatch => function () {
|
|
58
|
-
|
|
59
|
-
return originalCatch.apply(this,
|
|
57
|
+
shimmer.wrap(originalThenResult, 'catch', originalCatch => function (...args) {
|
|
58
|
+
args[0] = wrapCallbackWithFinish(args[0], finish, context)
|
|
59
|
+
return originalCatch.apply(this, args)
|
|
60
60
|
})
|
|
61
61
|
|
|
62
62
|
return originalThenResult
|
|
63
63
|
})
|
|
64
64
|
})
|
|
65
65
|
|
|
66
|
-
shimmer.wrap(rawResult, 'asCallback', originalAsCallback => function () {
|
|
66
|
+
shimmer.wrap(rawResult, 'asCallback', originalAsCallback => function (...args) {
|
|
67
67
|
return rawQuerySubscribes.runStores(context, () => {
|
|
68
|
-
|
|
69
|
-
return originalAsCallback.apply(this,
|
|
68
|
+
args[0] = wrapCallbackWithFinish(args[0], finish, context)
|
|
69
|
+
return originalAsCallback.apply(this, args)
|
|
70
70
|
})
|
|
71
71
|
})
|
|
72
72
|
|
|
@@ -80,7 +80,7 @@ addHook({
|
|
|
80
80
|
function wrapCallbackWithFinish (callback, finish, context) {
|
|
81
81
|
if (typeof callback !== 'function') return callback
|
|
82
82
|
|
|
83
|
-
return shimmer.wrapFunction(callback, callback => function () {
|
|
84
|
-
finish(context, () => callback.apply(this,
|
|
83
|
+
return shimmer.wrapFunction(callback, callback => function (...args) {
|
|
84
|
+
finish(context, () => callback.apply(this, args))
|
|
85
85
|
})
|
|
86
86
|
}
|
|
@@ -14,8 +14,8 @@ const routeChannel = channel('apm:koa:request:route')
|
|
|
14
14
|
const originals = new WeakMap()
|
|
15
15
|
|
|
16
16
|
function wrapCallback (callback) {
|
|
17
|
-
return function callbackWithTrace () {
|
|
18
|
-
const handleRequest = callback.apply(this,
|
|
17
|
+
return function callbackWithTrace (...args) {
|
|
18
|
+
const handleRequest = callback.apply(this, args)
|
|
19
19
|
|
|
20
20
|
if (typeof handleRequest !== 'function') return handleRequest
|
|
21
21
|
|
|
@@ -28,14 +28,14 @@ function wrapCallback (callback) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
function wrapUse (use) {
|
|
31
|
-
return function useWithTrace () {
|
|
32
|
-
const result = use.apply(this,
|
|
31
|
+
return function useWithTrace (...args) {
|
|
32
|
+
const result = use.apply(this, args)
|
|
33
33
|
|
|
34
|
-
if (
|
|
34
|
+
if (Array.isArray(this.middleware)) {
|
|
35
|
+
const fn = this.middleware.pop()
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
this.middleware.push(wrapMiddleware(fn))
|
|
37
|
+
this.middleware.push(wrapMiddleware(fn))
|
|
38
|
+
}
|
|
39
39
|
|
|
40
40
|
return result
|
|
41
41
|
}
|
|
@@ -54,8 +54,8 @@ function wrapRegister (register) {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
function wrapRouterUse (use) {
|
|
57
|
-
return function useWithTrace () {
|
|
58
|
-
const router = use.apply(this,
|
|
57
|
+
return function useWithTrace (...args) {
|
|
58
|
+
const router = use.apply(this, args)
|
|
59
59
|
|
|
60
60
|
for (const layer of router.stack) {
|
|
61
61
|
wrapStack(layer)
|
|
@@ -144,10 +144,10 @@ function fulfill (ctx, error) {
|
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
function wrapNext (req, next) {
|
|
147
|
-
return shimmer.wrapFunction(next, next => function () {
|
|
147
|
+
return shimmer.wrapFunction(next, next => function (...args) {
|
|
148
148
|
nextChannel.publish({ req })
|
|
149
149
|
|
|
150
|
-
return next.apply(this,
|
|
150
|
+
return next.apply(this, args)
|
|
151
151
|
})
|
|
152
152
|
}
|
|
153
153
|
|
|
@@ -71,12 +71,12 @@ addHook({ name: 'ldapjs', versions: ['>=2'] }, ldapjs => {
|
|
|
71
71
|
return search.apply(this, arguments)
|
|
72
72
|
})
|
|
73
73
|
|
|
74
|
-
shimmer.wrap(ldapjs.Client.prototype, '_send', _send => function () {
|
|
75
|
-
const callbackIndex = getCallbackArgIndex(
|
|
74
|
+
shimmer.wrap(ldapjs.Client.prototype, '_send', _send => function (...args) {
|
|
75
|
+
const callbackIndex = getCallbackArgIndex(args)
|
|
76
76
|
if (callbackIndex > -1) {
|
|
77
|
-
const callback =
|
|
77
|
+
const callback = args[callbackIndex]
|
|
78
78
|
// eslint-disable-next-line n/handle-callback-err
|
|
79
|
-
|
|
79
|
+
args[callbackIndex] = shimmer.wrapFunction(callback, callback => function (err, corkedEmitter) {
|
|
80
80
|
if (corkedEmitter !== null && typeof corkedEmitter === 'object' && typeof corkedEmitter.on === 'function') {
|
|
81
81
|
wrapEmitter(corkedEmitter)
|
|
82
82
|
}
|
|
@@ -84,7 +84,7 @@ addHook({ name: 'ldapjs', versions: ['>=2'] }, ldapjs => {
|
|
|
84
84
|
})
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
return _send.apply(this,
|
|
87
|
+
return _send.apply(this, args)
|
|
88
88
|
})
|
|
89
89
|
|
|
90
90
|
shimmer.wrap(ldapjs.Client.prototype, 'bind', bind => function (dn, password, controls, callback) {
|
|
@@ -69,8 +69,8 @@ function wrapDispatchFunc (dispatchFunc) {
|
|
|
69
69
|
// Also wrap end() as fallback
|
|
70
70
|
const originalEnd = res.end
|
|
71
71
|
if (originalEnd) {
|
|
72
|
-
res.end = function wrappedEnd () {
|
|
73
|
-
const result = originalEnd.apply(this,
|
|
72
|
+
res.end = function wrappedEnd (...args) {
|
|
73
|
+
const result = originalEnd.apply(this, args)
|
|
74
74
|
// Trigger finish if events don't fire
|
|
75
75
|
setImmediate(onFinish)
|
|
76
76
|
return result
|
|
@@ -4,10 +4,10 @@ const shimmer = require('../../datadog-shimmer')
|
|
|
4
4
|
const { addHook, AsyncResource } = require('./helpers/instrument')
|
|
5
5
|
|
|
6
6
|
function wrapRequest (original) {
|
|
7
|
-
return function () {
|
|
8
|
-
const id =
|
|
9
|
-
|
|
10
|
-
return original.apply(this,
|
|
7
|
+
return function (...args) {
|
|
8
|
+
const id = args.length - 1
|
|
9
|
+
args[id] = AsyncResource.bind(args[id])
|
|
10
|
+
return original.apply(this, args)
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
|
|
@@ -12,13 +12,13 @@ addHook({ name: 'lodash', versions: ['>=4'] }, lodash => {
|
|
|
12
12
|
lodash,
|
|
13
13
|
instrumentedLodashFn,
|
|
14
14
|
lodashFn => {
|
|
15
|
-
return function () {
|
|
15
|
+
return function (...args) {
|
|
16
16
|
if (!lodashOperationCh.hasSubscribers) {
|
|
17
|
-
return lodashFn.apply(this,
|
|
17
|
+
return lodashFn.apply(this, args)
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
const result = lodashFn.apply(this,
|
|
21
|
-
const message = { operation: lodashFn.name, arguments, result }
|
|
20
|
+
const result = lodashFn.apply(this, args)
|
|
21
|
+
const message = { operation: lodashFn.name, arguments: args, result }
|
|
22
22
|
lodashOperationCh.publish(message)
|
|
23
23
|
|
|
24
24
|
return message.result
|
|
@@ -12,13 +12,13 @@ const errorCh = channel('apm:mariadb:query:error')
|
|
|
12
12
|
const skipCh = channel('apm:mariadb:pool:skip')
|
|
13
13
|
|
|
14
14
|
function wrapCommandStart (start, ctx) {
|
|
15
|
-
return shimmer.wrapFunction(start, start => function () {
|
|
16
|
-
if (!startCh.hasSubscribers) return start.apply(this,
|
|
15
|
+
return shimmer.wrapFunction(start, start => function (...args) {
|
|
16
|
+
if (!startCh.hasSubscribers) return start.apply(this, args)
|
|
17
17
|
|
|
18
18
|
const { reject, resolve } = this
|
|
19
19
|
shimmer.wrap(this, 'resolve', function wrapResolve () {
|
|
20
|
-
return function () {
|
|
21
|
-
return finishCh.runStores(ctx, resolve, this, ...
|
|
20
|
+
return function (...args) {
|
|
21
|
+
return finishCh.runStores(ctx, resolve, this, ...args)
|
|
22
22
|
}
|
|
23
23
|
})
|
|
24
24
|
|
|
@@ -32,7 +32,7 @@ function wrapCommandStart (start, ctx) {
|
|
|
32
32
|
}
|
|
33
33
|
})
|
|
34
34
|
|
|
35
|
-
return startCh.runStores(ctx, start, this, ...
|
|
35
|
+
return startCh.runStores(ctx, start, this, ...args)
|
|
36
36
|
})
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -128,25 +128,25 @@ function wrapPoolBase (PoolBase) {
|
|
|
128
128
|
// so instead we just skip instrumentation completely to avoid memory leaks
|
|
129
129
|
// and/or orphan spans.
|
|
130
130
|
function wrapPoolMethod (createConnection) {
|
|
131
|
-
return function () {
|
|
132
|
-
return skipCh.runStores({}, createConnection, this, ...
|
|
131
|
+
return function (...args) {
|
|
132
|
+
return skipCh.runStores({}, createConnection, this, ...args)
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
function wrapPoolGetConnectionMethod (getConnection) {
|
|
137
|
-
return function wrappedGetConnection () {
|
|
138
|
-
const cb =
|
|
139
|
-
if (typeof cb !== 'function') return getConnection.apply(this,
|
|
137
|
+
return function wrappedGetConnection (...args) {
|
|
138
|
+
const cb = args[args.length - 1]
|
|
139
|
+
if (typeof cb !== 'function') return getConnection.apply(this, args)
|
|
140
140
|
|
|
141
141
|
const ctx = {}
|
|
142
142
|
|
|
143
|
-
|
|
144
|
-
return connectionFinishCh.runStores(ctx, cb, this, ...
|
|
143
|
+
args[args.length - 1] = function (...args) {
|
|
144
|
+
return connectionFinishCh.runStores(ctx, cb, this, ...args)
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
connectionStartCh.publish(ctx)
|
|
148
148
|
|
|
149
|
-
return getConnection.apply(this,
|
|
149
|
+
return getConnection.apply(this, args)
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
|
|
@@ -18,8 +18,8 @@ addHook({ name: 'memcached', versions: ['>=2.2'] }, Memcached => {
|
|
|
18
18
|
|
|
19
19
|
const client = this
|
|
20
20
|
|
|
21
|
-
const wrappedQueryCompiler = function () {
|
|
22
|
-
const query = queryCompiler.apply(this,
|
|
21
|
+
const wrappedQueryCompiler = function (...args) {
|
|
22
|
+
const query = queryCompiler.apply(this, args)
|
|
23
23
|
|
|
24
24
|
const ctx = { client, server, query }
|
|
25
25
|
startCh.runStores(ctx, () => {
|
|
@@ -14,8 +14,8 @@ const versions = ['>=2.1 <=3.0.0']
|
|
|
14
14
|
const requestContexts = new WeakMap()
|
|
15
15
|
|
|
16
16
|
function wrapConfigProxyFactory (configProxyFactory) {
|
|
17
|
-
return function () {
|
|
18
|
-
const configProxy = configProxyFactory.apply(this,
|
|
17
|
+
return function (...args) {
|
|
18
|
+
const configProxy = configProxyFactory.apply(this, args)
|
|
19
19
|
|
|
20
20
|
return function (req, res, next) {
|
|
21
21
|
const ctx = { req, res }
|
|
@@ -20,9 +20,9 @@ addHook({
|
|
|
20
20
|
|
|
21
21
|
patched.add(mochaEach)
|
|
22
22
|
|
|
23
|
-
return shimmer.wrapFunction(mochaEach, mochaEach => function () {
|
|
24
|
-
const [params] =
|
|
25
|
-
const { it, ...rest } = mochaEach.apply(this,
|
|
23
|
+
return shimmer.wrapFunction(mochaEach, mochaEach => function (...args) {
|
|
24
|
+
const [params] = args
|
|
25
|
+
const { it, ...rest } = mochaEach.apply(this, args)
|
|
26
26
|
return {
|
|
27
27
|
it: function (title) {
|
|
28
28
|
parameterizedTestCh.publish({ title, params })
|
|
@@ -326,6 +326,7 @@ function getExecutionConfiguration (runner, isParallel, frameworkVersion, onFini
|
|
|
326
326
|
}
|
|
327
327
|
config.isEarlyFlakeDetectionEnabled = libraryConfig.isEarlyFlakeDetectionEnabled
|
|
328
328
|
config.earlyFlakeDetectionNumRetries = libraryConfig.earlyFlakeDetectionNumRetries
|
|
329
|
+
config.earlyFlakeDetectionSlowTestRetries = libraryConfig.earlyFlakeDetectionSlowTestRetries ?? {}
|
|
329
330
|
config.earlyFlakeDetectionFaultyThreshold = libraryConfig.earlyFlakeDetectionFaultyThreshold
|
|
330
331
|
config.isKnownTestsEnabled = libraryConfig.isKnownTestsEnabled
|
|
331
332
|
config.isTestManagementTestsEnabled = libraryConfig.isTestManagementEnabled
|
|
@@ -369,17 +370,17 @@ addHook({
|
|
|
369
370
|
}, (Mocha, frameworkVersion) => {
|
|
370
371
|
warnDeprecatedMochaVersion(frameworkVersion)
|
|
371
372
|
|
|
372
|
-
shimmer.wrap(Mocha.prototype, 'run', run => function () {
|
|
373
|
+
shimmer.wrap(Mocha.prototype, 'run', run => function (...args) {
|
|
373
374
|
// Workers do not need to request any data, just run the tests
|
|
374
375
|
if (!testFinishCh.hasSubscribers || getEnvironmentVariable('MOCHA_WORKER_ID') || this.options.parallel) {
|
|
375
|
-
return run.apply(this,
|
|
376
|
+
return run.apply(this, args)
|
|
376
377
|
}
|
|
377
378
|
|
|
378
379
|
// `options.delay` does not work in parallel mode, so we can't delay the execution this way
|
|
379
380
|
// This needs to be both here and in `runMocha` hook. Read the comment in `runMocha` hook for more info.
|
|
380
381
|
this.options.delay = true
|
|
381
382
|
|
|
382
|
-
const runner = run.apply(this,
|
|
383
|
+
const runner = run.apply(this, args)
|
|
383
384
|
|
|
384
385
|
// eslint-disable-next-line unicorn/no-array-for-each
|
|
385
386
|
this.files.forEach((path) => {
|
|
@@ -426,11 +427,11 @@ addHook({
|
|
|
426
427
|
file: 'lib/cli/run-helpers.js',
|
|
427
428
|
}, (run) => {
|
|
428
429
|
// `runMocha` is an async function
|
|
429
|
-
shimmer.wrap(run, 'runMocha', runMocha => function () {
|
|
430
|
+
shimmer.wrap(run, 'runMocha', runMocha => function (...args) {
|
|
430
431
|
if (!testFinishCh.hasSubscribers) {
|
|
431
|
-
return runMocha.apply(this,
|
|
432
|
+
return runMocha.apply(this, args)
|
|
432
433
|
}
|
|
433
|
-
const mocha =
|
|
434
|
+
const mocha = args[0]
|
|
434
435
|
|
|
435
436
|
/**
|
|
436
437
|
* This attaches `run` to the global context, which we'll call after
|
|
@@ -444,7 +445,7 @@ addHook({
|
|
|
444
445
|
mocha.options.delay = true
|
|
445
446
|
}
|
|
446
447
|
|
|
447
|
-
return runMocha.apply(this,
|
|
448
|
+
return runMocha.apply(this, args)
|
|
448
449
|
})
|
|
449
450
|
return run
|
|
450
451
|
})
|
|
@@ -462,9 +463,9 @@ addHook({
|
|
|
462
463
|
|
|
463
464
|
shimmer.wrap(Runner.prototype, 'runTests', runTests => getRunTestsWrapper(runTests, config))
|
|
464
465
|
|
|
465
|
-
shimmer.wrap(Runner.prototype, 'run', run => function () {
|
|
466
|
+
shimmer.wrap(Runner.prototype, 'run', run => function (...args) {
|
|
466
467
|
if (!testFinishCh.hasSubscribers) {
|
|
467
|
-
return run.apply(this,
|
|
468
|
+
return run.apply(this, args)
|
|
468
469
|
}
|
|
469
470
|
|
|
470
471
|
const { suitesByTestFile, numSuitesByTestFile } = getSuitesByTestFile(this.suite)
|
|
@@ -552,7 +553,7 @@ addHook({
|
|
|
552
553
|
}
|
|
553
554
|
})
|
|
554
555
|
|
|
555
|
-
return run.apply(this,
|
|
556
|
+
return run.apply(this, args)
|
|
556
557
|
})
|
|
557
558
|
|
|
558
559
|
return Runner
|
|
@@ -722,6 +723,7 @@ addHook({
|
|
|
722
723
|
if (config.knownTests?.mocha) {
|
|
723
724
|
const testSuiteKnownTests = config.knownTests.mocha[testPath] || []
|
|
724
725
|
newWorkerArgs._ddEfdNumRetries = config.earlyFlakeDetectionNumRetries
|
|
726
|
+
newWorkerArgs._ddEfdSlowTestRetries = config.earlyFlakeDetectionSlowTestRetries
|
|
725
727
|
newWorkerArgs._ddIsEfdEnabled = config.isEarlyFlakeDetectionEnabled
|
|
726
728
|
newWorkerArgs._ddIsKnownTestsEnabled = true
|
|
727
729
|
newWorkerArgs._ddKnownTests = {
|