dd-trace 5.51.0 → 5.52.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 +0 -6
- package/index.d.ts +35 -1
- package/package.json +3 -9
- package/packages/datadog-instrumentations/src/confluentinc-kafka-javascript.js +391 -0
- package/packages/datadog-instrumentations/src/cucumber.js +3 -0
- package/packages/datadog-instrumentations/src/dns.js +16 -14
- package/packages/datadog-instrumentations/src/fs.js +37 -46
- package/packages/datadog-instrumentations/src/helpers/hooks.js +1 -0
- package/packages/datadog-instrumentations/src/jest.js +5 -0
- package/packages/datadog-instrumentations/src/mocha/utils.js +5 -0
- package/packages/datadog-instrumentations/src/net.js +24 -28
- package/packages/datadog-instrumentations/src/pg.js +19 -5
- package/packages/datadog-instrumentations/src/playwright.js +6 -0
- package/packages/datadog-instrumentations/src/vitest.js +18 -4
- package/packages/datadog-plugin-confluentinc-kafka-javascript/src/batch-consumer.js +11 -0
- package/packages/datadog-plugin-confluentinc-kafka-javascript/src/consumer.js +11 -0
- package/packages/datadog-plugin-confluentinc-kafka-javascript/src/index.js +19 -0
- package/packages/datadog-plugin-confluentinc-kafka-javascript/src/producer.js +11 -0
- package/packages/datadog-plugin-cucumber/src/index.js +3 -0
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +3 -0
- package/packages/datadog-plugin-dns/src/lookup.js +10 -5
- package/packages/datadog-plugin-dns/src/lookup_service.js +6 -2
- package/packages/datadog-plugin-dns/src/resolve.js +5 -2
- package/packages/datadog-plugin-dns/src/reverse.js +6 -2
- package/packages/datadog-plugin-fs/src/index.js +9 -2
- package/packages/datadog-plugin-jest/src/index.js +3 -0
- package/packages/datadog-plugin-kafkajs/src/batch-consumer.js +2 -1
- package/packages/datadog-plugin-kafkajs/src/consumer.js +12 -21
- package/packages/datadog-plugin-kafkajs/src/producer.js +6 -2
- package/packages/datadog-plugin-kafkajs/src/utils.js +27 -0
- package/packages/datadog-plugin-langchain/src/index.js +0 -1
- package/packages/datadog-plugin-mocha/src/index.js +3 -0
- package/packages/datadog-plugin-net/src/ipc.js +6 -4
- package/packages/datadog-plugin-net/src/tcp.js +15 -9
- package/packages/datadog-plugin-pg/src/index.js +5 -1
- package/packages/datadog-plugin-playwright/src/index.js +3 -0
- package/packages/datadog-plugin-vitest/src/index.js +15 -3
- package/packages/dd-trace/src/appsec/api_security_sampler.js +20 -12
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +14 -9
- package/packages/dd-trace/src/appsec/index.js +1 -1
- package/packages/dd-trace/src/baggage.js +36 -0
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +4 -2
- package/packages/dd-trace/src/config.js +13 -1
- package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +2 -0
- package/packages/dd-trace/src/debugger/devtools_client/state.js +1 -1
- package/packages/dd-trace/src/exporters/common/docker.js +13 -31
- package/packages/dd-trace/src/guardrails/telemetry.js +2 -5
- package/packages/dd-trace/src/llmobs/writers/base.js +33 -12
- package/packages/dd-trace/src/noop/proxy.js +5 -0
- package/packages/dd-trace/src/opentelemetry/context_manager.js +2 -0
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +17 -9
- package/packages/dd-trace/src/plugin_manager.js +2 -0
- package/packages/dd-trace/src/plugins/index.js +3 -0
- package/packages/dd-trace/src/plugins/log_plugin.js +9 -20
- package/packages/dd-trace/src/plugins/outbound.js +11 -3
- package/packages/dd-trace/src/plugins/tracing.js +8 -4
- package/packages/dd-trace/src/plugins/util/test.js +1 -1
- package/packages/dd-trace/src/profiling/exporter_cli.js +1 -1
- package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_lookup.js +1 -1
- package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_lookupservice.js +1 -1
- package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_resolve.js +2 -2
- package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_reverse.js +1 -1
- package/packages/dd-trace/src/profiling/profilers/event_plugins/event.js +15 -14
- package/packages/dd-trace/src/proxy.js +12 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +8 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/messaging.js +8 -0
- package/packages/dd-trace/src/standalone/product.js +3 -5
|
@@ -10,9 +10,10 @@ class FsPlugin extends TracingPlugin {
|
|
|
10
10
|
return super.configure(...args)
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
bindStart (ctx) {
|
|
14
14
|
if (!this.activeSpan) return this.skip()
|
|
15
15
|
|
|
16
|
+
const { operation, ...params } = ctx
|
|
16
17
|
const lowerOp = operation.toLowerCase()
|
|
17
18
|
const flag = params.flag || params.flags || (params.options && (params.options.flag || params.options.flags))
|
|
18
19
|
const defaultFlag = ((lowerOp.includes('open') || lowerOp.includes('read')) && 'r') ||
|
|
@@ -38,7 +39,13 @@ class FsPlugin extends TracingPlugin {
|
|
|
38
39
|
'file.src': params.src || params.oldPath || params.existingPath || params.target,
|
|
39
40
|
'file.uid': uid || ''
|
|
40
41
|
}
|
|
41
|
-
})
|
|
42
|
+
}, ctx)
|
|
43
|
+
|
|
44
|
+
return ctx.currentStore
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
bindFinish (ctx) {
|
|
48
|
+
return ctx.parentStore
|
|
42
49
|
}
|
|
43
50
|
}
|
|
44
51
|
|
|
@@ -346,6 +346,7 @@ class JestPlugin extends CiPlugin {
|
|
|
346
346
|
testStartLine,
|
|
347
347
|
attemptToFixPassed,
|
|
348
348
|
failedAllTests,
|
|
349
|
+
attemptToFixFailed,
|
|
349
350
|
isAtrRetry
|
|
350
351
|
}) => {
|
|
351
352
|
const span = storage('legacy').getStore().span
|
|
@@ -355,6 +356,8 @@ class JestPlugin extends CiPlugin {
|
|
|
355
356
|
}
|
|
356
357
|
if (attemptToFixPassed) {
|
|
357
358
|
span.setTag(TEST_MANAGEMENT_ATTEMPT_TO_FIX_PASSED, 'true')
|
|
359
|
+
} else if (attemptToFixFailed) {
|
|
360
|
+
span.setTag(TEST_MANAGEMENT_ATTEMPT_TO_FIX_PASSED, 'false')
|
|
358
361
|
}
|
|
359
362
|
if (failedAllTests) {
|
|
360
363
|
span.setTag(TEST_HAS_FAILED_ALL_RETRIES, 'true')
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const ConsumerPlugin = require('../../dd-trace/src/plugins/consumer')
|
|
2
2
|
const { getMessageSize } = require('../../dd-trace/src/datastreams')
|
|
3
|
+
const { convertToTextMap } = require('./utils')
|
|
3
4
|
|
|
4
5
|
class KafkajsBatchConsumerPlugin extends ConsumerPlugin {
|
|
5
6
|
static get id () { return 'kafkajs' }
|
|
@@ -10,7 +11,7 @@ class KafkajsBatchConsumerPlugin extends ConsumerPlugin {
|
|
|
10
11
|
for (const message of messages) {
|
|
11
12
|
if (!message || !message.headers) continue
|
|
12
13
|
const payloadSize = getMessageSize(message)
|
|
13
|
-
this.tracer.decodeDataStreamsContext(message.headers)
|
|
14
|
+
this.tracer.decodeDataStreamsContext(convertToTextMap(message.headers))
|
|
14
15
|
const edgeTags = ['direction:in', `group:${groupId}`, `topic:${topic}`, 'type:kafka']
|
|
15
16
|
if (clusterId) {
|
|
16
17
|
edgeTags.push(`kafka_cluster_id:${clusterId}`)
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const dc = require('dc-polyfill')
|
|
4
4
|
const { getMessageSize } = require('../../dd-trace/src/datastreams')
|
|
5
5
|
const ConsumerPlugin = require('../../dd-trace/src/plugins/consumer')
|
|
6
|
-
|
|
6
|
+
const { convertToTextMap } = require('./utils')
|
|
7
7
|
const afterStartCh = dc.channel('dd-trace:kafkajs:consumer:afterStart')
|
|
8
8
|
const beforeFinishCh = dc.channel('dd-trace:kafkajs:consumer:beforeFinish')
|
|
9
9
|
|
|
@@ -15,7 +15,7 @@ class KafkajsConsumerPlugin extends ConsumerPlugin {
|
|
|
15
15
|
|
|
16
16
|
constructor () {
|
|
17
17
|
super(...arguments)
|
|
18
|
-
this.addSub(
|
|
18
|
+
this.addSub(`apm:${this.constructor.id}:consume:commit`, message => this.commit(message))
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
/**
|
|
@@ -65,15 +65,18 @@ class KafkajsConsumerPlugin extends ConsumerPlugin {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
start ({ topic, partition, message, groupId, clusterId }) {
|
|
68
|
-
|
|
68
|
+
let childOf
|
|
69
|
+
const headers = convertToTextMap(message?.headers)
|
|
70
|
+
if (headers) {
|
|
71
|
+
childOf = this.tracer.extract('text_map', headers)
|
|
72
|
+
}
|
|
69
73
|
const span = this.startSpan({
|
|
70
74
|
childOf,
|
|
71
75
|
resource: topic,
|
|
72
76
|
type: 'worker',
|
|
73
77
|
meta: {
|
|
74
|
-
component:
|
|
78
|
+
component: this.constructor.id,
|
|
75
79
|
'kafka.topic': topic,
|
|
76
|
-
'kafka.message.offset': message.offset,
|
|
77
80
|
'kafka.cluster_id': clusterId,
|
|
78
81
|
[MESSAGING_DESTINATION_KEY]: topic
|
|
79
82
|
},
|
|
@@ -81,9 +84,11 @@ class KafkajsConsumerPlugin extends ConsumerPlugin {
|
|
|
81
84
|
'kafka.partition': partition
|
|
82
85
|
}
|
|
83
86
|
})
|
|
84
|
-
if (
|
|
87
|
+
if (message?.offset) span.setTag('kafka.message.offset', message?.offset)
|
|
88
|
+
|
|
89
|
+
if (this.config.dsmEnabled && headers) {
|
|
85
90
|
const payloadSize = getMessageSize(message)
|
|
86
|
-
this.tracer.decodeDataStreamsContext(
|
|
91
|
+
this.tracer.decodeDataStreamsContext(headers)
|
|
87
92
|
const edgeTags = ['direction:in', `group:${groupId}`, `topic:${topic}`, 'type:kafka']
|
|
88
93
|
if (clusterId) {
|
|
89
94
|
edgeTags.push(`kafka_cluster_id:${clusterId}`)
|
|
@@ -105,18 +110,4 @@ class KafkajsConsumerPlugin extends ConsumerPlugin {
|
|
|
105
110
|
}
|
|
106
111
|
}
|
|
107
112
|
|
|
108
|
-
function extract (tracer, bufferMap) {
|
|
109
|
-
if (!bufferMap) return null
|
|
110
|
-
|
|
111
|
-
const textMap = {}
|
|
112
|
-
|
|
113
|
-
for (const key of Object.keys(bufferMap)) {
|
|
114
|
-
if (bufferMap[key] === null || bufferMap[key] === undefined) continue
|
|
115
|
-
|
|
116
|
-
textMap[key] = bufferMap[key].toString()
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return tracer.extract('text_map', textMap)
|
|
120
|
-
}
|
|
121
|
-
|
|
122
113
|
module.exports = KafkajsConsumerPlugin
|
|
@@ -13,7 +13,7 @@ class KafkajsProducerPlugin extends ProducerPlugin {
|
|
|
13
13
|
|
|
14
14
|
constructor () {
|
|
15
15
|
super(...arguments)
|
|
16
|
-
this.addSub(
|
|
16
|
+
this.addSub(`apm:${this.constructor.id}:produce:commit`, message => this.commit(message))
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -54,6 +54,7 @@ class KafkajsProducerPlugin extends ProducerPlugin {
|
|
|
54
54
|
*/
|
|
55
55
|
commit (commitList) {
|
|
56
56
|
if (!this.config.dsmEnabled) return
|
|
57
|
+
if (!commitList || !Array.isArray(commitList)) return
|
|
57
58
|
const keys = [
|
|
58
59
|
'type',
|
|
59
60
|
'partition',
|
|
@@ -70,7 +71,7 @@ class KafkajsProducerPlugin extends ProducerPlugin {
|
|
|
70
71
|
const span = this.startSpan({
|
|
71
72
|
resource: topic,
|
|
72
73
|
meta: {
|
|
73
|
-
component:
|
|
74
|
+
component: this.constructor.id,
|
|
74
75
|
'kafka.topic': topic,
|
|
75
76
|
'kafka.cluster_id': clusterId,
|
|
76
77
|
[MESSAGING_DESTINATION_KEY]: topic
|
|
@@ -84,6 +85,9 @@ class KafkajsProducerPlugin extends ProducerPlugin {
|
|
|
84
85
|
}
|
|
85
86
|
for (const message of messages) {
|
|
86
87
|
if (message !== null && typeof message === 'object') {
|
|
88
|
+
if (!message.headers) {
|
|
89
|
+
message.headers = {}
|
|
90
|
+
}
|
|
87
91
|
this.tracer.inject(span, 'text_map', message.headers)
|
|
88
92
|
if (this.config.dsmEnabled) {
|
|
89
93
|
const payloadSize = getMessageSize(message)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
function convertToTextMap (bufferMap) {
|
|
4
|
+
if (!bufferMap) return null
|
|
5
|
+
|
|
6
|
+
// rdKafka returns an array of header maps
|
|
7
|
+
if (bufferMap instanceof Array) {
|
|
8
|
+
const headers = {}
|
|
9
|
+
for (const headerMap of bufferMap) {
|
|
10
|
+
for (const key of Object.keys(headerMap)) {
|
|
11
|
+
headers[key] = headerMap[key].toString()
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return headers
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const textMap = {}
|
|
18
|
+
for (const key of Object.keys(bufferMap)) {
|
|
19
|
+
if (bufferMap[key] === null || bufferMap[key] === undefined) continue
|
|
20
|
+
textMap[key] = bufferMap[key].toString()
|
|
21
|
+
}
|
|
22
|
+
return textMap
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = {
|
|
26
|
+
convertToTextMap
|
|
27
|
+
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
const langChainTracingPlugins = require('./tracing')
|
|
4
4
|
const langChainLLMObsPlugins = require('../../dd-trace/src/llmobs/plugins/langchain')
|
|
5
|
-
// const LangChainLLMObsPlugin = require('../../dd-trace/src/llmobs/plugins/langchain')
|
|
6
5
|
const CompositePlugin = require('../../dd-trace/src/plugins/composite')
|
|
7
6
|
|
|
8
7
|
const plugins = {}
|
|
@@ -208,6 +208,7 @@ class MochaPlugin extends CiPlugin {
|
|
|
208
208
|
isLastRetry,
|
|
209
209
|
hasFailedAllRetries,
|
|
210
210
|
attemptToFixPassed,
|
|
211
|
+
attemptToFixFailed,
|
|
211
212
|
isAttemptToFixRetry,
|
|
212
213
|
isAtrRetry
|
|
213
214
|
}) => {
|
|
@@ -229,6 +230,8 @@ class MochaPlugin extends CiPlugin {
|
|
|
229
230
|
}
|
|
230
231
|
if (attemptToFixPassed) {
|
|
231
232
|
span.setTag(TEST_MANAGEMENT_ATTEMPT_TO_FIX_PASSED, 'true')
|
|
233
|
+
} else if (attemptToFixFailed) {
|
|
234
|
+
span.setTag(TEST_MANAGEMENT_ATTEMPT_TO_FIX_PASSED, 'false')
|
|
232
235
|
}
|
|
233
236
|
if (isAttemptToFixRetry) {
|
|
234
237
|
span.setTag(TEST_IS_RETRY, 'true')
|
|
@@ -6,15 +6,17 @@ class NetIPCPlugin extends ClientPlugin {
|
|
|
6
6
|
static get id () { return 'net' }
|
|
7
7
|
static get operation () { return 'ipc' }
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
bindStart (ctx) {
|
|
10
10
|
this.startSpan('ipc.connect', {
|
|
11
11
|
service: this.config.service,
|
|
12
|
-
resource: options.path,
|
|
12
|
+
resource: ctx.options.path,
|
|
13
13
|
kind: 'client',
|
|
14
14
|
meta: {
|
|
15
|
-
'ipc.path': options.path
|
|
15
|
+
'ipc.path': ctx.options.path
|
|
16
16
|
}
|
|
17
|
-
})
|
|
17
|
+
}, ctx)
|
|
18
|
+
|
|
19
|
+
return ctx.currentStore
|
|
18
20
|
}
|
|
19
21
|
}
|
|
20
22
|
|
|
@@ -10,20 +10,24 @@ class NetTCPPlugin extends ClientPlugin {
|
|
|
10
10
|
constructor (...args) {
|
|
11
11
|
super(...args)
|
|
12
12
|
|
|
13
|
-
this.
|
|
14
|
-
|
|
13
|
+
this.addTraceBind('ready', (ctx) => {
|
|
14
|
+
return ctx.parentStore
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
this.addTraceSub('connection', (ctx) => {
|
|
18
|
+
const span = ctx.currentStore.span
|
|
15
19
|
|
|
16
20
|
span.addTags({
|
|
17
|
-
'tcp.local.address': socket.localAddress,
|
|
18
|
-
'tcp.local.port': socket.localPort
|
|
21
|
+
'tcp.local.address': ctx.socket.localAddress,
|
|
22
|
+
'tcp.local.port': ctx.socket.localPort
|
|
19
23
|
})
|
|
20
24
|
})
|
|
21
25
|
}
|
|
22
26
|
|
|
23
|
-
|
|
24
|
-
const host = options.host || 'localhost'
|
|
25
|
-
const port = options.port || 0
|
|
26
|
-
const family = options.family || 4
|
|
27
|
+
bindStart (ctx) {
|
|
28
|
+
const host = ctx.options.host || 'localhost'
|
|
29
|
+
const port = ctx.options.port || 0
|
|
30
|
+
const family = ctx.options.family || 4
|
|
27
31
|
|
|
28
32
|
this.startSpan('tcp.connect', {
|
|
29
33
|
service: this.config.service,
|
|
@@ -40,7 +44,9 @@ class NetTCPPlugin extends ClientPlugin {
|
|
|
40
44
|
'tcp.local.port': 0,
|
|
41
45
|
[CLIENT_PORT_KEY]: port
|
|
42
46
|
}
|
|
43
|
-
})
|
|
47
|
+
}, ctx)
|
|
48
|
+
|
|
49
|
+
return ctx.currentStore
|
|
44
50
|
}
|
|
45
51
|
}
|
|
46
52
|
|
|
@@ -8,7 +8,7 @@ class PGPlugin extends DatabasePlugin {
|
|
|
8
8
|
static get operation () { return 'query' }
|
|
9
9
|
static get system () { return 'postgres' }
|
|
10
10
|
|
|
11
|
-
start ({ params = {}, query, processId }) {
|
|
11
|
+
start ({ params = {}, query, processId, stream }) {
|
|
12
12
|
const service = this.serviceName({ pluginConfig: this.config, params })
|
|
13
13
|
const originalStatement = this.maybeTruncate(query.text)
|
|
14
14
|
|
|
@@ -27,6 +27,10 @@ class PGPlugin extends DatabasePlugin {
|
|
|
27
27
|
}
|
|
28
28
|
})
|
|
29
29
|
|
|
30
|
+
if (stream) {
|
|
31
|
+
span.setTag('db.stream', 1)
|
|
32
|
+
}
|
|
33
|
+
|
|
30
34
|
query.__ddInjectableQuery = this.injectDbmQuery(span, query.text, service, !!query.name)
|
|
31
35
|
}
|
|
32
36
|
}
|
|
@@ -267,6 +267,7 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
267
267
|
isAttemptToFixRetry,
|
|
268
268
|
hasFailedAllRetries,
|
|
269
269
|
hasPassedAttemptToFixRetries,
|
|
270
|
+
hasFailedAttemptToFixRetries,
|
|
270
271
|
isAtrRetry,
|
|
271
272
|
onDone
|
|
272
273
|
}) => {
|
|
@@ -311,6 +312,8 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
311
312
|
}
|
|
312
313
|
if (hasPassedAttemptToFixRetries) {
|
|
313
314
|
span.setTag(TEST_MANAGEMENT_ATTEMPT_TO_FIX_PASSED, 'true')
|
|
315
|
+
} else if (hasFailedAttemptToFixRetries) {
|
|
316
|
+
span.setTag(TEST_MANAGEMENT_ATTEMPT_TO_FIX_PASSED, 'false')
|
|
314
317
|
}
|
|
315
318
|
if (isDisabled) {
|
|
316
319
|
span.setTag(TEST_MANAGEMENT_IS_DISABLED, 'true')
|
|
@@ -155,7 +155,7 @@ class VitestPlugin extends CiPlugin {
|
|
|
155
155
|
}
|
|
156
156
|
})
|
|
157
157
|
|
|
158
|
-
this.addSub('ci:vitest:test:finish-time', ({ status, task, attemptToFixPassed }) => {
|
|
158
|
+
this.addSub('ci:vitest:test:finish-time', ({ status, task, attemptToFixPassed, attemptToFixFailed }) => {
|
|
159
159
|
const store = storage('legacy').getStore()
|
|
160
160
|
const span = store?.span
|
|
161
161
|
|
|
@@ -166,6 +166,8 @@ class VitestPlugin extends CiPlugin {
|
|
|
166
166
|
|
|
167
167
|
if (attemptToFixPassed) {
|
|
168
168
|
span.setTag(TEST_MANAGEMENT_ATTEMPT_TO_FIX_PASSED, 'true')
|
|
169
|
+
} else if (attemptToFixFailed) {
|
|
170
|
+
span.setTag(TEST_MANAGEMENT_ATTEMPT_TO_FIX_PASSED, 'false')
|
|
169
171
|
}
|
|
170
172
|
|
|
171
173
|
this.taskToFinishTime.set(task, span._getTime())
|
|
@@ -186,7 +188,14 @@ class VitestPlugin extends CiPlugin {
|
|
|
186
188
|
}
|
|
187
189
|
})
|
|
188
190
|
|
|
189
|
-
this.addSub('ci:vitest:test:error', ({
|
|
191
|
+
this.addSub('ci:vitest:test:error', ({
|
|
192
|
+
duration,
|
|
193
|
+
error,
|
|
194
|
+
shouldSetProbe,
|
|
195
|
+
promises,
|
|
196
|
+
hasFailedAllRetries,
|
|
197
|
+
attemptToFixFailed
|
|
198
|
+
}) => {
|
|
190
199
|
const store = storage('legacy').getStore()
|
|
191
200
|
const span = store?.span
|
|
192
201
|
|
|
@@ -211,6 +220,9 @@ class VitestPlugin extends CiPlugin {
|
|
|
211
220
|
if (hasFailedAllRetries) {
|
|
212
221
|
span.setTag(TEST_HAS_FAILED_ALL_RETRIES, 'true')
|
|
213
222
|
}
|
|
223
|
+
if (attemptToFixFailed) {
|
|
224
|
+
span.setTag(TEST_MANAGEMENT_ATTEMPT_TO_FIX_PASSED, 'false')
|
|
225
|
+
}
|
|
214
226
|
if (duration) {
|
|
215
227
|
span.finish(span._startTime + duration - MILLISECONDS_TO_SUBTRACT_FROM_FAILED_TEST_DURATION) // milliseconds
|
|
216
228
|
} else {
|
|
@@ -337,7 +349,7 @@ class VitestPlugin extends CiPlugin {
|
|
|
337
349
|
this.testModuleSpan.setTag('error', error)
|
|
338
350
|
this.testSessionSpan.setTag('error', error)
|
|
339
351
|
}
|
|
340
|
-
if (testCodeCoverageLinesTotal) {
|
|
352
|
+
if (testCodeCoverageLinesTotal !== undefined) {
|
|
341
353
|
this.testModuleSpan.setTag(TEST_CODE_COVERAGE_LINES_PCT, testCodeCoverageLinesTotal)
|
|
342
354
|
this.testSessionSpan.setTag(TEST_CODE_COVERAGE_LINES_PCT, testCodeCoverageLinesTotal)
|
|
343
355
|
}
|
|
@@ -4,10 +4,13 @@ const TTLCache = require('@isaacs/ttlcache')
|
|
|
4
4
|
const web = require('../plugins/util/web')
|
|
5
5
|
const log = require('../log')
|
|
6
6
|
const { AUTO_REJECT, USER_REJECT } = require('../../../../ext/priority')
|
|
7
|
+
const { keepTrace } = require('../priority_sampler')
|
|
8
|
+
const { ASM } = require('../standalone/product')
|
|
7
9
|
|
|
8
10
|
const MAX_SIZE = 4096
|
|
9
11
|
|
|
10
12
|
let enabled
|
|
13
|
+
let asmStandaloneEnabled
|
|
11
14
|
|
|
12
15
|
/**
|
|
13
16
|
* @type {TTLCache}
|
|
@@ -20,11 +23,12 @@ class NoopTTLCache {
|
|
|
20
23
|
has (_key) { return false }
|
|
21
24
|
}
|
|
22
25
|
|
|
23
|
-
function configure ({
|
|
24
|
-
enabled = apiSecurity.enabled
|
|
25
|
-
|
|
26
|
+
function configure ({ appsec, apmTracingEnabled }) {
|
|
27
|
+
enabled = appsec.apiSecurity.enabled
|
|
28
|
+
asmStandaloneEnabled = apmTracingEnabled === false
|
|
29
|
+
sampledRequests = appsec.apiSecurity.sampleDelay === 0
|
|
26
30
|
? new NoopTTLCache()
|
|
27
|
-
: new TTLCache({ max: MAX_SIZE, ttl: apiSecurity.sampleDelay * 1000 })
|
|
31
|
+
: new TTLCache({ max: MAX_SIZE, ttl: appsec.apiSecurity.sampleDelay * 1000 })
|
|
28
32
|
}
|
|
29
33
|
|
|
30
34
|
function disable () {
|
|
@@ -41,14 +45,18 @@ function sampleRequest (req, res, force = false) {
|
|
|
41
45
|
const rootSpan = web.root(req)
|
|
42
46
|
if (!rootSpan) return false
|
|
43
47
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
priority = getSpanPriority(rootSpan)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
if (asmStandaloneEnabled) {
|
|
49
|
+
keepTrace(rootSpan, ASM)
|
|
50
|
+
} else {
|
|
51
|
+
let priority = getSpanPriority(rootSpan)
|
|
52
|
+
if (!priority) {
|
|
53
|
+
rootSpan._prioritySampler?.sample(rootSpan)
|
|
54
|
+
priority = getSpanPriority(rootSpan)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (priority === AUTO_REJECT || priority === USER_REJECT) {
|
|
58
|
+
return false
|
|
59
|
+
}
|
|
52
60
|
}
|
|
53
61
|
|
|
54
62
|
if (force) {
|
|
@@ -19,9 +19,11 @@ let config
|
|
|
19
19
|
const hardcodedSecretCh = dc.channel('datadog:secrets:result')
|
|
20
20
|
let rewriter
|
|
21
21
|
let unwrapCompile = () => {}
|
|
22
|
-
let getPrepareStackTrace
|
|
22
|
+
let getPrepareStackTrace
|
|
23
|
+
let cacheRewrittenSourceMap
|
|
23
24
|
let kSymbolPrepareStackTrace
|
|
24
|
-
|
|
25
|
+
|
|
26
|
+
function noop () {}
|
|
25
27
|
|
|
26
28
|
function isFlagPresent (flag) {
|
|
27
29
|
return process.env.NODE_OPTIONS?.includes(flag) ||
|
|
@@ -155,7 +157,7 @@ function shimPrepareStackTrace () {
|
|
|
155
157
|
return
|
|
156
158
|
}
|
|
157
159
|
const pstDescriptor = Object.getOwnPropertyDescriptor(global.Error, 'prepareStackTrace')
|
|
158
|
-
if (
|
|
160
|
+
if (pstDescriptor?.configurable || pstDescriptor?.writable) {
|
|
159
161
|
Object.defineProperty(global.Error, 'prepareStackTrace', getPrepareStackTraceAccessor())
|
|
160
162
|
}
|
|
161
163
|
shimmedPrepareStackTrace = true
|
|
@@ -181,16 +183,17 @@ function isEsmConfigured () {
|
|
|
181
183
|
const hasLoaderArg = isFlagPresent('--loader') || isFlagPresent('--experimental-loader')
|
|
182
184
|
if (hasLoaderArg) return true
|
|
183
185
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
+
// Fast path for common case when enabled
|
|
187
|
+
if (require.cache[`${process.cwd()}/node_modules/import-in-the-middle/hook.js`]) {
|
|
188
|
+
return true
|
|
189
|
+
}
|
|
190
|
+
return Object.keys(require.cache).some(file => file.endsWith('import-in-the-middle/hook.js'))
|
|
186
191
|
}
|
|
187
192
|
|
|
188
|
-
|
|
189
|
-
if (isMainThread && Module.register &&
|
|
193
|
+
let enableEsmRewriter = function (telemetryVerbosity) {
|
|
194
|
+
if (isMainThread && Module.register && isEsmConfigured()) {
|
|
190
195
|
shimPrepareStackTrace()
|
|
191
196
|
|
|
192
|
-
esmRewriterEnabled = true
|
|
193
|
-
|
|
194
197
|
const { port1, port2 } = new MessageChannel()
|
|
195
198
|
|
|
196
199
|
port1.on('message', (message) => {
|
|
@@ -229,6 +232,8 @@ function enableEsmRewriter (telemetryVerbosity) {
|
|
|
229
232
|
}
|
|
230
233
|
|
|
231
234
|
cacheRewrittenSourceMap = require('@datadog/wasm-js-rewriter/js/source-map').cacheRewrittenSourceMap
|
|
235
|
+
|
|
236
|
+
enableEsmRewriter = noop
|
|
232
237
|
}
|
|
233
238
|
}
|
|
234
239
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { storage } = require('../../datadog-core')
|
|
4
|
+
const baggageStorage = storage('baggage')
|
|
5
|
+
|
|
6
|
+
function setBaggageItem (key, value) {
|
|
7
|
+
storage('baggage').enterWith({ ...baggageStorage.getStore(), [key]: value })
|
|
8
|
+
return storage('baggage').getStore()
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function getBaggageItem (key) {
|
|
12
|
+
return storage('baggage').getStore()?.[key]
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function getAllBaggageItems () {
|
|
16
|
+
return storage('baggage').getStore()
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function removeBaggageItem (keyToRemove) {
|
|
20
|
+
const { [keyToRemove]: _, ...newBaggage } = storage('baggage').getStore()
|
|
21
|
+
storage('baggage').enterWith(newBaggage)
|
|
22
|
+
return newBaggage
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function removeAllBaggageItems () {
|
|
26
|
+
storage('baggage').enterWith({})
|
|
27
|
+
return storage('baggage').getStore()
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
module.exports = {
|
|
31
|
+
setBaggageItem,
|
|
32
|
+
getBaggageItem,
|
|
33
|
+
getAllBaggageItems,
|
|
34
|
+
removeBaggageItem,
|
|
35
|
+
removeAllBaggageItems
|
|
36
|
+
}
|
|
@@ -7,7 +7,8 @@ function getTestManagementTests ({
|
|
|
7
7
|
evpProxyPrefix,
|
|
8
8
|
isGzipCompatible,
|
|
9
9
|
repositoryUrl,
|
|
10
|
-
commitMessage
|
|
10
|
+
commitMessage,
|
|
11
|
+
sha
|
|
11
12
|
}, done) {
|
|
12
13
|
const options = {
|
|
13
14
|
path: '/api/v2/test/libraries/test-management/tests',
|
|
@@ -41,7 +42,8 @@ function getTestManagementTests ({
|
|
|
41
42
|
type: 'ci_app_libraries_tests_request',
|
|
42
43
|
attributes: {
|
|
43
44
|
repository_url: repositoryUrl,
|
|
44
|
-
commit_message: commitMessage
|
|
45
|
+
commit_message: commitMessage,
|
|
46
|
+
sha
|
|
45
47
|
}
|
|
46
48
|
}
|
|
47
49
|
})
|
|
@@ -481,7 +481,8 @@ class Config {
|
|
|
481
481
|
this._setValue(defaults, 'clientIpEnabled', false)
|
|
482
482
|
this._setValue(defaults, 'clientIpHeader', null)
|
|
483
483
|
this._setValue(defaults, 'crashtracking.enabled', true)
|
|
484
|
-
this._setValue(defaults, 'codeOriginForSpans.enabled',
|
|
484
|
+
this._setValue(defaults, 'codeOriginForSpans.enabled', true)
|
|
485
|
+
this._setValue(defaults, 'codeOriginForSpans.experimental.exit_spans.enabled', false)
|
|
485
486
|
this._setValue(defaults, 'dbmPropagationMode', 'disabled')
|
|
486
487
|
this._setValue(defaults, 'dogstatsd.hostname', '127.0.0.1')
|
|
487
488
|
this._setValue(defaults, 'dogstatsd.port', '8125')
|
|
@@ -660,6 +661,7 @@ class Config {
|
|
|
660
661
|
DD_APPSEC_WAF_TIMEOUT,
|
|
661
662
|
DD_CRASHTRACKING_ENABLED,
|
|
662
663
|
DD_CODE_ORIGIN_FOR_SPANS_ENABLED,
|
|
664
|
+
DD_CODE_ORIGIN_FOR_SPANS_EXPERIMENTAL_EXIT_SPANS_ENABLED,
|
|
663
665
|
DD_DATA_STREAMS_ENABLED,
|
|
664
666
|
DD_DBM_PROPAGATION_MODE,
|
|
665
667
|
DD_DOGSTATSD_HOSTNAME,
|
|
@@ -825,6 +827,11 @@ class Config {
|
|
|
825
827
|
!this._isInServerlessEnvironment()
|
|
826
828
|
))
|
|
827
829
|
this._setBoolean(env, 'codeOriginForSpans.enabled', DD_CODE_ORIGIN_FOR_SPANS_ENABLED)
|
|
830
|
+
this._setBoolean(
|
|
831
|
+
env,
|
|
832
|
+
'codeOriginForSpans.experimental.exit_spans.enabled',
|
|
833
|
+
DD_CODE_ORIGIN_FOR_SPANS_EXPERIMENTAL_EXIT_SPANS_ENABLED
|
|
834
|
+
)
|
|
828
835
|
this._setString(env, 'dbmPropagationMode', DD_DBM_PROPAGATION_MODE)
|
|
829
836
|
this._setString(env, 'dogstatsd.hostname', DD_DOGSTATSD_HOST || DD_DOGSTATSD_HOSTNAME)
|
|
830
837
|
this._setString(env, 'dogstatsd.port', DD_DOGSTATSD_PORT)
|
|
@@ -1029,6 +1036,11 @@ class Config {
|
|
|
1029
1036
|
this._setValue(opts, 'baggageMaxBytes', options.baggageMaxBytes)
|
|
1030
1037
|
this._setValue(opts, 'baggageMaxItems', options.baggageMaxItems)
|
|
1031
1038
|
this._setBoolean(opts, 'codeOriginForSpans.enabled', options.codeOriginForSpans?.enabled)
|
|
1039
|
+
this._setBoolean(
|
|
1040
|
+
opts,
|
|
1041
|
+
'codeOriginForSpans.experimental.exit_spans.enabled',
|
|
1042
|
+
options.codeOriginForSpans?.experimental?.exit_spans?.enabled
|
|
1043
|
+
)
|
|
1032
1044
|
this._setString(opts, 'dbmPropagationMode', options.dbmPropagationMode)
|
|
1033
1045
|
if (options.dogstatsd) {
|
|
1034
1046
|
this._setString(opts, 'dogstatsd.hostname', options.dogstatsd.hostname)
|
|
@@ -175,11 +175,13 @@ async function updateBreakpoint (breakpoint, probe) {
|
|
|
175
175
|
|
|
176
176
|
function start () {
|
|
177
177
|
sessionStarted = true
|
|
178
|
+
log.debug('[debugger:devtools_client] Starting debugger')
|
|
178
179
|
return session.post('Debugger.enable')
|
|
179
180
|
}
|
|
180
181
|
|
|
181
182
|
function stop () {
|
|
182
183
|
sessionStarted = false
|
|
184
|
+
log.debug('[debugger:devtools_client] Stopping debugger')
|
|
183
185
|
return session.post('Debugger.disable')
|
|
184
186
|
}
|
|
185
187
|
|