dd-trace 3.14.1 → 3.16.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/LICENSE-3rdparty.csv +2 -2
- package/README.md +9 -5
- package/ci/init.js +9 -1
- package/ext/exporters.d.ts +2 -1
- package/ext/exporters.js +2 -1
- package/index.d.ts +36 -3
- package/package.json +21 -19
- package/packages/datadog-instrumentations/src/cucumber.js +80 -3
- package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +100 -27
- package/packages/datadog-instrumentations/src/helpers/hooks.js +1 -0
- package/packages/datadog-instrumentations/src/jest.js +35 -3
- package/packages/datadog-instrumentations/src/ldapjs.js +12 -2
- package/packages/datadog-instrumentations/src/mariadb.js +130 -11
- package/packages/datadog-instrumentations/src/mocha.js +30 -6
- package/packages/datadog-instrumentations/src/mongodb-core.js +8 -2
- package/packages/datadog-instrumentations/src/mongoose.js +1 -1
- package/packages/datadog-instrumentations/src/next.js +33 -4
- package/packages/datadog-instrumentations/src/playwright.js +42 -13
- package/packages/datadog-plugin-amqp10/src/consumer.js +1 -1
- package/packages/datadog-plugin-amqp10/src/index.js +1 -1
- package/packages/datadog-plugin-amqp10/src/producer.js +3 -2
- package/packages/datadog-plugin-amqplib/src/client.js +3 -2
- package/packages/datadog-plugin-amqplib/src/consumer.js +1 -1
- package/packages/datadog-plugin-amqplib/src/index.js +1 -1
- package/packages/datadog-plugin-amqplib/src/producer.js +3 -2
- package/packages/datadog-plugin-aws-sdk/src/base.js +7 -2
- package/packages/datadog-plugin-aws-sdk/src/index.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/cloudwatchlogs.js +2 -0
- package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +2 -0
- package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +2 -0
- package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +2 -0
- package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +2 -0
- package/packages/datadog-plugin-aws-sdk/src/services/redshift.js +2 -0
- package/packages/datadog-plugin-aws-sdk/src/services/s3.js +2 -0
- package/packages/datadog-plugin-aws-sdk/src/services/sns.js +2 -0
- package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +2 -0
- package/packages/datadog-plugin-bunyan/src/index.js +1 -1
- package/packages/datadog-plugin-cassandra-driver/src/index.js +3 -2
- package/packages/datadog-plugin-connect/src/index.js +1 -1
- package/packages/datadog-plugin-couchbase/src/index.js +1 -1
- package/packages/datadog-plugin-cucumber/src/index.js +33 -6
- package/packages/datadog-plugin-cypress/src/index.js +1 -1
- package/packages/datadog-plugin-cypress/src/plugin.js +40 -33
- package/packages/datadog-plugin-dns/src/index.js +1 -1
- package/packages/datadog-plugin-dns/src/lookup.js +1 -1
- package/packages/datadog-plugin-dns/src/lookup_service.js +1 -1
- package/packages/datadog-plugin-dns/src/resolve.js +1 -1
- package/packages/datadog-plugin-dns/src/reverse.js +1 -1
- package/packages/datadog-plugin-elasticsearch/src/index.js +1 -1
- package/packages/datadog-plugin-express/src/index.js +1 -1
- package/packages/datadog-plugin-fastify/src/index.js +1 -1
- package/packages/datadog-plugin-find-my-way/src/index.js +1 -1
- package/packages/datadog-plugin-fs/src/index.js +1 -1
- package/packages/datadog-plugin-google-cloud-pubsub/src/client.js +5 -5
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +1 -1
- package/packages/datadog-plugin-google-cloud-pubsub/src/index.js +1 -1
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +7 -6
- package/packages/datadog-plugin-graphql/src/execute.js +1 -1
- package/packages/datadog-plugin-graphql/src/index.js +1 -1
- package/packages/datadog-plugin-graphql/src/parse.js +1 -1
- package/packages/datadog-plugin-graphql/src/resolve.js +1 -1
- package/packages/datadog-plugin-graphql/src/validate.js +1 -1
- package/packages/datadog-plugin-grpc/src/client.js +1 -1
- package/packages/datadog-plugin-grpc/src/index.js +1 -1
- package/packages/datadog-plugin-grpc/src/server.js +1 -1
- package/packages/datadog-plugin-hapi/src/index.js +1 -1
- package/packages/datadog-plugin-http/src/client.js +2 -2
- package/packages/datadog-plugin-http/src/index.js +1 -1
- package/packages/datadog-plugin-http/src/server.js +3 -3
- package/packages/datadog-plugin-http2/src/client.js +4 -3
- package/packages/datadog-plugin-http2/src/index.js +1 -1
- package/packages/datadog-plugin-http2/src/server.js +3 -3
- package/packages/datadog-plugin-ioredis/src/index.js +1 -1
- package/packages/datadog-plugin-jest/src/index.js +53 -19
- package/packages/datadog-plugin-kafkajs/src/consumer.js +1 -1
- package/packages/datadog-plugin-kafkajs/src/index.js +1 -1
- package/packages/datadog-plugin-kafkajs/src/producer.js +1 -1
- package/packages/datadog-plugin-koa/src/index.js +1 -1
- package/packages/datadog-plugin-mariadb/src/index.js +18 -1
- package/packages/datadog-plugin-memcached/src/index.js +3 -2
- package/packages/datadog-plugin-microgateway-core/src/index.js +1 -1
- package/packages/datadog-plugin-mocha/src/index.js +13 -9
- package/packages/datadog-plugin-moleculer/src/client.js +1 -1
- package/packages/datadog-plugin-moleculer/src/index.js +1 -1
- package/packages/datadog-plugin-moleculer/src/server.js +1 -1
- package/packages/datadog-plugin-mongodb-core/src/index.js +1 -1
- package/packages/datadog-plugin-mysql/src/index.js +3 -2
- package/packages/datadog-plugin-mysql2/src/index.js +1 -1
- package/packages/datadog-plugin-net/src/index.js +9 -75
- package/packages/datadog-plugin-net/src/ipc.js +1 -1
- package/packages/datadog-plugin-net/src/tcp.js +3 -2
- package/packages/datadog-plugin-next/src/index.js +3 -3
- package/packages/datadog-plugin-opensearch/src/index.js +1 -1
- package/packages/datadog-plugin-oracledb/src/index.js +3 -2
- package/packages/datadog-plugin-paperplane/src/index.js +1 -1
- package/packages/datadog-plugin-paperplane/src/logger.js +1 -1
- package/packages/datadog-plugin-paperplane/src/server.js +1 -1
- package/packages/datadog-plugin-pg/src/index.js +3 -2
- package/packages/datadog-plugin-pino/src/index.js +1 -1
- package/packages/datadog-plugin-playwright/src/index.js +5 -4
- package/packages/datadog-plugin-redis/src/index.js +3 -2
- package/packages/datadog-plugin-restify/src/index.js +1 -1
- package/packages/datadog-plugin-rhea/src/consumer.js +1 -1
- package/packages/datadog-plugin-rhea/src/index.js +1 -1
- package/packages/datadog-plugin-rhea/src/producer.js +3 -2
- package/packages/datadog-plugin-router/src/index.js +8 -8
- package/packages/datadog-plugin-sharedb/src/index.js +1 -1
- package/packages/datadog-plugin-tedious/src/index.js +3 -2
- package/packages/datadog-plugin-web/src/index.js +1 -1
- package/packages/datadog-plugin-winston/src/index.js +1 -1
- package/packages/dd-trace/src/appsec/addresses.js +3 -1
- package/packages/dd-trace/src/appsec/blocking.js +35 -9
- package/packages/dd-trace/src/appsec/gateway/engine/runner.js +2 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/analyzers.js +2 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/vulnerability-analyzer.js +2 -2
- package/packages/dd-trace/src/appsec/iast/iast-context.js +6 -2
- package/packages/dd-trace/src/appsec/iast/iast-log.js +111 -0
- package/packages/dd-trace/src/appsec/iast/index.js +10 -6
- package/packages/dd-trace/src/appsec/iast/path-line.js +3 -6
- package/packages/dd-trace/src/appsec/iast/taint-tracking/index.js +2 -0
- package/packages/dd-trace/src/appsec/iast/taint-tracking/operations.js +2 -0
- package/packages/dd-trace/src/appsec/iast/taint-tracking/origin-types.js +2 -0
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +2 -0
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +9 -4
- package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +5 -3
- package/packages/dd-trace/src/appsec/iast/telemetry/log_collector.js +96 -0
- package/packages/dd-trace/src/appsec/iast/telemetry/logs.js +87 -0
- package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +27 -2
- package/packages/dd-trace/src/appsec/index.js +4 -4
- package/packages/dd-trace/src/appsec/recommended.json +76 -75
- package/packages/dd-trace/src/appsec/remote_config/capabilities.js +2 -1
- package/packages/dd-trace/src/appsec/remote_config/index.js +3 -0
- package/packages/dd-trace/src/appsec/sdk/index.js +19 -1
- package/packages/dd-trace/src/appsec/sdk/noop.js +6 -0
- package/packages/dd-trace/src/appsec/sdk/set_user.js +30 -0
- package/packages/dd-trace/src/appsec/sdk/track_event.js +2 -2
- package/packages/dd-trace/src/appsec/sdk/user_blocking.js +73 -0
- package/packages/dd-trace/src/ci-visibility/encode/json-encoder.js +27 -0
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +17 -9
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +14 -8
- package/packages/dd-trace/src/ci-visibility/exporters/jest-worker/index.js +33 -0
- package/packages/dd-trace/src/ci-visibility/exporters/jest-worker/writer.js +37 -0
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-itr-configuration.js +12 -4
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +12 -4
- package/packages/dd-trace/src/config.js +24 -5
- package/packages/dd-trace/src/constants.js +2 -1
- package/packages/dd-trace/src/datastreams/encoding.js +80 -0
- package/packages/dd-trace/src/exporter.js +7 -9
- package/packages/dd-trace/src/exporters/common/agents.js +42 -0
- package/packages/dd-trace/src/exporters/common/docker.js +4 -1
- package/packages/dd-trace/src/exporters/common/request.js +1 -4
- package/packages/dd-trace/src/lambda/handler.js +19 -12
- package/packages/dd-trace/src/log/writer.js +32 -24
- package/packages/dd-trace/src/metrics.js +18 -0
- package/packages/dd-trace/src/noop/proxy.js +2 -2
- package/packages/dd-trace/src/opentracing/span.js +5 -0
- package/packages/dd-trace/src/opentracing/span_context.js +1 -1
- package/packages/dd-trace/src/plugin_manager.js +7 -7
- package/packages/dd-trace/src/plugins/ci_plugin.js +20 -17
- package/packages/dd-trace/src/plugins/index.js +1 -0
- package/packages/dd-trace/src/plugins/log_plugin.js +1 -1
- package/packages/dd-trace/src/plugins/outgoing.js +2 -1
- package/packages/dd-trace/src/plugins/tracing.js +1 -1
- package/packages/dd-trace/src/plugins/util/ci.js +12 -0
- package/packages/dd-trace/src/plugins/util/exec.js +2 -2
- package/packages/dd-trace/src/plugins/util/git.js +16 -1
- package/packages/dd-trace/src/plugins/util/ip_extractor.js +23 -27
- package/packages/dd-trace/src/plugins/util/test.js +26 -7
- package/packages/dd-trace/src/profiler.js +3 -0
- package/packages/dd-trace/src/profiling/config.js +92 -20
- package/packages/dd-trace/src/profiling/constants.js +16 -0
- package/packages/dd-trace/src/profiling/exporter_cli.js +62 -0
- package/packages/dd-trace/src/profiling/exporters/agent.js +2 -1
- package/packages/dd-trace/src/profiling/exporters/file.js +13 -2
- package/packages/dd-trace/src/profiling/profiler.js +42 -12
- package/packages/dd-trace/src/profiling/profilers/space.js +21 -1
- package/packages/dd-trace/src/profiling/profilers/wall.js +1 -0
- package/packages/dd-trace/src/proxy.js +1 -1
- package/packages/dd-trace/src/span_processor.js +1 -1
- package/packages/dd-trace/src/span_sampler.js +71 -54
- package/packages/dd-trace/src/startup-log.js +3 -6
- package/packages/dd-trace/src/telemetry/index.js +16 -2
- package/packages/dd-trace/src/tracer.js +0 -16
- package/packages/dd-trace/src/util.js +10 -1
- package/scripts/install_plugin_modules.js +5 -1
- package/scripts/junit_report.js +0 -25
- package/scripts/tdd.js +0 -34
|
@@ -7,17 +7,17 @@ const shimmer = require('../../datadog-shimmer')
|
|
|
7
7
|
const startCh = channel('apm:mariadb:query:start')
|
|
8
8
|
const finishCh = channel('apm:mariadb:query:finish')
|
|
9
9
|
const errorCh = channel('apm:mariadb:query:error')
|
|
10
|
+
const skipCh = channel('apm:mariadb:pool:skip')
|
|
11
|
+
const unskipCh = channel('apm:mariadb:pool:unskip')
|
|
10
12
|
|
|
11
|
-
function wrapCommandStart (start) {
|
|
13
|
+
function wrapCommandStart (start, callbackResource) {
|
|
12
14
|
return function () {
|
|
13
15
|
if (!startCh.hasSubscribers) return start.apply(this, arguments)
|
|
14
16
|
|
|
15
|
-
const callbackResource = new AsyncResource('bound-anonymous-fn')
|
|
16
|
-
|
|
17
17
|
const resolve = callbackResource.bind(this.resolve)
|
|
18
18
|
const reject = callbackResource.bind(this.reject)
|
|
19
19
|
|
|
20
|
-
const asyncResource = new AsyncResource('bound-anonymous-fn')
|
|
20
|
+
const asyncResource = callbackResource.runInAsyncScope(() => new AsyncResource('bound-anonymous-fn'))
|
|
21
21
|
|
|
22
22
|
shimmer.wrap(this, 'resolve', function wrapResolve () {
|
|
23
23
|
return function () {
|
|
@@ -47,17 +47,136 @@ function wrapCommandStart (start) {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
function wrapCommand (Command) {
|
|
51
|
+
return class extends Command {
|
|
52
|
+
constructor (...args) {
|
|
53
|
+
super(...args)
|
|
54
|
+
|
|
55
|
+
const callbackResource = new AsyncResource('bound-anonymous-fn')
|
|
56
|
+
|
|
57
|
+
if (this.start) {
|
|
58
|
+
this.start = wrapCommandStart(this.start, callbackResource)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function createWrapQuery (options) {
|
|
65
|
+
return function wrapQuery (query) {
|
|
66
|
+
return function (sql) {
|
|
67
|
+
if (!startCh.hasSubscribers) return query.apply(this, arguments)
|
|
68
|
+
|
|
69
|
+
const asyncResource = new AsyncResource('bound-anonymous-fn')
|
|
70
|
+
|
|
71
|
+
return asyncResource.runInAsyncScope(() => {
|
|
72
|
+
startCh.publish({ sql, conf: options })
|
|
73
|
+
|
|
74
|
+
return query.apply(this, arguments)
|
|
75
|
+
.then(result => {
|
|
76
|
+
finishCh.publish()
|
|
77
|
+
return result
|
|
78
|
+
}, error => {
|
|
79
|
+
errorCh.publish(error)
|
|
80
|
+
finishCh.publish()
|
|
81
|
+
throw error
|
|
82
|
+
})
|
|
83
|
+
}, 'bound-anonymous-fn')
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function createWrapQueryCallback (options) {
|
|
89
|
+
return function wrapQuery (query) {
|
|
90
|
+
return function (sql) {
|
|
91
|
+
if (!startCh.hasSubscribers) return query.apply(this, arguments)
|
|
92
|
+
|
|
93
|
+
const cb = arguments[arguments.length - 1]
|
|
94
|
+
const asyncResource = new AsyncResource('bound-anonymous-fn')
|
|
95
|
+
const callbackResource = new AsyncResource('bound-anonymous-fn')
|
|
96
|
+
|
|
97
|
+
if (typeof cb !== 'function') {
|
|
98
|
+
arguments.length = arguments.length + 1
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
arguments[arguments.length - 1] = asyncResource.bind(function (err) {
|
|
102
|
+
if (err) {
|
|
103
|
+
errorCh.publish(err)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
finishCh.publish()
|
|
107
|
+
|
|
108
|
+
if (typeof cb === 'function') {
|
|
109
|
+
return callbackResource.runInAsyncScope(() => cb.apply(this, arguments))
|
|
110
|
+
}
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
return asyncResource.runInAsyncScope(() => {
|
|
114
|
+
startCh.publish({ sql, conf: options })
|
|
115
|
+
|
|
116
|
+
return query.apply(this, arguments)
|
|
117
|
+
}, 'bound-anonymous-fn')
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function wrapConnection (Connection, promiseMethod) {
|
|
123
|
+
return function (options) {
|
|
124
|
+
Connection.apply(this, arguments)
|
|
125
|
+
|
|
126
|
+
shimmer.wrap(this, promiseMethod, createWrapQuery(options))
|
|
127
|
+
shimmer.wrap(this, '_queryCallback', createWrapQueryCallback(options))
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function wrapPoolBase (PoolBase) {
|
|
132
|
+
return function (options, processTask, createConnectionPool, pingPromise) {
|
|
133
|
+
arguments[1] = wrapPoolMethod(processTask)
|
|
134
|
+
arguments[2] = wrapPoolMethod(createConnectionPool)
|
|
135
|
+
|
|
136
|
+
PoolBase.apply(this, arguments)
|
|
137
|
+
|
|
138
|
+
shimmer.wrap(this, 'query', createWrapQuery(options.connOptions))
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// It's not possible to prevent connection pools from leaking across queries,
|
|
143
|
+
// so instead we just skip instrumentation completely to avoid memory leaks
|
|
144
|
+
// and/or orphan spans.
|
|
145
|
+
function wrapPoolMethod (createConnection) {
|
|
146
|
+
return function () {
|
|
147
|
+
skipCh.publish()
|
|
148
|
+
try {
|
|
149
|
+
return createConnection.apply(this, arguments)
|
|
150
|
+
} finally {
|
|
151
|
+
unskipCh.publish()
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
50
156
|
const name = 'mariadb'
|
|
51
|
-
const versions = ['>=2.0.3']
|
|
52
157
|
|
|
53
|
-
addHook({ name, file: 'lib/cmd/query.js', versions }, (Query) => {
|
|
54
|
-
|
|
158
|
+
addHook({ name, file: 'lib/cmd/query.js', versions: ['>=3'] }, (Query) => {
|
|
159
|
+
return wrapCommand(Query)
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
addHook({ name, file: 'lib/cmd/execute.js', versions: ['>=3'] }, (Execute) => {
|
|
163
|
+
return wrapCommand(Execute)
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
addHook({ name, file: 'lib/pool.js', versions: ['>=3'] }, (Pool) => {
|
|
167
|
+
shimmer.wrap(Pool.prototype, '_createConnection', wrapPoolMethod)
|
|
55
168
|
|
|
56
|
-
return
|
|
169
|
+
return Pool
|
|
57
170
|
})
|
|
58
171
|
|
|
59
|
-
addHook({ name, file: 'lib/
|
|
60
|
-
shimmer.wrap(
|
|
172
|
+
addHook({ name, file: 'lib/connection.js', versions: ['>=2.5.2 <3'] }, (Connection) => {
|
|
173
|
+
return shimmer.wrap(Connection, wrapConnection(Connection, '_queryPromise'))
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
addHook({ name, file: 'lib/connection.js', versions: ['>=2.0.4 <=2.5.1'] }, (Connection) => {
|
|
177
|
+
return shimmer.wrap(Connection, wrapConnection(Connection, 'query'))
|
|
178
|
+
})
|
|
61
179
|
|
|
62
|
-
|
|
180
|
+
addHook({ name, file: 'lib/pool-base.js', versions: ['>=2.0.4 <3'] }, (PoolBase) => {
|
|
181
|
+
return shimmer.wrap(PoolBase, wrapPoolBase(PoolBase))
|
|
63
182
|
})
|
|
@@ -2,6 +2,8 @@ const { createCoverageMap } = require('istanbul-lib-coverage')
|
|
|
2
2
|
|
|
3
3
|
const { addHook, channel, AsyncResource } = require('./helpers/instrument')
|
|
4
4
|
const shimmer = require('../../datadog-shimmer')
|
|
5
|
+
const log = require('../../dd-trace/src/log')
|
|
6
|
+
|
|
5
7
|
const {
|
|
6
8
|
getCoveredFilenamesFromCoverage,
|
|
7
9
|
resetCoverage,
|
|
@@ -34,6 +36,9 @@ const testToAr = new WeakMap()
|
|
|
34
36
|
const originalFns = new WeakMap()
|
|
35
37
|
const testFileToSuiteAr = new Map()
|
|
36
38
|
|
|
39
|
+
// `isWorker` is true if it's a Mocha worker
|
|
40
|
+
let isWorker = false
|
|
41
|
+
|
|
37
42
|
// We'll preserve the original coverage here
|
|
38
43
|
const originalCoverageMap = createCoverageMap()
|
|
39
44
|
|
|
@@ -101,7 +106,7 @@ function mochaHook (Runner) {
|
|
|
101
106
|
patched.add(Runner)
|
|
102
107
|
|
|
103
108
|
shimmer.wrap(Runner.prototype, 'run', run => function () {
|
|
104
|
-
if (!testStartCh.hasSubscribers) {
|
|
109
|
+
if (!testStartCh.hasSubscribers || isWorker) {
|
|
105
110
|
return run.apply(this, arguments)
|
|
106
111
|
}
|
|
107
112
|
|
|
@@ -120,9 +125,18 @@ function mochaHook (Runner) {
|
|
|
120
125
|
|
|
121
126
|
const isSuitesSkipped = !!suitesToSkip.length
|
|
122
127
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
128
|
+
let testCodeCoverageLinesTotal
|
|
129
|
+
if (global.__coverage__) {
|
|
130
|
+
try {
|
|
131
|
+
testCodeCoverageLinesTotal = originalCoverageMap.getCoverageSummary().lines.pct
|
|
132
|
+
} catch (e) {
|
|
133
|
+
// ignore errors
|
|
134
|
+
}
|
|
135
|
+
// restore the original coverage
|
|
136
|
+
global.__coverage__ = fromCoverageMapToCoverage(originalCoverageMap)
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
testSessionFinishCh.publish({ status, isSuitesSkipped, testCodeCoverageLinesTotal })
|
|
126
140
|
}))
|
|
127
141
|
|
|
128
142
|
this.once('start', testRunAsyncResource.bind(function () {
|
|
@@ -321,7 +335,15 @@ addHook({
|
|
|
321
335
|
* If ITR is disabled, `onDone` is called immediately on the subscriber
|
|
322
336
|
*/
|
|
323
337
|
shimmer.wrap(Mocha.prototype, 'run', run => function () {
|
|
324
|
-
if (
|
|
338
|
+
if (this.options.parallel) {
|
|
339
|
+
log.warn(`Unable to initialize CI Visibility because Mocha is running in parallel mode.`)
|
|
340
|
+
return run.apply(this, arguments)
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
if (!itrConfigurationCh.hasSubscribers || this.isWorker) {
|
|
344
|
+
if (this.isWorker) {
|
|
345
|
+
isWorker = true
|
|
346
|
+
}
|
|
325
347
|
return run.apply(this, arguments)
|
|
326
348
|
}
|
|
327
349
|
this.options.delay = true
|
|
@@ -379,7 +401,9 @@ addHook({
|
|
|
379
401
|
* This attaches `run` to the global context, which we'll call after
|
|
380
402
|
* our configuration and skippable suites requests
|
|
381
403
|
*/
|
|
382
|
-
mocha.options.
|
|
404
|
+
if (!mocha.options.parallel) {
|
|
405
|
+
mocha.options.delay = true
|
|
406
|
+
}
|
|
383
407
|
return runMocha.apply(this, arguments)
|
|
384
408
|
})
|
|
385
409
|
return run
|
|
@@ -25,13 +25,19 @@ addHook({ name: 'mongodb-core', versions: ['2 - 3.1.9'] }, Server => {
|
|
|
25
25
|
return Server
|
|
26
26
|
})
|
|
27
27
|
|
|
28
|
-
addHook({ name: 'mongodb', versions: ['>=4'], file: 'lib/cmap/connection.js' }, Connection => {
|
|
28
|
+
addHook({ name: 'mongodb', versions: ['>=4 <4.6.0'], file: 'lib/cmap/connection.js' }, Connection => {
|
|
29
29
|
const proto = Connection.Connection.prototype
|
|
30
30
|
shimmer.wrap(proto, 'command', command => wrapConnectionCommand(command, 'command'))
|
|
31
31
|
shimmer.wrap(proto, 'query', query => wrapConnectionCommand(query, 'query'))
|
|
32
32
|
return Connection
|
|
33
33
|
})
|
|
34
34
|
|
|
35
|
+
addHook({ name: 'mongodb', versions: ['>=4.6.0'], file: 'lib/cmap/connection.js' }, Connection => {
|
|
36
|
+
const proto = Connection.Connection.prototype
|
|
37
|
+
shimmer.wrap(proto, 'command', command => wrapConnectionCommand(command, 'command'))
|
|
38
|
+
return Connection
|
|
39
|
+
})
|
|
40
|
+
|
|
35
41
|
addHook({ name: 'mongodb', versions: ['>=3.3 <4'], file: 'lib/core/wireprotocol/index.js' }, wp => wrapWp(wp))
|
|
36
42
|
|
|
37
43
|
addHook({ name: 'mongodb-core', versions: ['>=3.2'], file: 'lib/wireprotocol/index.js' }, wp => wrapWp(wp))
|
|
@@ -46,7 +52,7 @@ addHook({ name: 'mongodb-core', versions: ['~3.1.10'], file: 'lib/wireprotocol/2
|
|
|
46
52
|
return WireProtocol
|
|
47
53
|
})
|
|
48
54
|
|
|
49
|
-
addHook({ name: 'mongodb', versions: ['>=3.5.4'], file: 'lib/utils.js' }, util => {
|
|
55
|
+
addHook({ name: 'mongodb', versions: ['>=3.5.4 <4.11.0'], file: 'lib/utils.js' }, util => {
|
|
50
56
|
shimmer.wrap(util, 'maybePromise', maybePromise => function (parent, callback, fn) {
|
|
51
57
|
const asyncResource = new AsyncResource('bound-anonymous-fn')
|
|
52
58
|
const callbackIndex = arguments.length - 2
|
|
@@ -19,7 +19,7 @@ function wrapAddQueue (addQueue) {
|
|
|
19
19
|
|
|
20
20
|
addHook({
|
|
21
21
|
name: 'mongoose',
|
|
22
|
-
versions: ['>=4.6.4']
|
|
22
|
+
versions: ['>=4.6.4 <5', '5', '6', '>=7']
|
|
23
23
|
}, mongoose => {
|
|
24
24
|
if (mongoose.Promise !== global.Promise) {
|
|
25
25
|
shimmer.wrap(mongoose.Promise.prototype, 'then', wrapThen)
|
|
@@ -26,16 +26,33 @@ function wrapHandleApiRequest (handleApiRequest) {
|
|
|
26
26
|
return promise.then(handled => {
|
|
27
27
|
if (!handled) return handled
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
return this.hasPage(pathname).then(pageFound => {
|
|
30
|
+
const page = pageFound ? pathname : getPageFromPath(pathname, this.dynamicRoutes)
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
pageLoadChannel.publish({ page })
|
|
32
33
|
|
|
33
|
-
|
|
34
|
+
return handled
|
|
35
|
+
})
|
|
34
36
|
})
|
|
35
37
|
})
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
40
|
|
|
41
|
+
// next 13.2 handleApiRequest uses a different set of parameters
|
|
42
|
+
function wrapHandleApiRequestWithMatch (handleApiRequest) {
|
|
43
|
+
return function (req, res, query, match) {
|
|
44
|
+
return instrument(req, res, () => {
|
|
45
|
+
const page = (typeof match === 'object' && typeof match.definition === 'object')
|
|
46
|
+
? match.definition.pathname
|
|
47
|
+
: undefined
|
|
48
|
+
|
|
49
|
+
pageLoadChannel.publish({ page })
|
|
50
|
+
|
|
51
|
+
return handleApiRequest.apply(this, arguments)
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
39
56
|
function wrapRenderToResponse (renderToResponse) {
|
|
40
57
|
return function (ctx) {
|
|
41
58
|
return instrument(ctx.req, ctx.res, () => renderToResponse.apply(this, arguments))
|
|
@@ -127,7 +144,19 @@ function finish (req, res, result, err) {
|
|
|
127
144
|
return result
|
|
128
145
|
}
|
|
129
146
|
|
|
130
|
-
addHook({ name: 'next', versions: ['>=
|
|
147
|
+
addHook({ name: 'next', versions: ['>=13.2'], file: 'dist/server/next-server.js' }, nextServer => {
|
|
148
|
+
const Server = nextServer.default
|
|
149
|
+
|
|
150
|
+
shimmer.wrap(Server.prototype, 'handleRequest', wrapHandleRequest)
|
|
151
|
+
shimmer.wrap(Server.prototype, 'handleApiRequest', wrapHandleApiRequestWithMatch)
|
|
152
|
+
shimmer.wrap(Server.prototype, 'renderToResponse', wrapRenderToResponse)
|
|
153
|
+
shimmer.wrap(Server.prototype, 'renderErrorToResponse', wrapRenderErrorToResponse)
|
|
154
|
+
shimmer.wrap(Server.prototype, 'findPageComponents', wrapFindPageComponents)
|
|
155
|
+
|
|
156
|
+
return nextServer
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
addHook({ name: 'next', versions: ['>=11.1 <13.2'], file: 'dist/server/next-server.js' }, nextServer => {
|
|
131
160
|
const Server = nextServer.default
|
|
132
161
|
|
|
133
162
|
shimmer.wrap(Server.prototype, 'handleRequest', wrapHandleRequest)
|
|
@@ -25,6 +25,17 @@ const STATUS_TO_TEST_STATUS = {
|
|
|
25
25
|
|
|
26
26
|
let remainingTestsByFile = {}
|
|
27
27
|
|
|
28
|
+
function getTestsBySuiteFromTestGroups (testGroups) {
|
|
29
|
+
return testGroups.reduce((acc, { requireFile, tests }) => {
|
|
30
|
+
if (acc[requireFile]) {
|
|
31
|
+
acc[requireFile] = acc[requireFile].concat(tests)
|
|
32
|
+
} else {
|
|
33
|
+
acc[requireFile] = tests
|
|
34
|
+
}
|
|
35
|
+
return acc
|
|
36
|
+
}, {})
|
|
37
|
+
}
|
|
38
|
+
|
|
28
39
|
function getTestsBySuiteFromTestsById (testsById) {
|
|
29
40
|
const testsByTestSuite = {}
|
|
30
41
|
for (const { test } of testsById.values()) {
|
|
@@ -48,7 +59,7 @@ function getPlaywrightConfig (playwrightRunner) {
|
|
|
48
59
|
try {
|
|
49
60
|
return playwrightRunner._loader.fullConfig()
|
|
50
61
|
} catch (e) {
|
|
51
|
-
return {}
|
|
62
|
+
return playwrightRunner._config || {}
|
|
52
63
|
}
|
|
53
64
|
}
|
|
54
65
|
}
|
|
@@ -65,7 +76,7 @@ function getRootDir (playwrightRunner) {
|
|
|
65
76
|
}
|
|
66
77
|
|
|
67
78
|
function testBeginHandler (test) {
|
|
68
|
-
const {
|
|
79
|
+
const { _requireFile: testSuiteAbsolutePath, title: testName, _type } = test
|
|
69
80
|
|
|
70
81
|
if (_type === 'beforeAll' || _type === 'afterAll') {
|
|
71
82
|
return
|
|
@@ -90,7 +101,7 @@ function testBeginHandler (test) {
|
|
|
90
101
|
}
|
|
91
102
|
|
|
92
103
|
function testEndHandler (test, testStatus, error) {
|
|
93
|
-
const {
|
|
104
|
+
const { _requireFile: testSuiteAbsolutePath, results, _type } = test
|
|
94
105
|
|
|
95
106
|
if (_type === 'beforeAll' || _type === 'afterAll') {
|
|
96
107
|
return
|
|
@@ -135,6 +146,13 @@ function dispatcherRunWrapper (run) {
|
|
|
135
146
|
}
|
|
136
147
|
}
|
|
137
148
|
|
|
149
|
+
function dispatcherRunWrapperNew (run) {
|
|
150
|
+
return function () {
|
|
151
|
+
remainingTestsByFile = getTestsBySuiteFromTestGroups(arguments[0])
|
|
152
|
+
return run.apply(this, arguments)
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
138
156
|
function dispatcherHook (dispatcherExport) {
|
|
139
157
|
shimmer.wrap(dispatcherExport.Dispatcher.prototype, 'run', dispatcherRunWrapper)
|
|
140
158
|
shimmer.wrap(dispatcherExport.Dispatcher.prototype, '_createWorker', createWorker => function () {
|
|
@@ -160,8 +178,8 @@ function dispatcherHook (dispatcherExport) {
|
|
|
160
178
|
return dispatcherExport
|
|
161
179
|
}
|
|
162
180
|
|
|
163
|
-
function dispatcherHookNew (dispatcherExport) {
|
|
164
|
-
shimmer.wrap(dispatcherExport.Dispatcher.prototype, 'run',
|
|
181
|
+
function dispatcherHookNew (dispatcherExport, runWrapper) {
|
|
182
|
+
shimmer.wrap(dispatcherExport.Dispatcher.prototype, 'run', runWrapper)
|
|
165
183
|
shimmer.wrap(dispatcherExport.Dispatcher.prototype, '_createWorker', createWorker => function () {
|
|
166
184
|
const dispatcher = this
|
|
167
185
|
const worker = createWorker.apply(this, arguments)
|
|
@@ -192,24 +210,23 @@ function runnerHook (runnerExport, playwrightVersion) {
|
|
|
192
210
|
testSessionStartCh.publish({ command, frameworkVersion: playwrightVersion, rootDir })
|
|
193
211
|
})
|
|
194
212
|
|
|
195
|
-
const
|
|
196
|
-
const sessionStatus =
|
|
213
|
+
const runAllTestsReturn = await runAllTests.apply(this, arguments)
|
|
214
|
+
const sessionStatus = runAllTestsReturn.status || runAllTestsReturn
|
|
197
215
|
|
|
198
216
|
let onDone
|
|
199
217
|
|
|
200
218
|
const flushWait = new Promise(resolve => {
|
|
201
219
|
onDone = resolve
|
|
202
220
|
})
|
|
203
|
-
|
|
204
221
|
testSessionAsyncResource.runInAsyncScope(() => {
|
|
205
|
-
testSessionFinishCh.publish({ status: sessionStatus, onDone })
|
|
222
|
+
testSessionFinishCh.publish({ status: STATUS_TO_TEST_STATUS[sessionStatus], onDone })
|
|
206
223
|
})
|
|
207
224
|
await flushWait
|
|
208
225
|
|
|
209
226
|
startedSuites = []
|
|
210
227
|
remainingTestsByFile = {}
|
|
211
228
|
|
|
212
|
-
return
|
|
229
|
+
return runAllTestsReturn
|
|
213
230
|
})
|
|
214
231
|
|
|
215
232
|
return runnerExport
|
|
@@ -218,7 +235,7 @@ function runnerHook (runnerExport, playwrightVersion) {
|
|
|
218
235
|
addHook({
|
|
219
236
|
name: '@playwright/test',
|
|
220
237
|
file: 'lib/runner.js',
|
|
221
|
-
versions: ['>=1.18.0']
|
|
238
|
+
versions: ['>=1.18.0 <1.30.0']
|
|
222
239
|
}, runnerHook)
|
|
223
240
|
|
|
224
241
|
addHook({
|
|
@@ -230,5 +247,17 @@ addHook({
|
|
|
230
247
|
addHook({
|
|
231
248
|
name: '@playwright/test',
|
|
232
249
|
file: 'lib/dispatcher.js',
|
|
233
|
-
versions: ['>=1.30.0']
|
|
234
|
-
}, dispatcherHookNew)
|
|
250
|
+
versions: ['>=1.30.0 <1.31.0']
|
|
251
|
+
}, (dispatcher) => dispatcherHookNew(dispatcher, dispatcherRunWrapper))
|
|
252
|
+
|
|
253
|
+
addHook({
|
|
254
|
+
name: '@playwright/test',
|
|
255
|
+
file: 'lib/runner/dispatcher.js',
|
|
256
|
+
versions: ['>=1.31.0']
|
|
257
|
+
}, (dispatcher) => dispatcherHookNew(dispatcher, dispatcherRunWrapperNew))
|
|
258
|
+
|
|
259
|
+
addHook({
|
|
260
|
+
name: '@playwright/test',
|
|
261
|
+
file: 'lib/runner/runner.js',
|
|
262
|
+
versions: ['>=1.31.0']
|
|
263
|
+
}, runnerHook)
|
|
@@ -4,7 +4,7 @@ const ConsumerPlugin = require('../../dd-trace/src/plugins/consumer')
|
|
|
4
4
|
const { getAddress, getShortName } = require('./util')
|
|
5
5
|
|
|
6
6
|
class Amqp10ConsumerPlugin extends ConsumerPlugin {
|
|
7
|
-
static get
|
|
7
|
+
static get id () { return 'amqp10' }
|
|
8
8
|
static get system () { return 'amqp' }
|
|
9
9
|
|
|
10
10
|
start ({ link }) {
|
|
@@ -5,7 +5,7 @@ const ConsumerPlugin = require('./consumer')
|
|
|
5
5
|
const CompositePlugin = require('../../dd-trace/src/plugins/composite')
|
|
6
6
|
|
|
7
7
|
class Amqp10Plugin extends CompositePlugin {
|
|
8
|
-
static get
|
|
8
|
+
static get id () { return 'amqp10' }
|
|
9
9
|
static get plugins () {
|
|
10
10
|
return {
|
|
11
11
|
producer: ProducerPlugin,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const ProducerPlugin = require('../../dd-trace/src/plugins/producer')
|
|
4
|
+
const { CLIENT_PORT_KEY } = require('../../dd-trace/src/constants')
|
|
4
5
|
const { getAddress, getShortName } = require('./util')
|
|
5
6
|
|
|
6
7
|
class Amqp10ProducerPlugin extends ProducerPlugin {
|
|
7
|
-
static get
|
|
8
|
+
static get id () { return 'amqp10' }
|
|
8
9
|
static get operation () { return 'send' }
|
|
9
10
|
static get system () { return 'amqp' }
|
|
10
11
|
|
|
@@ -20,7 +21,7 @@ class Amqp10ProducerPlugin extends ProducerPlugin {
|
|
|
20
21
|
'amqp.link.target.address': target,
|
|
21
22
|
'amqp.link.role': 'sender',
|
|
22
23
|
'out.host': address.host,
|
|
23
|
-
|
|
24
|
+
[CLIENT_PORT_KEY]: address.port,
|
|
24
25
|
'amqp.link.name': link.name,
|
|
25
26
|
'amqp.link.handle': link.handle,
|
|
26
27
|
'amqp.connection.host': address.host,
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const { TEXT_MAP } = require('../../../ext/formats')
|
|
4
|
+
const { CLIENT_PORT_KEY } = require('../../dd-trace/src/constants')
|
|
4
5
|
const ClientPlugin = require('../../dd-trace/src/plugins/client')
|
|
5
6
|
const { getResourceName } = require('./util')
|
|
6
7
|
|
|
7
8
|
class AmqplibClientPlugin extends ClientPlugin {
|
|
8
|
-
static get
|
|
9
|
+
static get id () { return 'amqplib' }
|
|
9
10
|
static get operation () { return 'command' }
|
|
10
11
|
|
|
11
12
|
start ({ channel = {}, method, fields }) {
|
|
@@ -19,7 +20,7 @@ class AmqplibClientPlugin extends ClientPlugin {
|
|
|
19
20
|
kind: 'client',
|
|
20
21
|
meta: {
|
|
21
22
|
'out.host': stream._host,
|
|
22
|
-
|
|
23
|
+
[CLIENT_PORT_KEY]: stream.remotePort,
|
|
23
24
|
'amqp.queue': fields.queue,
|
|
24
25
|
'amqp.exchange': fields.exchange,
|
|
25
26
|
'amqp.routingKey': fields.routingKey,
|
|
@@ -5,7 +5,7 @@ const ConsumerPlugin = require('../../dd-trace/src/plugins/consumer')
|
|
|
5
5
|
const { getResourceName } = require('./util')
|
|
6
6
|
|
|
7
7
|
class AmqplibConsumerPlugin extends ConsumerPlugin {
|
|
8
|
-
static get
|
|
8
|
+
static get id () { return 'amqplib' }
|
|
9
9
|
static get operation () { return 'command' }
|
|
10
10
|
|
|
11
11
|
start ({ method, fields, message }) {
|
|
@@ -7,7 +7,7 @@ const CompositePlugin = require('../../dd-trace/src/plugins/composite')
|
|
|
7
7
|
|
|
8
8
|
// TODO: Consider splitting channels for publish/receive in the instrumentation.
|
|
9
9
|
class AmqplibPlugin extends CompositePlugin {
|
|
10
|
-
static get
|
|
10
|
+
static get id () { return 'amqplib' }
|
|
11
11
|
static get plugins () {
|
|
12
12
|
return {
|
|
13
13
|
producer: ProducerPlugin,
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const { TEXT_MAP } = require('../../../ext/formats')
|
|
4
|
+
const { CLIENT_PORT_KEY } = require('../../dd-trace/src/constants')
|
|
4
5
|
const ProducerPlugin = require('../../dd-trace/src/plugins/producer')
|
|
5
6
|
const { getResourceName } = require('./util')
|
|
6
7
|
|
|
7
8
|
class AmqplibProducerPlugin extends ProducerPlugin {
|
|
8
|
-
static get
|
|
9
|
+
static get id () { return 'amqplib' }
|
|
9
10
|
static get operation () { return 'command' }
|
|
10
11
|
|
|
11
12
|
start ({ channel = {}, method, fields }) {
|
|
@@ -18,7 +19,7 @@ class AmqplibProducerPlugin extends ProducerPlugin {
|
|
|
18
19
|
kind: 'producer',
|
|
19
20
|
meta: {
|
|
20
21
|
'out.host': stream._host,
|
|
21
|
-
|
|
22
|
+
[CLIENT_PORT_KEY]: stream.remotePort,
|
|
22
23
|
'amqp.queue': fields.queue,
|
|
23
24
|
'amqp.exchange': fields.exchange,
|
|
24
25
|
'amqp.routingKey': fields.routingKey,
|
|
@@ -3,10 +3,13 @@
|
|
|
3
3
|
const analyticsSampler = require('../../dd-trace/src/analytics_sampler')
|
|
4
4
|
const Plugin = require('../../dd-trace/src/plugins/plugin')
|
|
5
5
|
const { storage } = require('../../datadog-core')
|
|
6
|
+
const { isTrue } = require('../../dd-trace/src/util')
|
|
6
7
|
|
|
7
8
|
class BaseAwsSdkPlugin extends Plugin {
|
|
9
|
+
static get id () { return 'aws' }
|
|
10
|
+
|
|
8
11
|
get serviceIdentifier () {
|
|
9
|
-
const id = this.constructor.
|
|
12
|
+
const id = this.constructor.id.toLowerCase()
|
|
10
13
|
Object.defineProperty(this, 'serviceIdentifier', {
|
|
11
14
|
configurable: true,
|
|
12
15
|
writable: true,
|
|
@@ -74,7 +77,9 @@ class BaseAwsSdkPlugin extends Plugin {
|
|
|
74
77
|
}
|
|
75
78
|
|
|
76
79
|
isEnabled (request) {
|
|
77
|
-
|
|
80
|
+
const serviceId = this.serviceIdentifier.toUpperCase()
|
|
81
|
+
const envVarValue = process.env[`DD_TRACE_AWS_SDK_${serviceId}_ENABLED`]
|
|
82
|
+
return envVarValue ? isTrue(envVarValue) : true
|
|
78
83
|
}
|
|
79
84
|
|
|
80
85
|
addResponseTags (span, response) {
|
|
@@ -3,6 +3,8 @@ const log = require('../../../dd-trace/src/log')
|
|
|
3
3
|
const BaseAwsSdkPlugin = require('../base')
|
|
4
4
|
|
|
5
5
|
class EventBridge extends BaseAwsSdkPlugin {
|
|
6
|
+
static get id () { return 'eventbridge' }
|
|
7
|
+
|
|
6
8
|
generateTags (params, operation, response) {
|
|
7
9
|
if (!params || !params.source) return {}
|
|
8
10
|
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
const log = require('../../../dd-trace/src/log')
|
|
3
3
|
const BaseAwsSdkPlugin = require('../base')
|
|
4
4
|
class Kinesis extends BaseAwsSdkPlugin {
|
|
5
|
+
static get id () { return 'kinesis' }
|
|
6
|
+
|
|
5
7
|
generateTags (params, operation, response) {
|
|
6
8
|
if (!params || !params.StreamName) return {}
|
|
7
9
|
|