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
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const { performance } = require('node:perf_hooks')
|
|
4
|
+
|
|
3
5
|
const { createCoverageMap } = require('../../../vendor/dist/istanbul-lib-coverage')
|
|
4
6
|
const shimmer = require('../../datadog-shimmer')
|
|
5
7
|
const log = require('../../dd-trace/src/log')
|
|
@@ -12,6 +14,7 @@ const {
|
|
|
12
14
|
getTestSuitePath,
|
|
13
15
|
CUCUMBER_WORKER_TRACE_PAYLOAD_CODE,
|
|
14
16
|
getIsFaultyEarlyFlakeDetection,
|
|
17
|
+
getEfdRetryCount,
|
|
15
18
|
recordAttemptToFixExecution,
|
|
16
19
|
collectAttemptToFixExecutionsFromTraces,
|
|
17
20
|
logAttemptToFixTestExecution,
|
|
@@ -62,6 +65,9 @@ const lastStatusByPickleId = new Map()
|
|
|
62
65
|
/** For ATR: statuses keyed by stable scenario id (uri:name) so retries accumulate correctly */
|
|
63
66
|
const atrStatusesByScenarioKey = new Map()
|
|
64
67
|
const numRetriesByPickleId = new Map()
|
|
68
|
+
const efdRetryCountByPickleId = new Map()
|
|
69
|
+
const efdSlowAbortedPickleIds = new Set()
|
|
70
|
+
const testCaseStartedTimesById = new Map()
|
|
65
71
|
const numAttemptToCtx = new Map()
|
|
66
72
|
const newTestsByTestFullname = new Map()
|
|
67
73
|
const attemptToFixTestsByTestFullname = new Map()
|
|
@@ -82,6 +88,7 @@ let isUnskippable = false
|
|
|
82
88
|
let isSuitesSkippingEnabled = false
|
|
83
89
|
let isEarlyFlakeDetectionEnabled = false
|
|
84
90
|
let earlyFlakeDetectionNumRetries = 0
|
|
91
|
+
let earlyFlakeDetectionSlowTestRetries = {}
|
|
85
92
|
let earlyFlakeDetectionFaultyThreshold = 0
|
|
86
93
|
let isEarlyFlakeDetectionFaulty = false
|
|
87
94
|
let isFlakyTestRetriesEnabled = false
|
|
@@ -290,9 +297,9 @@ function wrapRun (pl, isLatestVersion, version) {
|
|
|
290
297
|
|
|
291
298
|
patched.add(pl)
|
|
292
299
|
|
|
293
|
-
shimmer.wrap(pl.prototype, 'run', run => function () {
|
|
300
|
+
shimmer.wrap(pl.prototype, 'run', run => function (...args) {
|
|
294
301
|
if (!testFinishCh.hasSubscribers) {
|
|
295
|
-
return run.apply(this,
|
|
302
|
+
return run.apply(this, args)
|
|
296
303
|
}
|
|
297
304
|
|
|
298
305
|
let numAttempt = 0
|
|
@@ -360,9 +367,10 @@ function wrapRun (pl, isLatestVersion, version) {
|
|
|
360
367
|
}
|
|
361
368
|
this.eventBroadcaster.on('envelope', onEnvelope)
|
|
362
369
|
let promise
|
|
370
|
+
const executionStart = performance.now()
|
|
363
371
|
|
|
364
372
|
testFnCh.runStores(ctx, () => {
|
|
365
|
-
promise = run.apply(this,
|
|
373
|
+
promise = run.apply(this, args)
|
|
366
374
|
})
|
|
367
375
|
promise.finally(async () => {
|
|
368
376
|
this.eventBroadcaster.removeListener('envelope', onEnvelope)
|
|
@@ -424,15 +432,31 @@ function wrapRun (pl, isLatestVersion, version) {
|
|
|
424
432
|
isEfdRetry = numRetries > 0
|
|
425
433
|
}
|
|
426
434
|
|
|
435
|
+
if (
|
|
436
|
+
isEarlyFlakeDetectionEnabled &&
|
|
437
|
+
status !== 'skip' &&
|
|
438
|
+
(isNew || isModified) &&
|
|
439
|
+
!isEfdRetry &&
|
|
440
|
+
!efdRetryCountByPickleId.has(this.pickle.id)
|
|
441
|
+
) {
|
|
442
|
+
const retryCount = getEfdRetryCount(performance.now() - executionStart, earlyFlakeDetectionSlowTestRetries)
|
|
443
|
+
efdRetryCountByPickleId.set(this.pickle.id, retryCount)
|
|
444
|
+
if (retryCount === 0) {
|
|
445
|
+
efdSlowAbortedPickleIds.add(this.pickle.id)
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
const efdRetryCount = efdRetryCountByPickleId.get(this.pickle.id) ?? earlyFlakeDetectionNumRetries
|
|
450
|
+
|
|
427
451
|
// Check if all EFD retries failed
|
|
428
452
|
if (isEfdRetry && (isNew || isModified)) {
|
|
429
453
|
const statuses = lastStatusByPickleId.get(this.pickle.id)
|
|
430
|
-
if (statuses.length ===
|
|
454
|
+
if (statuses.length === efdRetryCount + 1) {
|
|
431
455
|
const { fail } = statuses.reduce((acc, status) => {
|
|
432
456
|
acc[status]++
|
|
433
457
|
return acc
|
|
434
458
|
}, { pass: 0, fail: 0 })
|
|
435
|
-
if (fail ===
|
|
459
|
+
if (fail === efdRetryCount + 1) {
|
|
436
460
|
hasFailedAllRetries = true
|
|
437
461
|
}
|
|
438
462
|
}
|
|
@@ -480,7 +504,7 @@ function wrapRun (pl, isLatestVersion, version) {
|
|
|
480
504
|
const isLastAtrRetry = isFlakyTestRetriesEnabled && !isAttemptToFix && !isEfdRetry && numTestRetries > 0
|
|
481
505
|
|
|
482
506
|
const statuses = lastStatusByPickleId.get(this.pickle.id)
|
|
483
|
-
const isLastEfdRetry = isEfdRetry && statuses?.length ===
|
|
507
|
+
const isLastEfdRetry = isEfdRetry && statuses?.length === efdRetryCount + 1
|
|
484
508
|
const isLastAttemptToFixRetry = isAttemptToFix && statuses?.length === testManagementAttemptToFixRetries + 1
|
|
485
509
|
|
|
486
510
|
// Intermediate (non-last EFD or ATF retries) executions do not report a final status
|
|
@@ -514,6 +538,7 @@ function wrapRun (pl, isLatestVersion, version) {
|
|
|
514
538
|
isDisabled,
|
|
515
539
|
isQuarantined,
|
|
516
540
|
isModified,
|
|
541
|
+
earlyFlakeAbortReason: efdSlowAbortedPickleIds.has(this.pickle.id) ? 'slow' : undefined,
|
|
517
542
|
...attemptCtx.currentStore,
|
|
518
543
|
finalStatus,
|
|
519
544
|
})
|
|
@@ -526,11 +551,11 @@ function wrapRun (pl, isLatestVersion, version) {
|
|
|
526
551
|
})
|
|
527
552
|
}
|
|
528
553
|
})
|
|
529
|
-
shimmer.wrap(pl.prototype, 'runStep', runStep => function () {
|
|
554
|
+
shimmer.wrap(pl.prototype, 'runStep', runStep => function (...args) {
|
|
530
555
|
if (!testFinishCh.hasSubscribers) {
|
|
531
|
-
return runStep.apply(this,
|
|
556
|
+
return runStep.apply(this, args)
|
|
532
557
|
}
|
|
533
|
-
const testStep =
|
|
558
|
+
const testStep = args[0]
|
|
534
559
|
let resource
|
|
535
560
|
|
|
536
561
|
if (isLatestVersion) {
|
|
@@ -542,7 +567,7 @@ function wrapRun (pl, isLatestVersion, version) {
|
|
|
542
567
|
const ctx = { resource }
|
|
543
568
|
return testStepStartCh.runStores(ctx, () => {
|
|
544
569
|
try {
|
|
545
|
-
const promise = runStep.apply(this,
|
|
570
|
+
const promise = runStep.apply(this, args)
|
|
546
571
|
|
|
547
572
|
promise.then((result) => {
|
|
548
573
|
const finalResult = satisfies(version, '>=12.0.0') ? result.result : result
|
|
@@ -603,6 +628,7 @@ function getWrappedStart (start, frameworkVersion, isParallel = false, isCoordin
|
|
|
603
628
|
|
|
604
629
|
isEarlyFlakeDetectionEnabled = configurationResponse.libraryConfig?.isEarlyFlakeDetectionEnabled
|
|
605
630
|
earlyFlakeDetectionNumRetries = configurationResponse.libraryConfig?.earlyFlakeDetectionNumRetries
|
|
631
|
+
earlyFlakeDetectionSlowTestRetries = configurationResponse.libraryConfig?.earlyFlakeDetectionSlowTestRetries ?? {}
|
|
606
632
|
earlyFlakeDetectionFaultyThreshold = configurationResponse.libraryConfig?.earlyFlakeDetectionFaultyThreshold
|
|
607
633
|
isSuitesSkippingEnabled = configurationResponse.libraryConfig?.isSuitesSkippingEnabled
|
|
608
634
|
isFlakyTestRetriesEnabled = configurationResponse.libraryConfig?.isFlakyTestRetriesEnabled
|
|
@@ -692,6 +718,10 @@ function getWrappedStart (start, frameworkVersion, isParallel = false, isCoordin
|
|
|
692
718
|
|
|
693
719
|
atrStatusesByScenarioKey.clear()
|
|
694
720
|
attemptToFixTestsByTestFullname.clear()
|
|
721
|
+
efdRetryCountByPickleId.clear()
|
|
722
|
+
efdSlowAbortedPickleIds.clear()
|
|
723
|
+
testCaseStartedTimesById.clear()
|
|
724
|
+
newTestsByTestFullname.clear()
|
|
695
725
|
sessionStartCh.publish({ command, frameworkVersion })
|
|
696
726
|
|
|
697
727
|
if (!errorSkippableRequest && skippedSuites.length) {
|
|
@@ -816,7 +846,9 @@ function getWrappedRunTestCase (runTestCaseFunction, isNewerCucumberVersion = fa
|
|
|
816
846
|
}
|
|
817
847
|
}
|
|
818
848
|
// TODO: for >=11 we could use `runTestCaseResult` instead of accumulating results in `lastStatusByPickleId`
|
|
849
|
+
const firstExecutionStart = performance.now()
|
|
819
850
|
let runTestCaseResult = await runTestCaseFunction.apply(this, arguments)
|
|
851
|
+
const firstExecutionDurationMs = performance.now() - firstExecutionStart
|
|
820
852
|
|
|
821
853
|
// Restore dryRun so it doesn't affect subsequent tests in the same worker
|
|
822
854
|
this.options.dryRun = originalDryRun
|
|
@@ -835,7 +867,15 @@ function getWrappedRunTestCase (runTestCaseFunction, isNewerCucumberVersion = fa
|
|
|
835
867
|
|
|
836
868
|
// If it's a new test and it hasn't been skipped, we run it again
|
|
837
869
|
if (isEarlyFlakeDetectionEnabled && lastTestStatus !== 'skip' && (isNew || isModified)) {
|
|
838
|
-
|
|
870
|
+
let efdRetryCount = efdRetryCountByPickleId.get(pickle.id)
|
|
871
|
+
if (efdRetryCount === undefined) {
|
|
872
|
+
efdRetryCount = getEfdRetryCount(firstExecutionDurationMs, earlyFlakeDetectionSlowTestRetries)
|
|
873
|
+
efdRetryCountByPickleId.set(pickle.id, efdRetryCount)
|
|
874
|
+
if (efdRetryCount === 0) {
|
|
875
|
+
efdSlowAbortedPickleIds.add(pickle.id)
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
for (let retryIndex = 0; retryIndex < efdRetryCount; retryIndex++) {
|
|
839
879
|
numRetriesByPickleId.set(pickle.id, retryIndex + 1)
|
|
840
880
|
// eslint-disable-next-line no-await-in-loop
|
|
841
881
|
runTestCaseResult = await runTestCaseFunction.apply(this, arguments)
|
|
@@ -952,6 +992,9 @@ function getWrappedParseWorkerMessage (parseWorkerMessageFunction, isNewVersion)
|
|
|
952
992
|
let pickle
|
|
953
993
|
|
|
954
994
|
if (parsed.testCaseStarted) {
|
|
995
|
+
if (parsed.testCaseStarted.id) {
|
|
996
|
+
testCaseStartedTimesById.set(parsed.testCaseStarted.id, performance.now())
|
|
997
|
+
}
|
|
955
998
|
if (isNewVersion) {
|
|
956
999
|
pickle = this.inProgress[worker.id].pickle
|
|
957
1000
|
} else {
|
|
@@ -973,6 +1016,10 @@ function getWrappedParseWorkerMessage (parseWorkerMessageFunction, isNewVersion)
|
|
|
973
1016
|
|
|
974
1017
|
// after calling `parseWorkerMessageFunction`, the test status can already be read
|
|
975
1018
|
if (parsed.testCaseFinished) {
|
|
1019
|
+
const testCaseStartedId = parsed.testCaseFinished.testCaseStartedId
|
|
1020
|
+
const testCaseStartedAt = testCaseStartedTimesById.get(testCaseStartedId)
|
|
1021
|
+
testCaseStartedTimesById.delete(testCaseStartedId)
|
|
1022
|
+
|
|
976
1023
|
let worstTestStepResult
|
|
977
1024
|
if (isNewVersion && eventDataCollector) {
|
|
978
1025
|
pickle = this.inProgress[worker.id].pickle
|
|
@@ -1003,8 +1050,19 @@ function getWrappedParseWorkerMessage (parseWorkerMessageFunction, isNewVersion)
|
|
|
1003
1050
|
testStatuses = [status]
|
|
1004
1051
|
newTestsByTestFullname.set(testFullname, testStatuses)
|
|
1005
1052
|
}
|
|
1053
|
+
let efdRetryCount = efdRetryCountByPickleId.get(pickle.id)
|
|
1054
|
+
if (efdRetryCount === undefined) {
|
|
1055
|
+
const firstExecutionDurationMs = testCaseStartedAt === undefined ? 0 : performance.now() - testCaseStartedAt
|
|
1056
|
+
efdRetryCount = status === 'skip'
|
|
1057
|
+
? 0
|
|
1058
|
+
: getEfdRetryCount(firstExecutionDurationMs, earlyFlakeDetectionSlowTestRetries)
|
|
1059
|
+
efdRetryCountByPickleId.set(pickle.id, efdRetryCount)
|
|
1060
|
+
if (efdRetryCount === 0 && status !== 'skip') {
|
|
1061
|
+
efdSlowAbortedPickleIds.add(pickle.id)
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1006
1064
|
// We have finished all retries
|
|
1007
|
-
if (testStatuses.length ===
|
|
1065
|
+
if (testStatuses.length === efdRetryCount + 1) {
|
|
1008
1066
|
const newTestFinalStatus = getTestStatusFromRetries(testStatuses)
|
|
1009
1067
|
// we only push to `finished` if the retries have finished
|
|
1010
1068
|
finished.push(newTestFinalStatus)
|
|
@@ -1143,9 +1201,9 @@ addHook({
|
|
|
1143
1201
|
versions: ['>=11.0.0'],
|
|
1144
1202
|
file: 'lib/formatter/helpers/event_data_collector.js',
|
|
1145
1203
|
}, (eventDataCollectorPackage) => {
|
|
1146
|
-
shimmer.wrap(eventDataCollectorPackage.default.prototype, 'parseEnvelope', parseEnvelope => function () {
|
|
1204
|
+
shimmer.wrap(eventDataCollectorPackage.default.prototype, 'parseEnvelope', parseEnvelope => function (...args) {
|
|
1147
1205
|
eventDataCollector = this
|
|
1148
|
-
return parseEnvelope.apply(this,
|
|
1206
|
+
return parseEnvelope.apply(this, args)
|
|
1149
1207
|
})
|
|
1150
1208
|
return eventDataCollectorPackage
|
|
1151
1209
|
})
|
|
@@ -1164,18 +1222,20 @@ addHook({
|
|
|
1164
1222
|
parseWorkerMessage => getWrappedParseWorkerMessage(parseWorkerMessage, true)
|
|
1165
1223
|
)
|
|
1166
1224
|
// EFD in parallel mode only supported in >=11.0.0
|
|
1167
|
-
shimmer.wrap(adapterPackage.ChildProcessAdapter.prototype, 'startWorker', startWorker => function () {
|
|
1225
|
+
shimmer.wrap(adapterPackage.ChildProcessAdapter.prototype, 'startWorker', startWorker => function (...args) {
|
|
1168
1226
|
if (isKnownTestsEnabled && isValidKnownTests(knownTests)) {
|
|
1169
1227
|
this.options.worldParameters._ddIsKnownTestsEnabled = true
|
|
1170
1228
|
this.options.worldParameters._ddIsEarlyFlakeDetectionEnabled = isEarlyFlakeDetectionEnabled
|
|
1171
1229
|
this.options.worldParameters._ddKnownTests = knownTests
|
|
1172
1230
|
this.options.worldParameters._ddEarlyFlakeDetectionNumRetries = earlyFlakeDetectionNumRetries
|
|
1231
|
+
this.options.worldParameters._ddEarlyFlakeDetectionSlowTestRetries = earlyFlakeDetectionSlowTestRetries
|
|
1173
1232
|
} else {
|
|
1174
1233
|
isEarlyFlakeDetectionEnabled = false
|
|
1175
1234
|
isKnownTestsEnabled = false
|
|
1176
1235
|
this.options.worldParameters._ddIsEarlyFlakeDetectionEnabled = false
|
|
1177
1236
|
this.options.worldParameters._ddIsKnownTestsEnabled = false
|
|
1178
1237
|
this.options.worldParameters._ddEarlyFlakeDetectionNumRetries = 0
|
|
1238
|
+
this.options.worldParameters._ddEarlyFlakeDetectionSlowTestRetries = {}
|
|
1179
1239
|
}
|
|
1180
1240
|
|
|
1181
1241
|
if (isImpactedTestsEnabled) {
|
|
@@ -1192,7 +1252,7 @@ addHook({
|
|
|
1192
1252
|
this.options.worldParameters._ddTestManagementAttemptToFixRetries = testManagementAttemptToFixRetries
|
|
1193
1253
|
}
|
|
1194
1254
|
|
|
1195
|
-
return startWorker.apply(this,
|
|
1255
|
+
return startWorker.apply(this, args)
|
|
1196
1256
|
})
|
|
1197
1257
|
return adapterPackage
|
|
1198
1258
|
})
|
|
@@ -1222,6 +1282,7 @@ addHook({
|
|
|
1222
1282
|
isEarlyFlakeDetectionEnabled = !!this.options.worldParameters._ddIsEarlyFlakeDetectionEnabled
|
|
1223
1283
|
if (isEarlyFlakeDetectionEnabled) {
|
|
1224
1284
|
earlyFlakeDetectionNumRetries = this.options.worldParameters._ddEarlyFlakeDetectionNumRetries
|
|
1285
|
+
earlyFlakeDetectionSlowTestRetries = this.options.worldParameters._ddEarlyFlakeDetectionSlowTestRetries ?? {}
|
|
1225
1286
|
}
|
|
1226
1287
|
isImpactedTestsEnabled = !!this.options.worldParameters._ddImpactedTestsEnabled
|
|
1227
1288
|
if (isImpactedTestsEnabled) {
|
|
@@ -8,11 +8,13 @@ const {
|
|
|
8
8
|
wrapConfig,
|
|
9
9
|
} = require('./cypress-config')
|
|
10
10
|
|
|
11
|
+
const MINIMUM_CYPRESS_VERSION = DD_MAJOR >= 6 ? '>=12.0.0' : '>=10.2.0'
|
|
12
|
+
|
|
11
13
|
// Wrap defineConfig() so configs are instrumented when loaded in Cypress's
|
|
12
14
|
// config child process. This covers both CLI and programmatic usage with CJS configs.
|
|
13
15
|
addHook({
|
|
14
16
|
name: 'cypress',
|
|
15
|
-
versions: [
|
|
17
|
+
versions: [MINIMUM_CYPRESS_VERSION],
|
|
16
18
|
}, (cypress) => {
|
|
17
19
|
if (typeof cypress.defineConfig === 'function') {
|
|
18
20
|
shimmer.wrap(cypress, 'defineConfig', (defineConfig) => function (config) {
|
|
@@ -61,7 +63,7 @@ function wrapStartOnModule (mod) {
|
|
|
61
63
|
for (const file of ['lib/exec/run.js', 'lib/exec/open.js', 'dist/exec/run.js', 'dist/exec/open.js']) {
|
|
62
64
|
addHook({
|
|
63
65
|
name: 'cypress',
|
|
64
|
-
versions: [
|
|
66
|
+
versions: [MINIMUM_CYPRESS_VERSION],
|
|
65
67
|
file,
|
|
66
68
|
}, wrapStartOnModule)
|
|
67
69
|
}
|
|
@@ -70,7 +72,7 @@ for (const file of ['lib/exec/run.js', 'lib/exec/open.js', 'dist/exec/run.js', '
|
|
|
70
72
|
// The chunk exports runModule and openModule, each with a start() method.
|
|
71
73
|
addHook({
|
|
72
74
|
name: 'cypress',
|
|
73
|
-
versions: [
|
|
75
|
+
versions: [MINIMUM_CYPRESS_VERSION],
|
|
74
76
|
filePattern: 'dist/cli.*',
|
|
75
77
|
}, (cliChunk) => {
|
|
76
78
|
if (cliChunk.runModule?.start) {
|
|
@@ -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
|
})
|