dd-trace 5.54.0 → 5.55.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/ci/cypress/plugin.js +8 -0
- package/ci/cypress/polyfills.js +23 -0
- package/ci/init.js +8 -7
- package/initialize.mjs +2 -2
- package/package.json +6 -6
- package/packages/datadog-code-origin/index.js +22 -4
- package/packages/datadog-core/src/utils/src/kebabcase.js +3 -3
- package/packages/datadog-instrumentations/src/cassandra-driver.js +5 -6
- package/packages/datadog-instrumentations/src/confluentinc-kafka-javascript.js +2 -3
- package/packages/datadog-instrumentations/src/cookie-parser.js +1 -1
- package/packages/datadog-instrumentations/src/couchbase.js +3 -6
- package/packages/datadog-instrumentations/src/cucumber.js +21 -28
- package/packages/datadog-instrumentations/src/dns.js +4 -4
- package/packages/datadog-instrumentations/src/elasticsearch.js +9 -10
- package/packages/datadog-instrumentations/src/fastify.js +7 -9
- package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +14 -16
- package/packages/datadog-instrumentations/src/hapi.js +10 -11
- package/packages/datadog-instrumentations/src/helpers/fetch.js +4 -5
- package/packages/datadog-instrumentations/src/helpers/hook.js +1 -2
- package/packages/datadog-instrumentations/src/helpers/register.js +6 -5
- package/packages/datadog-instrumentations/src/jest.js +67 -98
- package/packages/datadog-instrumentations/src/koa.js +2 -3
- package/packages/datadog-instrumentations/src/mariadb.js +11 -4
- package/packages/datadog-instrumentations/src/mocha/main.js +79 -75
- package/packages/datadog-instrumentations/src/mocha.js +3 -1
- package/packages/datadog-instrumentations/src/mysql.js +11 -2
- package/packages/datadog-instrumentations/src/nyc.js +2 -1
- package/packages/datadog-instrumentations/src/openai.js +2 -2
- package/packages/datadog-instrumentations/src/otel-sdk-trace.js +4 -3
- package/packages/datadog-instrumentations/src/pg.js +2 -3
- package/packages/datadog-instrumentations/src/playwright.js +19 -22
- package/packages/datadog-instrumentations/src/protobufjs.js +3 -4
- package/packages/datadog-instrumentations/src/redis.js +1 -1
- package/packages/datadog-instrumentations/src/restify.js +9 -13
- package/packages/datadog-instrumentations/src/router.js +12 -11
- package/packages/datadog-instrumentations/src/tedious.js +1 -2
- package/packages/datadog-instrumentations/src/vitest.js +15 -29
- package/packages/datadog-plugin-avsc/src/schema_iterator.js +12 -12
- package/packages/datadog-plugin-aws-sdk/src/base.js +12 -8
- package/packages/datadog-plugin-aws-sdk/src/services/cloudwatchlogs.js +3 -5
- package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +12 -20
- package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +4 -5
- package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +3 -5
- package/packages/datadog-plugin-aws-sdk/src/services/redshift.js +3 -5
- package/packages/datadog-plugin-aws-sdk/src/services/s3.js +3 -5
- package/packages/datadog-plugin-aws-sdk/src/services/sns.js +1 -2
- package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +7 -10
- package/packages/datadog-plugin-cucumber/src/index.js +3 -2
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +2 -1
- package/packages/datadog-plugin-dd-trace-api/src/index.js +2 -1
- package/packages/datadog-plugin-elasticsearch/src/index.js +1 -1
- package/packages/datadog-plugin-google-cloud-vertexai/src/tracing.js +1 -1
- package/packages/datadog-plugin-graphql/src/index.js +3 -2
- package/packages/datadog-plugin-graphql/src/resolve.js +17 -10
- package/packages/datadog-plugin-http/src/client.js +5 -6
- package/packages/datadog-plugin-http2/src/client.js +7 -8
- package/packages/datadog-plugin-jest/src/index.js +3 -2
- package/packages/datadog-plugin-mocha/src/index.js +6 -1
- package/packages/datadog-plugin-mongodb-core/src/index.js +2 -1
- package/packages/datadog-plugin-mysql/src/index.js +11 -0
- package/packages/datadog-plugin-next/src/index.js +1 -1
- package/packages/datadog-plugin-openai/src/tracing.js +2 -4
- package/packages/datadog-plugin-playwright/src/index.js +3 -2
- package/packages/datadog-plugin-protobufjs/src/schema_iterator.js +8 -9
- package/packages/datadog-plugin-redis/src/index.js +1 -3
- package/packages/datadog-plugin-vitest/src/index.js +5 -4
- package/packages/dd-trace/src/appsec/iast/analyzers/analyzers.js +0 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-password-rules.js +0 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-secret-rules.js +0 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-secrets-rules.js +0 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/missing-header-analyzer.js +1 -2
- package/packages/dd-trace/src/appsec/iast/security-controls/index.js +11 -12
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +1 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +2 -1
- package/packages/dd-trace/src/appsec/iast/telemetry/span-tags.js +1 -1
- package/packages/dd-trace/src/appsec/iast/telemetry/verbosity.js +1 -2
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/range-utils.js +10 -11
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +0 -4
- package/packages/dd-trace/src/appsec/iast/vulnerabilities.js +0 -1
- package/packages/dd-trace/src/appsec/index.js +4 -4
- package/packages/dd-trace/src/appsec/reporter.js +5 -7
- package/packages/dd-trace/src/appsec/sdk/set_user.js +2 -2
- package/packages/dd-trace/src/appsec/sdk/track_event.js +3 -3
- package/packages/dd-trace/src/appsec/telemetry/index.js +31 -1
- package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +6 -2
- package/packages/dd-trace/src/azure_metadata.js +8 -3
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +8 -7
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +2 -1
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +2 -1
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/di-logs-writer.js +2 -1
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +2 -1
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +4 -3
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/index.js +7 -6
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +2 -1
- package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +4 -3
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +4 -3
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +2 -1
- package/packages/dd-trace/src/config-helper.js +89 -0
- package/packages/dd-trace/src/config.js +77 -78
- package/packages/dd-trace/src/config_stable.js +7 -4
- package/packages/dd-trace/src/datastreams/fnv.js +1 -1
- package/packages/dd-trace/src/datastreams/schemas/schema_builder.js +6 -6
- package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +1 -2
- package/packages/dd-trace/src/debugger/devtools_client/condition.js +1 -2
- package/packages/dd-trace/src/debugger/devtools_client/index.js +2 -1
- package/packages/dd-trace/src/debugger/devtools_client/send.js +3 -2
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/collector.js +1 -2
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/processor.js +3 -4
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/redaction.js +1 -1
- package/packages/dd-trace/src/debugger/index.js +1 -0
- package/packages/dd-trace/src/dogstatsd.js +2 -2
- package/packages/dd-trace/src/encode/0.4.js +5 -2
- package/packages/dd-trace/src/encode/0.5.js +3 -5
- package/packages/dd-trace/src/encode/agentless-ci-visibility.js +5 -5
- package/packages/dd-trace/src/exporter.js +2 -1
- package/packages/dd-trace/src/exporters/common/docker.js +3 -2
- package/packages/dd-trace/src/exporters/common/request.js +4 -1
- package/packages/dd-trace/src/exporters/common/util.js +3 -1
- package/packages/dd-trace/src/id.js +3 -3
- package/packages/dd-trace/src/index.js +4 -3
- package/packages/dd-trace/src/lambda/handler.js +2 -1
- package/packages/dd-trace/src/lambda/index.js +2 -1
- package/packages/dd-trace/src/lambda/runtime/patch.js +3 -2
- package/packages/dd-trace/src/lambda/runtime/ritm.js +3 -2
- package/packages/dd-trace/src/llmobs/constants/tags.js +1 -0
- package/packages/dd-trace/src/llmobs/index.js +21 -5
- package/packages/dd-trace/src/llmobs/noop.js +18 -20
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/index.js +11 -13
- package/packages/dd-trace/src/llmobs/plugins/openai.js +1 -2
- package/packages/dd-trace/src/llmobs/sdk.js +2 -1
- package/packages/dd-trace/src/llmobs/span_processor.js +1 -1
- package/packages/dd-trace/src/llmobs/tagger.js +19 -6
- package/packages/dd-trace/src/llmobs/writers/base.js +1 -1
- package/packages/dd-trace/src/log/index.js +5 -4
- package/packages/dd-trace/src/log/writer.js +1 -2
- package/packages/dd-trace/src/msgpack/encoder.js +3 -3
- package/packages/dd-trace/src/noop/span.js +1 -1
- package/packages/dd-trace/src/opentelemetry/tracer.js +1 -1
- package/packages/dd-trace/src/opentracing/propagation/log.js +4 -5
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +17 -18
- package/packages/dd-trace/src/opentracing/span.js +7 -6
- package/packages/dd-trace/src/payload-tagging/config/index.js +17 -21
- package/packages/dd-trace/src/plugin_manager.js +4 -3
- package/packages/dd-trace/src/plugins/ci_plugin.js +25 -1
- package/packages/dd-trace/src/plugins/plugin.js +1 -1
- package/packages/dd-trace/src/plugins/util/ci.js +7 -7
- package/packages/dd-trace/src/plugins/util/git.js +1 -1
- package/packages/dd-trace/src/plugins/util/llm.js +2 -2
- package/packages/dd-trace/src/plugins/util/stacktrace.js +8 -1
- package/packages/dd-trace/src/plugins/util/test.js +4 -3
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +2 -1
- package/packages/dd-trace/src/plugins/util/web.js +3 -4
- package/packages/dd-trace/src/priority_sampler.js +46 -35
- package/packages/dd-trace/src/profiling/config.js +12 -32
- package/packages/dd-trace/src/profiling/exporter_cli.js +20 -20
- package/packages/dd-trace/src/profiling/exporters/agent.js +1 -1
- package/packages/dd-trace/src/profiling/exporters/event_serializer.js +2 -1
- package/packages/dd-trace/src/profiling/index.js +2 -1
- package/packages/dd-trace/src/profiling/profiler.js +7 -4
- package/packages/dd-trace/src/profiling/ssi-telemetry-mock-profiler.js +3 -1
- package/packages/dd-trace/src/profiling/tagger.js +22 -12
- package/packages/dd-trace/src/proxy.js +2 -1
- package/packages/dd-trace/src/ritm.js +4 -4
- package/packages/dd-trace/src/runtime_metrics/runtime_metrics.js +3 -2
- package/packages/dd-trace/src/sampler.js +10 -2
- package/packages/dd-trace/src/serverless.js +11 -4
- package/packages/dd-trace/src/span_processor.js +2 -1
- package/packages/dd-trace/src/standalone/tracesource.js +1 -2
- package/packages/dd-trace/src/standalone/tracesource_priority_sampler.js +1 -2
- package/packages/dd-trace/src/startup-log.js +5 -17
- package/packages/dd-trace/src/supported-configurations.json +439 -0
- package/packages/dd-trace/src/telemetry/dependencies.js +62 -57
- package/packages/dd-trace/src/telemetry/send-data.js +7 -6
- package/packages/dd-trace/src/telemetry/telemetry.js +12 -25
- package/packages/dd-trace/src/tracer.js +3 -7
- package/packages/dd-trace/src/util.js +0 -5
- package/packages/dd-trace/src/appsec/iast/analyzers/header-injection-analyzer.js +0 -120
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/header-sensitive-analyzer.js +0 -20
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const { addHook, channel
|
|
3
|
+
const { addHook, channel } = require('./helpers/instrument')
|
|
4
4
|
const shimmer = require('../../datadog-shimmer')
|
|
5
5
|
const log = require('../../dd-trace/src/log')
|
|
6
6
|
const {
|
|
@@ -83,8 +83,6 @@ let testManagementAttemptToFixRetries = 0
|
|
|
83
83
|
let isImpactedTestsEnabled = false
|
|
84
84
|
let modifiedTests = {}
|
|
85
85
|
|
|
86
|
-
const sessionAsyncResource = new AsyncResource('bound-anonymous-fn')
|
|
87
|
-
|
|
88
86
|
const testContexts = new WeakMap()
|
|
89
87
|
const originalTestFns = new WeakMap()
|
|
90
88
|
const originalHookFns = new WeakMap()
|
|
@@ -581,19 +579,16 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
|
|
|
581
579
|
}
|
|
582
580
|
}
|
|
583
581
|
if (event.name === 'test_skip' || event.name === 'test_todo') {
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
},
|
|
595
|
-
isDisabled: this.testManagementTestsForThisSuite?.disabled?.includes(getJestTestName(event.test))
|
|
596
|
-
})
|
|
582
|
+
testSkippedCh.publish({
|
|
583
|
+
test: {
|
|
584
|
+
name: getJestTestName(event.test),
|
|
585
|
+
suite: this.testSuite,
|
|
586
|
+
testSourceFile: this.testSourceFile,
|
|
587
|
+
displayName: this.displayName,
|
|
588
|
+
frameworkVersion: jestVersion,
|
|
589
|
+
testStartLine: getTestLineStart(event.test.asyncError, this.testSuite)
|
|
590
|
+
},
|
|
591
|
+
isDisabled: this.testManagementTestsForThisSuite?.disabled?.includes(getJestTestName(event.test))
|
|
597
592
|
})
|
|
598
593
|
}
|
|
599
594
|
}
|
|
@@ -711,9 +706,7 @@ function cliWrapper (cli, jestVersion) {
|
|
|
711
706
|
return runCLI.apply(this, arguments)
|
|
712
707
|
}
|
|
713
708
|
|
|
714
|
-
|
|
715
|
-
libraryConfigurationCh.publish({ onDone })
|
|
716
|
-
})
|
|
709
|
+
libraryConfigurationCh.publish({ onDone })
|
|
717
710
|
|
|
718
711
|
try {
|
|
719
712
|
const { err, libraryConfig } = await configurationPromise
|
|
@@ -737,9 +730,7 @@ function cliWrapper (cli, jestVersion) {
|
|
|
737
730
|
onDone = resolve
|
|
738
731
|
})
|
|
739
732
|
|
|
740
|
-
|
|
741
|
-
knownTestsCh.publish({ onDone })
|
|
742
|
-
})
|
|
733
|
+
knownTestsCh.publish({ onDone })
|
|
743
734
|
|
|
744
735
|
try {
|
|
745
736
|
const { err, knownTests: receivedKnownTests } = await knownTestsPromise
|
|
@@ -760,9 +751,7 @@ function cliWrapper (cli, jestVersion) {
|
|
|
760
751
|
onDone = resolve
|
|
761
752
|
})
|
|
762
753
|
|
|
763
|
-
|
|
764
|
-
skippableSuitesCh.publish({ onDone })
|
|
765
|
-
})
|
|
754
|
+
skippableSuitesCh.publish({ onDone })
|
|
766
755
|
|
|
767
756
|
try {
|
|
768
757
|
const { err, skippableSuites: receivedSkippableSuites } = await skippableSuitesPromise
|
|
@@ -779,9 +768,7 @@ function cliWrapper (cli, jestVersion) {
|
|
|
779
768
|
onDone = resolve
|
|
780
769
|
})
|
|
781
770
|
|
|
782
|
-
|
|
783
|
-
testManagementTestsCh.publish({ onDone })
|
|
784
|
-
})
|
|
771
|
+
testManagementTestsCh.publish({ onDone })
|
|
785
772
|
|
|
786
773
|
try {
|
|
787
774
|
const { err, testManagementTests: receivedTestManagementTests } = await testManagementTestsPromise
|
|
@@ -798,9 +785,7 @@ function cliWrapper (cli, jestVersion) {
|
|
|
798
785
|
onDone = resolve
|
|
799
786
|
})
|
|
800
787
|
|
|
801
|
-
|
|
802
|
-
impactedTestsCh.publish({ onDone })
|
|
803
|
-
})
|
|
788
|
+
impactedTestsCh.publish({ onDone })
|
|
804
789
|
|
|
805
790
|
try {
|
|
806
791
|
const { err, modifiedTests: receivedModifiedTests } = await impactedTestsPromise
|
|
@@ -813,9 +798,7 @@ function cliWrapper (cli, jestVersion) {
|
|
|
813
798
|
}
|
|
814
799
|
|
|
815
800
|
const processArgv = process.argv.slice(2).join(' ')
|
|
816
|
-
|
|
817
|
-
testSessionStartCh.publish({ command: `jest ${processArgv}`, frameworkVersion: jestVersion })
|
|
818
|
-
})
|
|
801
|
+
testSessionStartCh.publish({ command: `jest ${processArgv}`, frameworkVersion: jestVersion })
|
|
819
802
|
|
|
820
803
|
const result = await runCLI.apply(this, arguments)
|
|
821
804
|
|
|
@@ -864,23 +847,22 @@ function cliWrapper (cli, jestVersion) {
|
|
|
864
847
|
}, FLUSH_TIMEOUT).unref()
|
|
865
848
|
})
|
|
866
849
|
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
onDone
|
|
882
|
-
})
|
|
850
|
+
testSessionFinishCh.publish({
|
|
851
|
+
status,
|
|
852
|
+
isSuitesSkipped,
|
|
853
|
+
isSuitesSkippingEnabled,
|
|
854
|
+
isCodeCoverageEnabled,
|
|
855
|
+
testCodeCoverageLinesTotal,
|
|
856
|
+
numSkippedSuites,
|
|
857
|
+
hasUnskippableSuites,
|
|
858
|
+
hasForcedToRunSuites,
|
|
859
|
+
error,
|
|
860
|
+
isEarlyFlakeDetectionEnabled,
|
|
861
|
+
isEarlyFlakeDetectionFaulty,
|
|
862
|
+
isTestManagementTestsEnabled,
|
|
863
|
+
onDone
|
|
883
864
|
})
|
|
865
|
+
|
|
884
866
|
const waitingResult = await Promise.race([flushPromise, timeoutPromise])
|
|
885
867
|
|
|
886
868
|
if (waitingResult === 'timeout') {
|
|
@@ -1006,45 +988,40 @@ function jestAdapterWrapper (jestAdapter, jestVersion) {
|
|
|
1006
988
|
if (!environment) {
|
|
1007
989
|
return adapter.apply(this, arguments)
|
|
1008
990
|
}
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
}
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
status = 'fail'
|
|
1025
|
-
}
|
|
991
|
+
testSuiteStartCh.publish({
|
|
992
|
+
testSuite: environment.testSuite,
|
|
993
|
+
testEnvironmentOptions: environment.testEnvironmentOptions,
|
|
994
|
+
testSourceFile: environment.testSourceFile,
|
|
995
|
+
displayName: environment.displayName,
|
|
996
|
+
frameworkVersion: jestVersion
|
|
997
|
+
})
|
|
998
|
+
return adapter.apply(this, arguments).then(suiteResults => {
|
|
999
|
+
const { numFailingTests, skipped, failureMessage: errorMessage } = suiteResults
|
|
1000
|
+
let status = 'pass'
|
|
1001
|
+
if (skipped) {
|
|
1002
|
+
status = 'skipped'
|
|
1003
|
+
} else if (numFailingTests !== 0) {
|
|
1004
|
+
status = 'fail'
|
|
1005
|
+
}
|
|
1026
1006
|
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1007
|
+
/**
|
|
1008
|
+
* Child processes do not each request ITR configuration, so the jest's parent process
|
|
1009
|
+
* needs to pass them the configuration. This is done via _ddTestCodeCoverageEnabled, which
|
|
1010
|
+
* controls whether coverage is reported.
|
|
1011
|
+
*/
|
|
1012
|
+
if (environment.testEnvironmentOptions?._ddTestCodeCoverageEnabled) {
|
|
1013
|
+
const root = environment.repositoryRoot || environment.rootDir
|
|
1034
1014
|
|
|
1035
|
-
|
|
1036
|
-
|
|
1015
|
+
const coverageFiles = getCoveredFilenamesFromCoverage(environment.global.__coverage__)
|
|
1016
|
+
.map(filename => getTestSuitePath(filename, root))
|
|
1037
1017
|
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
testSuiteFinishCh.publish({ status: 'fail', error })
|
|
1046
|
-
throw error
|
|
1047
|
-
})
|
|
1018
|
+
testSuiteCodeCoverageCh.publish({ coverageFiles, testSuite: environment.testSourceFile })
|
|
1019
|
+
}
|
|
1020
|
+
testSuiteFinishCh.publish({ status, errorMessage })
|
|
1021
|
+
return suiteResults
|
|
1022
|
+
}).catch(error => {
|
|
1023
|
+
testSuiteFinishCh.publish({ status: 'fail', error })
|
|
1024
|
+
throw error
|
|
1048
1025
|
})
|
|
1049
1026
|
})
|
|
1050
1027
|
if (jestAdapter.default) {
|
|
@@ -1064,9 +1041,7 @@ addHook({
|
|
|
1064
1041
|
|
|
1065
1042
|
function configureTestEnvironment (readConfigsResult) {
|
|
1066
1043
|
const { configs } = readConfigsResult
|
|
1067
|
-
|
|
1068
|
-
testSessionConfigurationCh.publish(configs.map(config => config.testEnvironmentOptions))
|
|
1069
|
-
})
|
|
1044
|
+
testSessionConfigurationCh.publish(configs.map(config => config.testEnvironmentOptions))
|
|
1070
1045
|
// We can't directly use isCodeCoverageEnabled when reporting coverage in `jestAdapterWrapper`
|
|
1071
1046
|
// because `jestAdapterWrapper` runs in a different process. We have to go through `testEnvironmentOptions`
|
|
1072
1047
|
configs.forEach(config => {
|
|
@@ -1315,21 +1290,15 @@ addHook({
|
|
|
1315
1290
|
shimmer.wrap(ChildProcessWorker.prototype, '_onMessage', _onMessage => function () {
|
|
1316
1291
|
const [code, data] = arguments[0]
|
|
1317
1292
|
if (code === JEST_WORKER_TRACE_PAYLOAD_CODE) { // datadog trace payload
|
|
1318
|
-
|
|
1319
|
-
workerReportTraceCh.publish(data)
|
|
1320
|
-
})
|
|
1293
|
+
workerReportTraceCh.publish(data)
|
|
1321
1294
|
return
|
|
1322
1295
|
}
|
|
1323
1296
|
if (code === JEST_WORKER_COVERAGE_PAYLOAD_CODE) { // datadog coverage payload
|
|
1324
|
-
|
|
1325
|
-
workerReportCoverageCh.publish(data)
|
|
1326
|
-
})
|
|
1297
|
+
workerReportCoverageCh.publish(data)
|
|
1327
1298
|
return
|
|
1328
1299
|
}
|
|
1329
1300
|
if (code === JEST_WORKER_LOGS_PAYLOAD_CODE) { // datadog logs payload
|
|
1330
|
-
|
|
1331
|
-
workerReportLogsCh.publish(data)
|
|
1332
|
-
})
|
|
1301
|
+
workerReportLogsCh.publish(data)
|
|
1333
1302
|
return
|
|
1334
1303
|
}
|
|
1335
1304
|
return _onMessage.apply(this, arguments)
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const { channel, addHook
|
|
3
|
+
const { channel, addHook } = require('./helpers/instrument')
|
|
4
4
|
|
|
5
5
|
const shimmer = require('../../datadog-shimmer')
|
|
6
6
|
|
|
7
7
|
const commandAddCh = channel('apm:mariadb:command:add')
|
|
8
|
+
const connectionStartCh = channel('apm:mariadb:connection:start')
|
|
9
|
+
const connectionFinishCh = channel('apm:mariadb:connection:finish')
|
|
8
10
|
const startCh = channel('apm:mariadb:query:start')
|
|
9
11
|
const finishCh = channel('apm:mariadb:query:finish')
|
|
10
12
|
const errorCh = channel('apm:mariadb:query:error')
|
|
@@ -82,7 +84,7 @@ function createWrapQueryCallback (options) {
|
|
|
82
84
|
const ctx = { sql, conf: options }
|
|
83
85
|
|
|
84
86
|
if (typeof cb !== 'function') {
|
|
85
|
-
arguments.length
|
|
87
|
+
arguments.length += 1
|
|
86
88
|
}
|
|
87
89
|
|
|
88
90
|
arguments[arguments.length - 1] = shimmer.wrapFunction(cb, cb => function (err) {
|
|
@@ -135,8 +137,13 @@ function wrapPoolGetConnectionMethod (getConnection) {
|
|
|
135
137
|
const cb = arguments[arguments.length - 1]
|
|
136
138
|
if (typeof cb !== 'function') return getConnection.apply(this, arguments)
|
|
137
139
|
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
+
const ctx = {}
|
|
141
|
+
|
|
142
|
+
arguments[arguments.length - 1] = function () {
|
|
143
|
+
return connectionFinishCh.runStores(ctx, cb, this, ...arguments)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
connectionStartCh.publish(ctx)
|
|
140
147
|
|
|
141
148
|
return getConnection.apply(this, arguments)
|
|
142
149
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const { createCoverageMap } = require('istanbul-lib-coverage')
|
|
4
|
-
const { addHook, channel
|
|
4
|
+
const { addHook, channel } = require('../helpers/instrument')
|
|
5
5
|
const shimmer = require('../../../datadog-shimmer')
|
|
6
6
|
const { isMarkedAsUnskippable } = require('../../../datadog-plugin-jest/src/util')
|
|
7
7
|
const log = require('../../../dd-trace/src/log')
|
|
8
|
+
const { getEnvironmentVariable } = require('../../../dd-trace/src/config-helper')
|
|
8
9
|
const {
|
|
9
10
|
getTestSuitePath,
|
|
10
11
|
MOCHA_WORKER_TRACE_PAYLOAD_CODE,
|
|
@@ -37,7 +38,6 @@ const {
|
|
|
37
38
|
|
|
38
39
|
require('./common')
|
|
39
40
|
|
|
40
|
-
const testSessionAsyncResource = new AsyncResource('bound-anonymous-fn')
|
|
41
41
|
const patched = new WeakSet()
|
|
42
42
|
|
|
43
43
|
const unskippableSuites = []
|
|
@@ -65,6 +65,8 @@ const testSuiteCodeCoverageCh = channel('ci:mocha:test-suite:code-coverage')
|
|
|
65
65
|
const libraryConfigurationCh = channel('ci:mocha:library-configuration')
|
|
66
66
|
const knownTestsCh = channel('ci:mocha:known-tests')
|
|
67
67
|
const skippableSuitesCh = channel('ci:mocha:test-suite:skippable')
|
|
68
|
+
const mochaGlobalRunCh = channel('ci:mocha:global:run')
|
|
69
|
+
|
|
68
70
|
const testManagementTestsCh = channel('ci:mocha:test-management-tests')
|
|
69
71
|
const impactedTestsCh = channel('ci:mocha:modified-tests')
|
|
70
72
|
const workerReportTraceCh = channel('ci:mocha:worker-report:trace')
|
|
@@ -100,18 +102,18 @@ function getFilteredSuites (originalSuites) {
|
|
|
100
102
|
}
|
|
101
103
|
|
|
102
104
|
function getOnStartHandler (isParallel, frameworkVersion) {
|
|
103
|
-
return
|
|
105
|
+
return function () {
|
|
104
106
|
const processArgv = process.argv.slice(2).join(' ')
|
|
105
107
|
const command = `mocha ${processArgv}`
|
|
106
108
|
testSessionStartCh.publish({ command, frameworkVersion })
|
|
107
109
|
if (!isParallel && skippedSuites.length) {
|
|
108
110
|
itrSkippedSuitesCh.publish({ skippedSuites, frameworkVersion })
|
|
109
111
|
}
|
|
110
|
-
}
|
|
112
|
+
}
|
|
111
113
|
}
|
|
112
114
|
|
|
113
115
|
function getOnEndHandler (isParallel) {
|
|
114
|
-
return
|
|
116
|
+
return function () {
|
|
115
117
|
let status = 'pass'
|
|
116
118
|
let error
|
|
117
119
|
if (this.stats) {
|
|
@@ -196,47 +198,12 @@ function getOnEndHandler (isParallel) {
|
|
|
196
198
|
isTestManagementEnabled: config.isTestManagementTestsEnabled,
|
|
197
199
|
isParallel
|
|
198
200
|
})
|
|
199
|
-
}
|
|
201
|
+
}
|
|
200
202
|
}
|
|
201
203
|
|
|
202
204
|
function getExecutionConfiguration (runner, isParallel, onFinishRequest) {
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
const onReceivedTestManagementTests = ({ err, testManagementTests: receivedTestManagementTests }) => {
|
|
206
|
-
if (err) {
|
|
207
|
-
config.testManagementTests = {}
|
|
208
|
-
config.isTestManagementTestsEnabled = false
|
|
209
|
-
config.testManagementAttemptToFixRetries = 0
|
|
210
|
-
} else {
|
|
211
|
-
config.testManagementTests = receivedTestManagementTests
|
|
212
|
-
}
|
|
213
|
-
if (config.isImpactedTestsEnabled) {
|
|
214
|
-
impactedTestsCh.publish({
|
|
215
|
-
onDone: mochaRunAsyncResource.bind(onReceivedImpactedTests)
|
|
216
|
-
})
|
|
217
|
-
} else if (config.isSuitesSkippingEnabled) {
|
|
218
|
-
skippableSuitesCh.publish({
|
|
219
|
-
onDone: mochaRunAsyncResource.bind(onReceivedSkippableSuites)
|
|
220
|
-
})
|
|
221
|
-
} else {
|
|
222
|
-
onFinishRequest()
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
const onReceivedImpactedTests = ({ err, modifiedTests: receivedModifiedTests }) => {
|
|
227
|
-
if (err) {
|
|
228
|
-
config.modifiedTests = []
|
|
229
|
-
config.isImpactedTestsEnabled = false
|
|
230
|
-
} else {
|
|
231
|
-
config.modifiedTests = receivedModifiedTests
|
|
232
|
-
}
|
|
233
|
-
if (config.isSuitesSkippingEnabled) {
|
|
234
|
-
skippableSuitesCh.publish({
|
|
235
|
-
onDone: mochaRunAsyncResource.bind(onReceivedSkippableSuites)
|
|
236
|
-
})
|
|
237
|
-
} else {
|
|
238
|
-
onFinishRequest()
|
|
239
|
-
}
|
|
205
|
+
const ctx = {
|
|
206
|
+
isParallel
|
|
240
207
|
}
|
|
241
208
|
|
|
242
209
|
const onReceivedSkippableSuites = ({ err, skippableSuites, itrCorrelationId: responseItrCorrelationId }) => {
|
|
@@ -260,7 +227,47 @@ function getExecutionConfiguration (runner, isParallel, onFinishRequest) {
|
|
|
260
227
|
|
|
261
228
|
skippedSuites = [...filteredSuites.skippedSuites]
|
|
262
229
|
|
|
263
|
-
|
|
230
|
+
mochaGlobalRunCh.runStores(ctx, () => {
|
|
231
|
+
onFinishRequest()
|
|
232
|
+
})
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const onReceivedImpactedTests = ({ err, modifiedTests: receivedModifiedTests }) => {
|
|
236
|
+
if (err) {
|
|
237
|
+
config.modifiedTests = []
|
|
238
|
+
config.isImpactedTestsEnabled = false
|
|
239
|
+
} else {
|
|
240
|
+
config.modifiedTests = receivedModifiedTests
|
|
241
|
+
}
|
|
242
|
+
if (config.isSuitesSkippingEnabled) {
|
|
243
|
+
ctx.onDone = onReceivedSkippableSuites
|
|
244
|
+
skippableSuitesCh.runStores(ctx, () => {})
|
|
245
|
+
} else {
|
|
246
|
+
mochaGlobalRunCh.runStores(ctx, () => {
|
|
247
|
+
onFinishRequest()
|
|
248
|
+
})
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
const onReceivedTestManagementTests = ({ err, testManagementTests: receivedTestManagementTests }) => {
|
|
253
|
+
if (err) {
|
|
254
|
+
config.testManagementTests = {}
|
|
255
|
+
config.isTestManagementTestsEnabled = false
|
|
256
|
+
config.testManagementAttemptToFixRetries = 0
|
|
257
|
+
} else {
|
|
258
|
+
config.testManagementTests = receivedTestManagementTests
|
|
259
|
+
}
|
|
260
|
+
if (config.isImpactedTestsEnabled) {
|
|
261
|
+
ctx.onDone = onReceivedImpactedTests
|
|
262
|
+
impactedTestsCh.runStores(ctx, () => {})
|
|
263
|
+
} else if (config.isSuitesSkippingEnabled) {
|
|
264
|
+
ctx.onDone = onReceivedSkippableSuites
|
|
265
|
+
skippableSuitesCh.runStores(ctx, () => {})
|
|
266
|
+
} else {
|
|
267
|
+
mochaGlobalRunCh.runStores(ctx, () => {
|
|
268
|
+
onFinishRequest()
|
|
269
|
+
})
|
|
270
|
+
}
|
|
264
271
|
}
|
|
265
272
|
|
|
266
273
|
const onReceivedKnownTests = ({ err, knownTests }) => {
|
|
@@ -272,27 +279,27 @@ function getExecutionConfiguration (runner, isParallel, onFinishRequest) {
|
|
|
272
279
|
config.knownTests = knownTests
|
|
273
280
|
}
|
|
274
281
|
if (config.isTestManagementTestsEnabled) {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
})
|
|
282
|
+
ctx.onDone = onReceivedTestManagementTests
|
|
283
|
+
testManagementTestsCh.runStores(ctx, () => {})
|
|
278
284
|
} if (config.isImpactedTestsEnabled) {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
})
|
|
285
|
+
ctx.onDone = onReceivedImpactedTests
|
|
286
|
+
impactedTestsCh.runStores(ctx, () => {})
|
|
282
287
|
} else if (config.isSuitesSkippingEnabled) {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
})
|
|
288
|
+
ctx.onDone = onReceivedSkippableSuites
|
|
289
|
+
skippableSuitesCh.runStores(ctx, () => {})
|
|
286
290
|
} else {
|
|
287
|
-
|
|
291
|
+
mochaGlobalRunCh.runStores(ctx, () => {
|
|
292
|
+
onFinishRequest()
|
|
293
|
+
})
|
|
288
294
|
}
|
|
289
295
|
}
|
|
290
296
|
|
|
291
297
|
const onReceivedConfiguration = ({ err, libraryConfig }) => {
|
|
292
298
|
if (err || !skippableSuitesCh.hasSubscribers || !knownTestsCh.hasSubscribers) {
|
|
293
|
-
return
|
|
299
|
+
return mochaGlobalRunCh.runStores(ctx, () => {
|
|
300
|
+
onFinishRequest()
|
|
301
|
+
})
|
|
294
302
|
}
|
|
295
|
-
|
|
296
303
|
config.isEarlyFlakeDetectionEnabled = libraryConfig.isEarlyFlakeDetectionEnabled
|
|
297
304
|
config.earlyFlakeDetectionNumRetries = libraryConfig.earlyFlakeDetectionNumRetries
|
|
298
305
|
config.earlyFlakeDetectionFaultyThreshold = libraryConfig.earlyFlakeDetectionFaultyThreshold
|
|
@@ -306,30 +313,27 @@ function getExecutionConfiguration (runner, isParallel, onFinishRequest) {
|
|
|
306
313
|
config.flakyTestRetriesCount = !isParallel && libraryConfig.flakyTestRetriesCount
|
|
307
314
|
|
|
308
315
|
if (config.isKnownTestsEnabled) {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
})
|
|
316
|
+
ctx.onDone = onReceivedKnownTests
|
|
317
|
+
knownTestsCh.runStores(ctx, () => {})
|
|
312
318
|
} else if (config.isTestManagementTestsEnabled) {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
})
|
|
319
|
+
ctx.onDone = onReceivedTestManagementTests
|
|
320
|
+
testManagementTestsCh.runStores(ctx, () => {})
|
|
316
321
|
} else if (config.isImpactedTestsEnabled) {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
})
|
|
322
|
+
ctx.onDone = onReceivedImpactedTests
|
|
323
|
+
impactedTestsCh.runStores(ctx, () => {})
|
|
320
324
|
} else if (config.isSuitesSkippingEnabled) {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
})
|
|
325
|
+
ctx.onDone = onReceivedSkippableSuites
|
|
326
|
+
skippableSuitesCh.runStores(ctx, () => {})
|
|
324
327
|
} else {
|
|
325
|
-
|
|
328
|
+
mochaGlobalRunCh.runStores(ctx, () => {
|
|
329
|
+
onFinishRequest()
|
|
330
|
+
})
|
|
326
331
|
}
|
|
327
332
|
}
|
|
328
333
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
})
|
|
334
|
+
ctx.onDone = onReceivedConfiguration
|
|
335
|
+
|
|
336
|
+
libraryConfigurationCh.runStores(ctx, () => {})
|
|
333
337
|
}
|
|
334
338
|
|
|
335
339
|
// In this hook we delay the execution with options.delay to grab library configuration,
|
|
@@ -342,7 +346,7 @@ addHook({
|
|
|
342
346
|
}, (Mocha) => {
|
|
343
347
|
shimmer.wrap(Mocha.prototype, 'run', run => function () {
|
|
344
348
|
// Workers do not need to request any data, just run the tests
|
|
345
|
-
if (!testFinishCh.hasSubscribers ||
|
|
349
|
+
if (!testFinishCh.hasSubscribers || getEnvironmentVariable('MOCHA_WORKER_ID') || this.options.parallel) {
|
|
346
350
|
return run.apply(this, arguments)
|
|
347
351
|
}
|
|
348
352
|
|
|
@@ -517,7 +521,7 @@ addHook({
|
|
|
517
521
|
if (ctx) {
|
|
518
522
|
testSuiteFinishCh.publish({ status, ...ctx.currentStore }, () => {})
|
|
519
523
|
} else {
|
|
520
|
-
log.warn(() => `No
|
|
524
|
+
log.warn(() => `No ctx found for suite ${suite.file}`)
|
|
521
525
|
}
|
|
522
526
|
})
|
|
523
527
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const { channel, addHook
|
|
3
|
+
const { channel, addHook } = require('./helpers/instrument')
|
|
4
4
|
const shimmer = require('../../datadog-shimmer')
|
|
5
5
|
|
|
6
6
|
addHook({ name: 'mysql', file: 'lib/Connection.js', versions: ['>=2'] }, Connection => {
|
|
@@ -57,11 +57,20 @@ addHook({ name: 'mysql', file: 'lib/Connection.js', versions: ['>=2'] }, Connect
|
|
|
57
57
|
})
|
|
58
58
|
|
|
59
59
|
addHook({ name: 'mysql', file: 'lib/Pool.js', versions: ['>=2'] }, Pool => {
|
|
60
|
+
const connectionStartCh = channel('apm:mysql:connection:start')
|
|
61
|
+
const connectionFinishCh = channel('apm:mysql:connection:finish')
|
|
60
62
|
const startPoolQueryCh = channel('datadog:mysql:pool:query:start')
|
|
61
63
|
const finishPoolQueryCh = channel('datadog:mysql:pool:query:finish')
|
|
62
64
|
|
|
63
65
|
shimmer.wrap(Pool.prototype, 'getConnection', getConnection => function (cb) {
|
|
64
|
-
arguments[0] =
|
|
66
|
+
arguments[0] = function () {
|
|
67
|
+
return connectionFinishCh.runStores(ctx, cb, this, ...arguments)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const ctx = {}
|
|
71
|
+
|
|
72
|
+
connectionStartCh.publish(ctx)
|
|
73
|
+
|
|
65
74
|
return getConnection.apply(this, arguments)
|
|
66
75
|
})
|
|
67
76
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const { addHook, channel } = require('./helpers/instrument')
|
|
2
2
|
const shimmer = require('../../datadog-shimmer')
|
|
3
|
+
const { getEnvironmentVariable } = require('../../dd-trace/src/config-helper')
|
|
3
4
|
|
|
4
5
|
const codeCoverageWrapCh = channel('ci:nyc:wrap')
|
|
5
6
|
|
|
@@ -11,7 +12,7 @@ addHook({
|
|
|
11
12
|
shimmer.wrap(nycPackage.prototype, 'wrap', wrap => function () {
|
|
12
13
|
// Only relevant if the config `all` is set to true
|
|
13
14
|
try {
|
|
14
|
-
if (JSON.parse(
|
|
15
|
+
if (JSON.parse(getEnvironmentVariable('NYC_CONFIG')).all) {
|
|
15
16
|
codeCoverageWrapCh.publish(this)
|
|
16
17
|
}
|
|
17
18
|
} catch {
|
|
@@ -187,12 +187,12 @@ function addStreamedChunk (content, chunk) {
|
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
-
function convertBufferstoObjects (chunks
|
|
190
|
+
function convertBufferstoObjects (chunks) {
|
|
191
191
|
return Buffer
|
|
192
192
|
.concat(chunks) // combine the buffers
|
|
193
193
|
.toString() // stringify
|
|
194
194
|
.split(/(?=data:)/) // split on "data:"
|
|
195
|
-
.map(chunk => chunk.
|
|
195
|
+
.map(chunk => chunk.replaceAll('\n', '').slice(6)) // remove newlines and 'data: ' from the front
|
|
196
196
|
.slice(0, -1) // remove the last [DONE] message
|
|
197
197
|
.map(JSON.parse) // parse all of the returned objects
|
|
198
198
|
}
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
const { addHook } = require('./helpers/instrument')
|
|
4
4
|
const shimmer = require('../../datadog-shimmer')
|
|
5
5
|
const tracer = require('../../dd-trace')
|
|
6
|
+
const { getEnvironmentVariable } = require('../../dd-trace/src/config-helper')
|
|
6
7
|
|
|
7
|
-
const otelSdkEnabled =
|
|
8
|
-
|
|
9
|
-
? !
|
|
8
|
+
const otelSdkEnabled = getEnvironmentVariable('DD_TRACE_OTEL_ENABLED') ||
|
|
9
|
+
getEnvironmentVariable('OTEL_SDK_DISABLED')
|
|
10
|
+
? !getEnvironmentVariable('OTEL_SDK_DISABLED')
|
|
10
11
|
: undefined
|
|
11
12
|
|
|
12
13
|
if (otelSdkEnabled) {
|