dd-trace 5.46.0 → 5.48.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 +1 -2
- package/index.d.ts +39 -0
- package/package.json +8 -9
- package/packages/datadog-instrumentations/orchestrion.yml +52 -0
- package/packages/datadog-instrumentations/src/cucumber.js +2 -1
- package/packages/datadog-instrumentations/src/jest.js +11 -2
- package/packages/datadog-instrumentations/src/langchain.js +49 -53
- package/packages/datadog-instrumentations/src/mocha/main.js +1 -1
- package/packages/datadog-instrumentations/src/mocha/utils.js +11 -3
- package/packages/datadog-instrumentations/src/orchestrion-config/index.js +5 -0
- package/packages/datadog-instrumentations/src/playwright.js +14 -2
- package/packages/datadog-instrumentations/src/vitest.js +11 -3
- package/packages/datadog-plugin-cucumber/src/index.js +11 -4
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +17 -5
- package/packages/datadog-plugin-jest/src/index.js +11 -4
- package/packages/datadog-plugin-langchain/src/index.js +18 -12
- package/packages/datadog-plugin-langchain/src/tracing.js +66 -6
- package/packages/datadog-plugin-mocha/src/index.js +17 -5
- package/packages/datadog-plugin-mongodb-core/src/index.js +5 -1
- package/packages/datadog-plugin-playwright/src/index.js +10 -3
- package/packages/datadog-plugin-vitest/src/index.js +13 -8
- package/packages/datadog-shimmer/src/shimmer.js +3 -42
- package/packages/dd-trace/src/appsec/iast/taint-tracking/filter.js +3 -3
- package/packages/dd-trace/src/appsec/iast/taint-tracking/index.js +0 -3
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter-esm.mjs +24 -11
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter-telemetry.js +3 -32
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +98 -56
- package/packages/dd-trace/src/appsec/sdk/index.js +23 -1
- package/packages/dd-trace/src/appsec/sdk/noop.js +10 -0
- package/packages/dd-trace/src/appsec/sdk/set_user.js +2 -1
- package/packages/dd-trace/src/appsec/sdk/track_event.js +129 -8
- package/packages/dd-trace/src/appsec/sdk/user_blocking.js +0 -1
- package/packages/dd-trace/src/appsec/telemetry/index.js +2 -2
- package/packages/dd-trace/src/appsec/telemetry/user.js +2 -2
- package/packages/dd-trace/src/config.js +9 -0
- package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +14 -1
- package/packages/dd-trace/src/debugger/devtools_client/condition.js +36 -2
- package/packages/dd-trace/src/debugger/devtools_client/index.js +75 -33
- package/packages/dd-trace/src/debugger/devtools_client/send.js +4 -1
- package/packages/dd-trace/src/debugger/devtools_client/source-maps.js +1 -1
- package/packages/dd-trace/src/exporters/common/docker.js +37 -7
- package/packages/dd-trace/src/exporters/common/request.js +1 -4
- package/packages/dd-trace/src/llmobs/plugins/base.js +2 -2
- package/packages/dd-trace/src/llmobs/plugins/langchain/index.js +62 -3
- package/packages/dd-trace/src/llmobs/plugins/openai.js +1 -0
- package/packages/dd-trace/src/llmobs/plugins/vertexai.js +2 -1
- package/packages/dd-trace/src/log/index.js +2 -0
- package/packages/dd-trace/src/log/writer.js +19 -2
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +17 -3
- package/packages/dd-trace/src/opentracing/span.js +10 -0
- package/packages/dd-trace/src/plugins/util/test.js +7 -0
- package/packages/dd-trace/src/profiling/exporters/agent.js +1 -5
- package/packages/dd-trace/src/profiling/profilers/wall.js +3 -1
- package/packages/dd-trace/src/proxy.js +5 -1
|
@@ -30,7 +30,8 @@ const {
|
|
|
30
30
|
TEST_MANAGEMENT_IS_DISABLED,
|
|
31
31
|
TEST_MANAGEMENT_IS_ATTEMPT_TO_FIX,
|
|
32
32
|
TEST_MANAGEMENT_ATTEMPT_TO_FIX_PASSED,
|
|
33
|
-
TEST_HAS_FAILED_ALL_RETRIES
|
|
33
|
+
TEST_HAS_FAILED_ALL_RETRIES,
|
|
34
|
+
TEST_RETRY_REASON_TYPES
|
|
34
35
|
} = require('../../dd-trace/src/plugins/util/test')
|
|
35
36
|
const { COMPONENT } = require('../../dd-trace/src/constants')
|
|
36
37
|
const id = require('../../dd-trace/src/id')
|
|
@@ -344,7 +345,8 @@ class JestPlugin extends CiPlugin {
|
|
|
344
345
|
status,
|
|
345
346
|
testStartLine,
|
|
346
347
|
attemptToFixPassed,
|
|
347
|
-
failedAllTests
|
|
348
|
+
failedAllTests,
|
|
349
|
+
isAtrRetry
|
|
348
350
|
}) => {
|
|
349
351
|
const span = storage('legacy').getStore().span
|
|
350
352
|
span.setTag(TEST_STATUS, status)
|
|
@@ -357,6 +359,10 @@ class JestPlugin extends CiPlugin {
|
|
|
357
359
|
if (failedAllTests) {
|
|
358
360
|
span.setTag(TEST_HAS_FAILED_ALL_RETRIES, 'true')
|
|
359
361
|
}
|
|
362
|
+
if (isAtrRetry) {
|
|
363
|
+
span.setTag(TEST_IS_RETRY, 'true')
|
|
364
|
+
span.setTag(TEST_RETRY_REASON, TEST_RETRY_REASON_TYPES.atr)
|
|
365
|
+
}
|
|
360
366
|
|
|
361
367
|
const spanTags = span.context()._tags
|
|
362
368
|
this.telemetry.ciVisEvent(
|
|
@@ -447,7 +453,7 @@ class JestPlugin extends CiPlugin {
|
|
|
447
453
|
|
|
448
454
|
if (isAttemptToFixRetry) {
|
|
449
455
|
extraTags[TEST_IS_RETRY] = 'true'
|
|
450
|
-
extraTags[TEST_RETRY_REASON] =
|
|
456
|
+
extraTags[TEST_RETRY_REASON] = TEST_RETRY_REASON_TYPES.atf
|
|
451
457
|
}
|
|
452
458
|
|
|
453
459
|
if (isDisabled) {
|
|
@@ -462,12 +468,13 @@ class JestPlugin extends CiPlugin {
|
|
|
462
468
|
extraTags[TEST_IS_NEW] = 'true'
|
|
463
469
|
if (isEfdRetry) {
|
|
464
470
|
extraTags[TEST_IS_RETRY] = 'true'
|
|
465
|
-
extraTags[TEST_RETRY_REASON] =
|
|
471
|
+
extraTags[TEST_RETRY_REASON] = TEST_RETRY_REASON_TYPES.efd
|
|
466
472
|
}
|
|
467
473
|
}
|
|
468
474
|
|
|
469
475
|
if (isJestRetry) {
|
|
470
476
|
extraTags[TEST_IS_RETRY] = 'true'
|
|
477
|
+
extraTags[TEST_RETRY_REASON] = TEST_RETRY_REASON_TYPES.ext
|
|
471
478
|
}
|
|
472
479
|
|
|
473
480
|
return super.startTestSpan(name, suite, this.testSuiteSpan, extraTags)
|
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const
|
|
3
|
+
const langChainTracingPlugins = require('./tracing')
|
|
4
|
+
const langChainLLMObsPlugins = require('../../dd-trace/src/llmobs/plugins/langchain')
|
|
5
|
+
// const LangChainLLMObsPlugin = require('../../dd-trace/src/llmobs/plugins/langchain')
|
|
5
6
|
const CompositePlugin = require('../../dd-trace/src/plugins/composite')
|
|
6
7
|
|
|
8
|
+
const plugins = {}
|
|
9
|
+
|
|
10
|
+
// ordering here is important - the llm observability plugin must come first
|
|
11
|
+
// so that we can add annotations associated with the span before it finishes.
|
|
12
|
+
// however, because the tracing plugin uses `bindStart` vs the llmobs' `start`,
|
|
13
|
+
// the span is guaranteed to be created in the tracing plugin before the llmobs one is called
|
|
14
|
+
for (const Plugin of langChainLLMObsPlugins) {
|
|
15
|
+
plugins[Plugin.id] = Plugin
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
for (const Plugin of langChainTracingPlugins) {
|
|
19
|
+
plugins[Plugin.id] = Plugin
|
|
20
|
+
}
|
|
21
|
+
|
|
7
22
|
class LangChainPlugin extends CompositePlugin {
|
|
8
23
|
static get id () { return 'langchain' }
|
|
9
|
-
static get plugins () {
|
|
10
|
-
return {
|
|
11
|
-
// ordering here is important - the llm observability plugin must come first
|
|
12
|
-
// so that we can add annotations associated with the span before it finishes.
|
|
13
|
-
// however, because the tracing plugin uses `bindStart` vs the llmobs' `start`,
|
|
14
|
-
// the span is guaranteed to be created in the tracing plugin before the llmobs one is called
|
|
15
|
-
llmobs: LangChainLLMObsPlugin,
|
|
16
|
-
tracing: LangChainTracingPlugin
|
|
17
|
-
}
|
|
18
|
-
}
|
|
24
|
+
static get plugins () { return plugins }
|
|
19
25
|
}
|
|
20
26
|
|
|
21
27
|
module.exports = LangChainPlugin
|
|
@@ -15,13 +15,10 @@ const LangChainLLMHandler = require('./handlers/language_models/llm')
|
|
|
15
15
|
const LangChainChainHandler = require('./handlers/chain')
|
|
16
16
|
const LangChainEmbeddingHandler = require('./handlers/embedding')
|
|
17
17
|
|
|
18
|
-
class
|
|
18
|
+
class BaseLangChainTracingPlugin extends TracingPlugin {
|
|
19
19
|
static get id () { return 'langchain' }
|
|
20
20
|
static get operation () { return 'invoke' }
|
|
21
21
|
static get system () { return 'langchain' }
|
|
22
|
-
static get prefix () {
|
|
23
|
-
return 'tracing:apm:langchain:invoke'
|
|
24
|
-
}
|
|
25
22
|
|
|
26
23
|
constructor () {
|
|
27
24
|
super(...arguments)
|
|
@@ -36,7 +33,15 @@ class LangChainTracingPlugin extends TracingPlugin {
|
|
|
36
33
|
}
|
|
37
34
|
|
|
38
35
|
bindStart (ctx) {
|
|
39
|
-
|
|
36
|
+
// TODO(bengl): All this renaming is just so we don't have to change the existing handlers
|
|
37
|
+
ctx.args = ctx.arguments
|
|
38
|
+
ctx.instance = ctx.self
|
|
39
|
+
const type = ctx.type = this.constructor.lcType
|
|
40
|
+
|
|
41
|
+
// Runnable interfaces have an `lc_namespace` property
|
|
42
|
+
const ns = ctx.self.lc_namespace || ctx.namespace
|
|
43
|
+
const resource = ctx.resource = [...ns, ctx.self.constructor.name].join('.')
|
|
44
|
+
|
|
40
45
|
const handler = this.handlers[type]
|
|
41
46
|
|
|
42
47
|
const instance = ctx.instance
|
|
@@ -85,4 +90,59 @@ class LangChainTracingPlugin extends TracingPlugin {
|
|
|
85
90
|
}
|
|
86
91
|
}
|
|
87
92
|
|
|
88
|
-
|
|
93
|
+
class RunnableSequenceInvokePlugin extends BaseLangChainTracingPlugin {
|
|
94
|
+
static get id () { return 'langchain_rs_invoke' }
|
|
95
|
+
static get lcType () { return 'chain' }
|
|
96
|
+
static get prefix () {
|
|
97
|
+
return 'tracing:orchestrion:@langchain/core:RunnableSequence_invoke'
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
class RunnableSequenceBatchPlugin extends BaseLangChainTracingPlugin {
|
|
102
|
+
static get id () { return 'langchain_rs_batch' }
|
|
103
|
+
static get lcType () { return 'chain' }
|
|
104
|
+
static get prefix () {
|
|
105
|
+
return 'tracing:orchestrion:@langchain/core:RunnableSequence_batch'
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
class BaseChatModelGeneratePlugin extends BaseLangChainTracingPlugin {
|
|
110
|
+
static get id () { return 'langchain_chat_model_generate' }
|
|
111
|
+
static get lcType () { return 'chat_model' }
|
|
112
|
+
static get prefix () {
|
|
113
|
+
return 'tracing:orchestrion:@langchain/core:BaseChatModel_generate'
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
class BaseLLMGeneratePlugin extends BaseLangChainTracingPlugin {
|
|
118
|
+
static get id () { return 'langchain_llm_generate' }
|
|
119
|
+
static get lcType () { return 'llm' }
|
|
120
|
+
static get prefix () {
|
|
121
|
+
return 'tracing:orchestrion:@langchain/core:BaseLLM_generate'
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
class EmbeddingsEmbedQueryPlugin extends BaseLangChainTracingPlugin {
|
|
126
|
+
static get id () { return 'langchain_embeddings_embed_query' }
|
|
127
|
+
static get lcType () { return 'embedding' }
|
|
128
|
+
static get prefix () {
|
|
129
|
+
return 'tracing:apm:@langchain/core:Embeddings_embedQuery'
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
class EmbeddingsEmbedDocumentsPlugin extends BaseLangChainTracingPlugin {
|
|
134
|
+
static get id () { return 'langchain_embeddings_embed_documents' }
|
|
135
|
+
static get lcType () { return 'embedding' }
|
|
136
|
+
static get prefix () {
|
|
137
|
+
return 'tracing:apm:@langchain/core:Embeddings_embedDocuments'
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
module.exports = [
|
|
142
|
+
RunnableSequenceInvokePlugin,
|
|
143
|
+
RunnableSequenceBatchPlugin,
|
|
144
|
+
BaseChatModelGeneratePlugin,
|
|
145
|
+
BaseLLMGeneratePlugin,
|
|
146
|
+
EmbeddingsEmbedQueryPlugin,
|
|
147
|
+
EmbeddingsEmbedDocumentsPlugin
|
|
148
|
+
]
|
|
@@ -36,7 +36,8 @@ const {
|
|
|
36
36
|
TEST_MANAGEMENT_IS_DISABLED,
|
|
37
37
|
TEST_MANAGEMENT_IS_ATTEMPT_TO_FIX,
|
|
38
38
|
TEST_HAS_FAILED_ALL_RETRIES,
|
|
39
|
-
TEST_MANAGEMENT_ATTEMPT_TO_FIX_PASSED
|
|
39
|
+
TEST_MANAGEMENT_ATTEMPT_TO_FIX_PASSED,
|
|
40
|
+
TEST_RETRY_REASON_TYPES
|
|
40
41
|
} = require('../../dd-trace/src/plugins/util/test')
|
|
41
42
|
const { COMPONENT } = require('../../dd-trace/src/constants')
|
|
42
43
|
const {
|
|
@@ -207,7 +208,8 @@ class MochaPlugin extends CiPlugin {
|
|
|
207
208
|
isLastRetry,
|
|
208
209
|
hasFailedAllRetries,
|
|
209
210
|
attemptToFixPassed,
|
|
210
|
-
isAttemptToFixRetry
|
|
211
|
+
isAttemptToFixRetry,
|
|
212
|
+
isAtrRetry
|
|
211
213
|
}) => {
|
|
212
214
|
const store = storage('legacy').getStore()
|
|
213
215
|
const span = store?.span
|
|
@@ -216,6 +218,11 @@ class MochaPlugin extends CiPlugin {
|
|
|
216
218
|
span.setTag(TEST_STATUS, status)
|
|
217
219
|
if (hasBeenRetried) {
|
|
218
220
|
span.setTag(TEST_IS_RETRY, 'true')
|
|
221
|
+
if (isAtrRetry) {
|
|
222
|
+
span.setTag(TEST_RETRY_REASON, TEST_RETRY_REASON_TYPES.atr)
|
|
223
|
+
} else {
|
|
224
|
+
span.setTag(TEST_RETRY_REASON, TEST_RETRY_REASON_TYPES.ext)
|
|
225
|
+
}
|
|
219
226
|
}
|
|
220
227
|
if (hasFailedAllRetries) {
|
|
221
228
|
span.setTag(TEST_HAS_FAILED_ALL_RETRIES, 'true')
|
|
@@ -225,7 +232,7 @@ class MochaPlugin extends CiPlugin {
|
|
|
225
232
|
}
|
|
226
233
|
if (isAttemptToFixRetry) {
|
|
227
234
|
span.setTag(TEST_IS_RETRY, 'true')
|
|
228
|
-
span.setTag(TEST_RETRY_REASON,
|
|
235
|
+
span.setTag(TEST_RETRY_REASON, TEST_RETRY_REASON_TYPES.atf)
|
|
229
236
|
}
|
|
230
237
|
|
|
231
238
|
const spanTags = span.context()._tags
|
|
@@ -273,13 +280,18 @@ class MochaPlugin extends CiPlugin {
|
|
|
273
280
|
}
|
|
274
281
|
})
|
|
275
282
|
|
|
276
|
-
this.addSub('ci:mocha:test:retry', ({ isFirstAttempt, willBeRetried, err, test }) => {
|
|
283
|
+
this.addSub('ci:mocha:test:retry', ({ isFirstAttempt, willBeRetried, err, test, isAtrRetry }) => {
|
|
277
284
|
const store = storage('legacy').getStore()
|
|
278
285
|
const span = store?.span
|
|
279
286
|
if (span) {
|
|
280
287
|
span.setTag(TEST_STATUS, 'fail')
|
|
281
288
|
if (!isFirstAttempt) {
|
|
282
289
|
span.setTag(TEST_IS_RETRY, 'true')
|
|
290
|
+
if (isAtrRetry) {
|
|
291
|
+
span.setTag(TEST_RETRY_REASON, TEST_RETRY_REASON_TYPES.atr)
|
|
292
|
+
} else {
|
|
293
|
+
span.setTag(TEST_RETRY_REASON, TEST_RETRY_REASON_TYPES.ext)
|
|
294
|
+
}
|
|
283
295
|
}
|
|
284
296
|
if (err) {
|
|
285
297
|
span.setTag('error', err)
|
|
@@ -473,7 +485,7 @@ class MochaPlugin extends CiPlugin {
|
|
|
473
485
|
extraTags[TEST_IS_NEW] = 'true'
|
|
474
486
|
if (isEfdRetry) {
|
|
475
487
|
extraTags[TEST_IS_RETRY] = 'true'
|
|
476
|
-
extraTags[TEST_RETRY_REASON] = '
|
|
488
|
+
extraTags[TEST_RETRY_REASON] = 'early_flake_detection'
|
|
477
489
|
}
|
|
478
490
|
}
|
|
479
491
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const { isTrue } = require('../../dd-trace/src/util')
|
|
3
4
|
const DatabasePlugin = require('../../dd-trace/src/plugins/database')
|
|
4
5
|
const coalesce = require('koalas')
|
|
5
6
|
|
|
@@ -12,9 +13,12 @@ class MongodbCorePlugin extends DatabasePlugin {
|
|
|
12
13
|
|
|
13
14
|
configure (config) {
|
|
14
15
|
super.configure(config)
|
|
16
|
+
|
|
17
|
+
const heartbeatFromEnv = process.env.DD_TRACE_MONGODB_HEARTBEAT_ENABLED
|
|
18
|
+
|
|
15
19
|
this.config.heartbeatEnabled = coalesce(
|
|
16
20
|
config.heartbeatEnabled,
|
|
17
|
-
|
|
21
|
+
heartbeatFromEnv && isTrue(heartbeatFromEnv),
|
|
18
22
|
true
|
|
19
23
|
)
|
|
20
24
|
}
|
|
@@ -33,7 +33,8 @@ const {
|
|
|
33
33
|
TEST_SUITE_ID,
|
|
34
34
|
TEST_NAME,
|
|
35
35
|
TEST_IS_RUM_ACTIVE,
|
|
36
|
-
TEST_BROWSER_VERSION
|
|
36
|
+
TEST_BROWSER_VERSION,
|
|
37
|
+
TEST_RETRY_REASON_TYPES
|
|
37
38
|
} = require('../../dd-trace/src/plugins/util/test')
|
|
38
39
|
const { RESOURCE_NAME } = require('../../../ext/tags')
|
|
39
40
|
const { COMPONENT } = require('../../dd-trace/src/constants')
|
|
@@ -266,6 +267,7 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
266
267
|
isAttemptToFixRetry,
|
|
267
268
|
hasFailedAllRetries,
|
|
268
269
|
hasPassedAttemptToFixRetries,
|
|
270
|
+
isAtrRetry,
|
|
269
271
|
onDone
|
|
270
272
|
}) => {
|
|
271
273
|
const store = storage('legacy').getStore()
|
|
@@ -286,11 +288,16 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
286
288
|
span.setTag(TEST_IS_NEW, 'true')
|
|
287
289
|
if (isEfdRetry) {
|
|
288
290
|
span.setTag(TEST_IS_RETRY, 'true')
|
|
289
|
-
span.setTag(TEST_RETRY_REASON,
|
|
291
|
+
span.setTag(TEST_RETRY_REASON, TEST_RETRY_REASON_TYPES.efd)
|
|
290
292
|
}
|
|
291
293
|
}
|
|
292
294
|
if (isRetry) {
|
|
293
295
|
span.setTag(TEST_IS_RETRY, 'true')
|
|
296
|
+
if (isAtrRetry) {
|
|
297
|
+
span.setTag(TEST_RETRY_REASON, TEST_RETRY_REASON_TYPES.atr)
|
|
298
|
+
} else {
|
|
299
|
+
span.setTag(TEST_RETRY_REASON, TEST_RETRY_REASON_TYPES.ext)
|
|
300
|
+
}
|
|
294
301
|
}
|
|
295
302
|
if (hasFailedAllRetries) {
|
|
296
303
|
span.setTag(TEST_HAS_FAILED_ALL_RETRIES, 'true')
|
|
@@ -300,7 +307,7 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
300
307
|
}
|
|
301
308
|
if (isAttemptToFixRetry) {
|
|
302
309
|
span.setTag(TEST_IS_RETRY, 'true')
|
|
303
|
-
span.setTag(TEST_RETRY_REASON,
|
|
310
|
+
span.setTag(TEST_RETRY_REASON, TEST_RETRY_REASON_TYPES.atf)
|
|
304
311
|
}
|
|
305
312
|
if (hasPassedAttemptToFixRetries) {
|
|
306
313
|
span.setTag(TEST_MANAGEMENT_ATTEMPT_TO_FIX_PASSED, 'true')
|
|
@@ -25,7 +25,8 @@ const {
|
|
|
25
25
|
TEST_MANAGEMENT_IS_ATTEMPT_TO_FIX,
|
|
26
26
|
TEST_MANAGEMENT_ATTEMPT_TO_FIX_PASSED,
|
|
27
27
|
TEST_HAS_FAILED_ALL_RETRIES,
|
|
28
|
-
getLibraryCapabilitiesTags
|
|
28
|
+
getLibraryCapabilitiesTags,
|
|
29
|
+
TEST_RETRY_REASON_TYPES
|
|
29
30
|
} = require('../../dd-trace/src/plugins/util/test')
|
|
30
31
|
const { COMPONENT } = require('../../dd-trace/src/constants')
|
|
31
32
|
const {
|
|
@@ -104,7 +105,8 @@ class VitestPlugin extends CiPlugin {
|
|
|
104
105
|
isDisabled,
|
|
105
106
|
mightHitProbe,
|
|
106
107
|
isRetryReasonEfd,
|
|
107
|
-
isRetryReasonAttemptToFix
|
|
108
|
+
isRetryReasonAttemptToFix,
|
|
109
|
+
isRetryReasonAtr
|
|
108
110
|
}) => {
|
|
109
111
|
const testSuite = getTestSuitePath(testSuiteAbsolutePath, this.repositoryRoot)
|
|
110
112
|
const store = storage('legacy').getStore()
|
|
@@ -114,19 +116,22 @@ class VitestPlugin extends CiPlugin {
|
|
|
114
116
|
}
|
|
115
117
|
if (isRetry) {
|
|
116
118
|
extraTags[TEST_IS_RETRY] = 'true'
|
|
119
|
+
if (isRetryReasonAttemptToFix) {
|
|
120
|
+
extraTags[TEST_RETRY_REASON] = TEST_RETRY_REASON_TYPES.atf
|
|
121
|
+
} else if (isRetryReasonEfd) {
|
|
122
|
+
extraTags[TEST_RETRY_REASON] = TEST_RETRY_REASON_TYPES.efd
|
|
123
|
+
} else if (isRetryReasonAtr) {
|
|
124
|
+
extraTags[TEST_RETRY_REASON] = TEST_RETRY_REASON_TYPES.atr
|
|
125
|
+
} else {
|
|
126
|
+
extraTags[TEST_RETRY_REASON] = TEST_RETRY_REASON_TYPES.ext
|
|
127
|
+
}
|
|
117
128
|
}
|
|
118
129
|
if (isNew) {
|
|
119
130
|
extraTags[TEST_IS_NEW] = 'true'
|
|
120
131
|
}
|
|
121
|
-
if (isRetryReasonEfd) {
|
|
122
|
-
extraTags[TEST_RETRY_REASON] = 'efd'
|
|
123
|
-
}
|
|
124
132
|
if (isAttemptToFix) {
|
|
125
133
|
extraTags[TEST_MANAGEMENT_IS_ATTEMPT_TO_FIX] = 'true'
|
|
126
134
|
}
|
|
127
|
-
if (isRetryReasonAttemptToFix) {
|
|
128
|
-
extraTags[TEST_RETRY_REASON] = 'attempt_to_fix'
|
|
129
|
-
}
|
|
130
135
|
if (isQuarantined) {
|
|
131
136
|
extraTags[TEST_MANAGEMENT_IS_QUARANTINED] = 'true'
|
|
132
137
|
}
|
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
const log = require('../../dd-trace/src/log')
|
|
4
4
|
|
|
5
|
-
// Use a weak map to avoid polluting the wrapped function/method.
|
|
6
|
-
const unwrappers = new WeakMap()
|
|
7
|
-
|
|
8
5
|
function copyProperties (original, wrapped) {
|
|
9
6
|
// TODO getPrototypeOf is not fast. Should we instead do this in specific
|
|
10
7
|
// instrumentations where needed?
|
|
@@ -27,21 +24,13 @@ function copyProperties (original, wrapped) {
|
|
|
27
24
|
function wrapFunction (original, wrapper) {
|
|
28
25
|
if (typeof original === 'function') assertNotClass(original)
|
|
29
26
|
|
|
30
|
-
|
|
27
|
+
const wrapped = safeMode
|
|
31
28
|
? safeWrapper(original, wrapper)
|
|
32
29
|
: wrapper(original)
|
|
33
30
|
|
|
34
|
-
|
|
35
|
-
return delegate.apply(this, arguments)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
unwrappers.set(shim, () => {
|
|
39
|
-
delegate = original
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
if (typeof original === 'function') copyProperties(original, shim)
|
|
31
|
+
if (typeof original === 'function') copyProperties(original, wrapped)
|
|
43
32
|
|
|
44
|
-
return
|
|
33
|
+
return wrapped
|
|
45
34
|
}
|
|
46
35
|
|
|
47
36
|
const wrapFn = function (original, delegate) {
|
|
@@ -99,8 +88,6 @@ function wrapMethod (target, name, wrapper, noAssert) {
|
|
|
99
88
|
if (typeof original === 'function') copyProperties(original, wrapped)
|
|
100
89
|
|
|
101
90
|
if (descriptor) {
|
|
102
|
-
unwrappers.set(wrapped, () => Object.defineProperty(target, name, descriptor))
|
|
103
|
-
|
|
104
91
|
if (descriptor.get || descriptor.set) {
|
|
105
92
|
attributes.get = () => wrapped
|
|
106
93
|
} else {
|
|
@@ -114,7 +101,6 @@ function wrapMethod (target, name, wrapper, noAssert) {
|
|
|
114
101
|
})
|
|
115
102
|
}
|
|
116
103
|
} else { // no descriptor means original was on the prototype
|
|
117
|
-
unwrappers.set(wrapped, () => delete target[name])
|
|
118
104
|
attributes.value = wrapped
|
|
119
105
|
attributes.writable = true
|
|
120
106
|
}
|
|
@@ -218,18 +204,6 @@ function wrap (target, name, wrapper) {
|
|
|
218
204
|
: wrapMethod(target, name, wrapper)
|
|
219
205
|
}
|
|
220
206
|
|
|
221
|
-
function unwrap (target, name) {
|
|
222
|
-
if (!target) return target // no target to unwrap
|
|
223
|
-
|
|
224
|
-
const unwrapper = unwrappers.get(name ? target[name] : target)
|
|
225
|
-
|
|
226
|
-
if (!unwrapper) return target // target is already unwrapped or isn't wrapped
|
|
227
|
-
|
|
228
|
-
unwrapper()
|
|
229
|
-
|
|
230
|
-
return target
|
|
231
|
-
}
|
|
232
|
-
|
|
233
207
|
function massWrap (targets, names, wrapper) {
|
|
234
208
|
targets = toArray(targets)
|
|
235
209
|
names = toArray(names)
|
|
@@ -241,17 +215,6 @@ function massWrap (targets, names, wrapper) {
|
|
|
241
215
|
}
|
|
242
216
|
}
|
|
243
217
|
|
|
244
|
-
function massUnwrap (targets, names) {
|
|
245
|
-
targets = toArray(targets)
|
|
246
|
-
names = toArray(names)
|
|
247
|
-
|
|
248
|
-
for (const target of targets) {
|
|
249
|
-
for (const name of names) {
|
|
250
|
-
unwrap(target, name)
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
218
|
function toArray (maybeArray) {
|
|
256
219
|
return Array.isArray(maybeArray) ? maybeArray : [maybeArray]
|
|
257
220
|
}
|
|
@@ -294,7 +257,5 @@ module.exports = {
|
|
|
294
257
|
wrap,
|
|
295
258
|
wrapFunction,
|
|
296
259
|
massWrap,
|
|
297
|
-
unwrap,
|
|
298
|
-
massUnwrap,
|
|
299
260
|
setSafe
|
|
300
261
|
}
|
|
@@ -6,11 +6,11 @@ const isPrivateModule = function (file) {
|
|
|
6
6
|
return file && file.indexOf(NODE_MODULES) === -1
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
const
|
|
10
|
-
return file && file.indexOf('dd-trace-js')
|
|
9
|
+
const isDdTrace = function (file) {
|
|
10
|
+
return file && (file.indexOf('dd-trace-js') !== -1 || file.indexOf('dd-trace') !== -1)
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
module.exports = {
|
|
14
14
|
isPrivateModule,
|
|
15
|
-
|
|
15
|
+
isDdTrace
|
|
16
16
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const { enableRewriter, disableRewriter } = require('./rewriter')
|
|
4
3
|
const {
|
|
5
4
|
createTransaction,
|
|
6
5
|
removeTransaction,
|
|
@@ -16,7 +15,6 @@ const kafkaContextPlugin = require('../context/kafka-ctx-plugin')
|
|
|
16
15
|
|
|
17
16
|
module.exports = {
|
|
18
17
|
enableTaintTracking (config, telemetryVerbosity) {
|
|
19
|
-
enableRewriter(telemetryVerbosity)
|
|
20
18
|
enableTaintOperations(telemetryVerbosity)
|
|
21
19
|
taintTrackingPlugin.enable(config)
|
|
22
20
|
|
|
@@ -26,7 +24,6 @@ module.exports = {
|
|
|
26
24
|
setMaxTransactions(config.maxConcurrentRequests)
|
|
27
25
|
},
|
|
28
26
|
disableTaintTracking () {
|
|
29
|
-
disableRewriter()
|
|
30
27
|
disableTaintOperations()
|
|
31
28
|
taintTrackingPlugin.disable()
|
|
32
29
|
|
|
@@ -3,19 +3,20 @@
|
|
|
3
3
|
import path from 'path'
|
|
4
4
|
import { URL } from 'url'
|
|
5
5
|
import { getName } from '../telemetry/verbosity.js'
|
|
6
|
-
import {
|
|
6
|
+
import { isDdTrace, isPrivateModule } from './filter.js'
|
|
7
7
|
import constants from './constants.js'
|
|
8
8
|
|
|
9
9
|
const currentUrl = new URL(import.meta.url)
|
|
10
10
|
const ddTraceDir = path.join(currentUrl.pathname, '..', '..', '..', '..', '..', '..')
|
|
11
11
|
|
|
12
|
-
let port, rewriter
|
|
12
|
+
let port, rewriter, iastEnabled
|
|
13
13
|
|
|
14
14
|
export async function initialize (data) {
|
|
15
15
|
if (rewriter) return Promise.reject(new Error('ALREADY INITIALIZED'))
|
|
16
16
|
|
|
17
|
-
const { csiMethods, telemetryVerbosity, chainSourceMap } = data
|
|
17
|
+
const { csiMethods, telemetryVerbosity, chainSourceMap, orchestrionConfig } = data
|
|
18
18
|
port = data.port
|
|
19
|
+
iastEnabled = data.iastEnabled
|
|
19
20
|
|
|
20
21
|
const iastRewriter = await import('@datadog/wasm-js-rewriter')
|
|
21
22
|
|
|
@@ -24,7 +25,8 @@ export async function initialize (data) {
|
|
|
24
25
|
rewriter = new NonCacheRewriter({
|
|
25
26
|
csiMethods,
|
|
26
27
|
telemetryVerbosity: getName(telemetryVerbosity),
|
|
27
|
-
chainSourceMap
|
|
28
|
+
chainSourceMap,
|
|
29
|
+
orchestrion: orchestrionConfig
|
|
28
30
|
})
|
|
29
31
|
}
|
|
30
32
|
|
|
@@ -35,15 +37,26 @@ export async function load (url, context, nextLoad) {
|
|
|
35
37
|
if (!result.source) return result
|
|
36
38
|
if (url.includes(ddTraceDir) || url.includes('iitm=true')) return result
|
|
37
39
|
|
|
40
|
+
let passes
|
|
38
41
|
try {
|
|
39
|
-
if (
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
if (isDdTrace(url)) {
|
|
43
|
+
return result
|
|
44
|
+
}
|
|
45
|
+
if (isPrivateModule(url)) {
|
|
46
|
+
// TODO error tracking needs to be added based on config
|
|
47
|
+
passes = ['error_tracking']
|
|
48
|
+
if (iastEnabled) {
|
|
49
|
+
passes.push('iast')
|
|
46
50
|
}
|
|
51
|
+
} else {
|
|
52
|
+
passes = ['orchestrion']
|
|
53
|
+
}
|
|
54
|
+
const rewritten = rewriter.rewrite(result.source.toString(), url, passes)
|
|
55
|
+
|
|
56
|
+
if (rewritten?.content) {
|
|
57
|
+
result.source = rewritten.content || result.source
|
|
58
|
+
const data = { url, rewritten }
|
|
59
|
+
port.postMessage({ type: constants.REWRITTEN_MESSAGE, data })
|
|
47
60
|
}
|
|
48
61
|
} catch (e) {
|
|
49
62
|
const newErrObject = {
|
|
@@ -4,39 +4,10 @@ const iastTelemetry = require('../telemetry')
|
|
|
4
4
|
const { Verbosity } = require('../telemetry/verbosity')
|
|
5
5
|
const { INSTRUMENTED_PROPAGATION } = require('../telemetry/iast-metric')
|
|
6
6
|
|
|
7
|
-
const telemetryRewriter = {
|
|
8
|
-
off (content, filename, rewriter) {
|
|
9
|
-
return rewriter.rewrite(content, filename)
|
|
10
|
-
},
|
|
11
|
-
|
|
12
|
-
information (content, filename, rewriter) {
|
|
13
|
-
const response = this.off(content, filename, rewriter)
|
|
14
|
-
|
|
15
|
-
incrementTelemetry(response.metrics)
|
|
16
|
-
|
|
17
|
-
return response
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function getRewriteFunction (rewriter) {
|
|
22
|
-
switch (iastTelemetry.verbosity) {
|
|
23
|
-
case Verbosity.OFF:
|
|
24
|
-
return (content, filename) => telemetryRewriter.off(content, filename, rewriter)
|
|
25
|
-
default:
|
|
26
|
-
return (content, filename) => telemetryRewriter.information(content, filename, rewriter)
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function incrementTelemetry (metrics) {
|
|
31
|
-
if (metrics?.instrumentedPropagation) {
|
|
32
|
-
INSTRUMENTED_PROPAGATION.inc(undefined, metrics.instrumentedPropagation)
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
7
|
function incrementTelemetryIfNeeded (metrics) {
|
|
37
|
-
if (iastTelemetry.verbosity !== Verbosity.OFF) {
|
|
38
|
-
|
|
8
|
+
if (iastTelemetry.verbosity !== Verbosity.OFF && metrics?.instrumentedPropagation) {
|
|
9
|
+
INSTRUMENTED_PROPAGATION.inc(undefined, metrics.instrumentedPropagation)
|
|
39
10
|
}
|
|
40
11
|
}
|
|
41
12
|
|
|
42
|
-
module.exports = {
|
|
13
|
+
module.exports = { incrementTelemetryIfNeeded }
|