dd-trace 5.128.0 → 5.129.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +52 -9
- package/package.json +1 -1
- package/packages/datadog-instrumentations/src/cucumber.js +10 -5
- package/packages/datadog-instrumentations/src/cypress-config.js +27 -15
- package/packages/datadog-instrumentations/src/helpers/bundler-register.js +6 -0
- package/packages/datadog-instrumentations/src/helpers/check-require-cache.js +2 -1
- package/packages/datadog-instrumentations/src/helpers/hooks.js +0 -6
- package/packages/datadog-instrumentations/src/helpers/register.js +20 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +41 -4
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +15 -13
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/playwright.js +43 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/webdriverio.js +13 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.js +28 -3
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +4 -0
- package/packages/datadog-instrumentations/src/jest.js +27 -3
- package/packages/datadog-instrumentations/src/mocha/main.js +7 -5
- package/packages/datadog-instrumentations/src/mocha/utils.js +8 -8
- package/packages/datadog-instrumentations/src/playwright-reporter.js +3 -4
- package/packages/datadog-instrumentations/src/playwright.js +47 -6
- package/packages/datadog-instrumentations/src/undici.js +7 -3
- package/packages/datadog-instrumentations/src/vitest-main.js +91 -20
- package/packages/datadog-instrumentations/src/webdriverio.js +28 -12
- package/packages/datadog-instrumentations/src/ws.js +41 -1
- package/packages/datadog-plugin-cucumber/src/index.js +3 -4
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +44 -14
- package/packages/datadog-plugin-cypress/src/index.js +3 -1
- package/packages/datadog-plugin-jest/src/index.js +3 -4
- package/packages/datadog-plugin-mocha/src/index.js +3 -4
- package/packages/datadog-plugin-playwright/src/index.js +11 -6
- package/packages/datadog-plugin-vitest/src/index.js +3 -4
- package/packages/datadog-plugin-ws/src/producer.js +1 -1
- package/packages/datadog-shimmer/src/shimmer.js +14 -10
- package/packages/datadog-turbopack/index.js +4 -1
- package/packages/datadog-turbopack/src/loader.js +6 -2
- package/packages/dd-trace/src/agent/info.js +5 -4
- package/packages/dd-trace/src/config/generated-config-types.d.ts +15 -15
- package/packages/dd-trace/src/config/index.js +7 -6
- package/packages/dd-trace/src/config/supported-configurations.json +11 -0
- package/packages/dd-trace/src/debugger/devtools_client/config.js +2 -1
- package/packages/dd-trace/src/debugger/devtools_client/send.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/redaction.js +5 -3
- package/packages/dd-trace/src/debugger/devtools_client/status.js +1 -1
- package/packages/dd-trace/src/debugger/index.js +1 -1
- package/packages/dd-trace/src/evp_proxy/constants.js +2 -0
- package/packages/dd-trace/src/evp_proxy/direct.js +17 -13
- package/packages/dd-trace/src/evp_proxy/discovery.js +14 -10
- package/packages/dd-trace/src/evp_proxy/path.js +21 -7
- package/packages/dd-trace/src/exporters/common/url.js +33 -2
- package/packages/dd-trace/src/llmobs/prompts/manager.js +10 -2
- package/packages/dd-trace/src/llmobs/prompts/prompt.js +77 -11
- package/packages/dd-trace/src/llmobs/tagger.js +9 -4
- package/packages/dd-trace/src/openfeature/configuration_source.js +4 -1
- package/packages/dd-trace/src/openfeature/flagging_provider.js +3 -3
- package/packages/dd-trace/src/openfeature/index.js +6 -2
- package/packages/dd-trace/src/openfeature/writers/base.js +90 -17
- package/packages/dd-trace/src/openfeature/writers/exposures.js +4 -0
- package/packages/dd-trace/src/openfeature/writers/util.js +104 -33
- package/packages/dd-trace/src/opentracing/tracer.js +3 -3
- package/packages/dd-trace/src/plugin_manager.js +27 -8
- package/packages/dd-trace/src/plugins/ci_plugin.js +1 -1
- package/packages/dd-trace/src/plugins/util/test.js +9 -4
- package/packages/dd-trace/src/proxy.js +2 -2
- package/packages/dd-trace/src/telemetry/send-data.js +2 -1
- package/packages/dd-trace/src/telemetry/telemetry.js +1 -1
- package/packages/dd-trace/src/tracer.js +5 -4
- package/packages/datadog-instrumentations/src/azure-cosmos.js +0 -7
- package/packages/datadog-instrumentations/src/bullmq.js +0 -11
- package/packages/datadog-instrumentations/src/langchain.js +0 -7
- package/packages/datadog-instrumentations/src/langgraph.js +0 -7
- package/packages/datadog-instrumentations/src/mercurius.js +0 -11
package/index.d.ts
CHANGED
|
@@ -4083,13 +4083,13 @@ declare namespace tracer {
|
|
|
4083
4083
|
/** Create a text or chat prompt and its first version. */
|
|
4084
4084
|
createPrompt (
|
|
4085
4085
|
promptId: string,
|
|
4086
|
-
template: string |
|
|
4086
|
+
template: string | PromptTemplateItem[],
|
|
4087
4087
|
options?: CreatePromptOptions
|
|
4088
4088
|
): Promise<PromptResponse>
|
|
4089
4089
|
/** Add a text or chat version to an existing prompt. */
|
|
4090
4090
|
createPromptVersion (
|
|
4091
4091
|
promptId: string,
|
|
4092
|
-
template: string |
|
|
4092
|
+
template: string | PromptTemplateItem[],
|
|
4093
4093
|
options?: CreatePromptVersionOptions
|
|
4094
4094
|
): Promise<PromptVersionResponse>
|
|
4095
4095
|
/** Update prompt metadata. */
|
|
@@ -4113,10 +4113,45 @@ declare namespace tracer {
|
|
|
4113
4113
|
content: string
|
|
4114
4114
|
}
|
|
4115
4115
|
|
|
4116
|
+
/** Provider fields on expanded messages; authored templates remain text-only. */
|
|
4117
|
+
interface FormattedPromptMessage extends PromptTemplateMessage {
|
|
4118
|
+
// The inherited content type stays string for compatibility; tool-only payloads can omit it or contain null.
|
|
4119
|
+
tool_calls?: PromptToolCall[] | null,
|
|
4120
|
+
tool_results?: PromptToolResult[] | null,
|
|
4121
|
+
tool_call_id?: string | null
|
|
4122
|
+
}
|
|
4123
|
+
|
|
4124
|
+
interface PromptToolCall {
|
|
4125
|
+
id?: string | null,
|
|
4126
|
+
type?: string | null,
|
|
4127
|
+
tool_id?: string | null,
|
|
4128
|
+
name?: string | null,
|
|
4129
|
+
arguments?: unknown,
|
|
4130
|
+
function?: {
|
|
4131
|
+
name: string,
|
|
4132
|
+
arguments: string
|
|
4133
|
+
} | null
|
|
4134
|
+
}
|
|
4135
|
+
|
|
4136
|
+
interface PromptToolResult {
|
|
4137
|
+
id?: string | null,
|
|
4138
|
+
type?: string | null,
|
|
4139
|
+
tool_id?: string | null,
|
|
4140
|
+
name?: string | null,
|
|
4141
|
+
result?: unknown
|
|
4142
|
+
}
|
|
4143
|
+
|
|
4144
|
+
interface PromptMessagePlaceholder {
|
|
4145
|
+
type: 'placeholder',
|
|
4146
|
+
name: string
|
|
4147
|
+
}
|
|
4148
|
+
|
|
4149
|
+
type PromptTemplateItem = PromptTemplateMessage | PromptMessagePlaceholder
|
|
4150
|
+
|
|
4116
4151
|
type PromptFallbackValue =
|
|
4117
4152
|
| string
|
|
4118
|
-
|
|
|
4119
|
-
| { template: string |
|
|
4153
|
+
| PromptTemplateItem[]
|
|
4154
|
+
| { template: string | PromptTemplateItem[], version?: string, config?: Record<string, JSONType> }
|
|
4120
4155
|
type PromptFallback = PromptFallbackValue | (() => PromptFallbackValue)
|
|
4121
4156
|
|
|
4122
4157
|
interface GetPromptOptions {
|
|
@@ -4135,13 +4170,15 @@ declare namespace tracer {
|
|
|
4135
4170
|
title?: string,
|
|
4136
4171
|
description?: string,
|
|
4137
4172
|
userVersion?: string,
|
|
4138
|
-
envIds?: string[]
|
|
4173
|
+
envIds?: string[],
|
|
4174
|
+
config?: Record<string, JSONType>
|
|
4139
4175
|
}
|
|
4140
4176
|
|
|
4141
4177
|
interface CreatePromptVersionOptions {
|
|
4142
4178
|
description?: string,
|
|
4143
4179
|
userVersion?: string,
|
|
4144
|
-
envIds?: string[]
|
|
4180
|
+
envIds?: string[],
|
|
4181
|
+
config?: Record<string, JSONType>
|
|
4145
4182
|
}
|
|
4146
4183
|
|
|
4147
4184
|
interface UpdatePromptOptions {
|
|
@@ -4154,14 +4191,16 @@ declare namespace tracer {
|
|
|
4154
4191
|
envIds?: string[]
|
|
4155
4192
|
}
|
|
4156
4193
|
|
|
4194
|
+
// Preserve released output types; placeholder entries and null/omitted tool content are not fully described here.
|
|
4157
4195
|
interface ManagedPrompt {
|
|
4158
4196
|
readonly id: string,
|
|
4159
4197
|
readonly version: string,
|
|
4160
4198
|
readonly source: 'registry' | 'cache' | 'fallback' | 'ff' | 'resolve',
|
|
4161
4199
|
readonly template: string | ReadonlyArray<Readonly<PromptTemplateMessage>>,
|
|
4200
|
+
readonly config: Readonly<Record<string, ReadonlyJSONType>>,
|
|
4162
4201
|
readonly promptUuid?: string,
|
|
4163
4202
|
readonly promptVersionUuid?: string,
|
|
4164
|
-
format (variables?: Record<string, unknown>): string |
|
|
4203
|
+
format (variables?: Record<string, unknown>): string | FormattedPromptMessage[]
|
|
4165
4204
|
toAnnotation (variables?: Record<string, unknown>): Prompt
|
|
4166
4205
|
}
|
|
4167
4206
|
|
|
@@ -4179,7 +4218,8 @@ declare namespace tracer {
|
|
|
4179
4218
|
ml_app?: string,
|
|
4180
4219
|
ml_apps?: string[],
|
|
4181
4220
|
last_version_created_at?: string,
|
|
4182
|
-
extracted_from?: string
|
|
4221
|
+
extracted_from?: string,
|
|
4222
|
+
config?: Record<string, JSONType>
|
|
4183
4223
|
}
|
|
4184
4224
|
|
|
4185
4225
|
interface PromptVersionResponse {
|
|
@@ -4193,7 +4233,8 @@ declare namespace tracer {
|
|
|
4193
4233
|
version_created_at?: string,
|
|
4194
4234
|
author?: string,
|
|
4195
4235
|
description?: string,
|
|
4196
|
-
ml_app?: string
|
|
4236
|
+
ml_app?: string,
|
|
4237
|
+
config?: Record<string, JSONType>
|
|
4197
4238
|
}
|
|
4198
4239
|
|
|
4199
4240
|
interface DeletedPromptResponse {
|
|
@@ -4205,6 +4246,8 @@ declare namespace tracer {
|
|
|
4205
4246
|
/** JSON-serializable value accepted by LLMObs Experiments. */
|
|
4206
4247
|
type JSONType = string | number | boolean | null | JSONType[] | { [key: string]: JSONType }
|
|
4207
4248
|
|
|
4249
|
+
type ReadonlyJSONType = string | number | boolean | null | ReadonlyArray<ReadonlyJSONType> | { readonly [key: string]: ReadonlyJSONType }
|
|
4250
|
+
|
|
4208
4251
|
/**
|
|
4209
4252
|
* A task run over each dataset record during an experiment.
|
|
4210
4253
|
*/
|
package/package.json
CHANGED
|
@@ -142,7 +142,6 @@ let knownTests = {}
|
|
|
142
142
|
let skippedSuites = []
|
|
143
143
|
let isSuitesSkipped = false
|
|
144
144
|
let areAllSuitesSkipped = false
|
|
145
|
-
let hasTestsToRun = false
|
|
146
145
|
let repositoryRoot
|
|
147
146
|
|
|
148
147
|
function shouldRunEarlyFlakeDetection () {
|
|
@@ -1218,7 +1217,6 @@ function getWrappedStart (start, frameworkVersion, isParallel = false, isCoordin
|
|
|
1218
1217
|
}
|
|
1219
1218
|
}
|
|
1220
1219
|
|
|
1221
|
-
hasTestsToRun = isCoordinator ? this.sourcedPickles.length > 0 : this.pickleIds.length > 0
|
|
1222
1220
|
pickleByFile = isCoordinator ? getPickleByFileNew(this) : getPickleByFile(this)
|
|
1223
1221
|
|
|
1224
1222
|
if (isKnownTestsEnabled) {
|
|
@@ -1330,10 +1328,17 @@ function getWrappedStart (start, frameworkVersion, isParallel = false, isCoordin
|
|
|
1330
1328
|
global.__coverage__ = fromCoverageMapToCoverage(originalCoverageMap)
|
|
1331
1329
|
}
|
|
1332
1330
|
|
|
1333
|
-
const
|
|
1331
|
+
const testCaseAttempts = (this.eventDataCollector || eventDataCollector).getTestCaseAttempts()
|
|
1332
|
+
const getStatus = satisfies(frameworkVersion, '>=7.3.0') ? getStatusFromResultLatest : getStatusFromResult
|
|
1333
|
+
const hasExecutedTests = testCaseAttempts.some(({ worstTestStepResult }) =>
|
|
1334
|
+
getStatus(worstTestStepResult).status !== 'skip'
|
|
1335
|
+
)
|
|
1336
|
+
const testSessionEmptyReason = success && !hasExecutedTests
|
|
1337
|
+
? (testCaseAttempts.length > 0 || skippedSuites.length > 0 ? 'all_tests_skipped' : 'zero_tests')
|
|
1338
|
+
: undefined
|
|
1334
1339
|
const flushPromise = getChannelPromise(sessionFinishCh, {
|
|
1335
|
-
status:
|
|
1336
|
-
|
|
1340
|
+
status: testSessionEmptyReason ? 'skip' : (success ? 'pass' : 'fail'),
|
|
1341
|
+
testSessionEmptyReason,
|
|
1337
1342
|
isSuitesSkipped,
|
|
1338
1343
|
testCodeCoverageLinesTotal,
|
|
1339
1344
|
testSessionCoverageFiles,
|
|
@@ -426,15 +426,16 @@ function registerManualAfterScreenshotHandlers (on, handlers, datadogHandler) {
|
|
|
426
426
|
}
|
|
427
427
|
|
|
428
428
|
/**
|
|
429
|
-
* Registers one Cypress
|
|
429
|
+
* Registers one Cypress lifecycle handler that runs every collected handler
|
|
430
430
|
* in registration order. Cypress 10+ otherwise keeps only the last handler.
|
|
431
431
|
*
|
|
432
432
|
* @param {Function} on Cypress event registration function
|
|
433
|
-
* @param {
|
|
434
|
-
* @param {Function
|
|
433
|
+
* @param {'before:run'|'after:spec'} event lifecycle event
|
|
434
|
+
* @param {Function[]} handlers collected lifecycle handlers
|
|
435
|
+
* @param {Function} [datadogHandler] Datadog lifecycle handler
|
|
435
436
|
* @param {Function} [cleanup] removes generated support files after an error
|
|
436
437
|
*/
|
|
437
|
-
function
|
|
438
|
+
function registerLifecycleHandlers (on, event, handlers, datadogHandler, cleanup) {
|
|
438
439
|
const userHandlers = datadogHandler
|
|
439
440
|
? handlers.filter(handler => handler !== datadogHandler)
|
|
440
441
|
: handlers
|
|
@@ -442,27 +443,31 @@ function registerAfterSpecHandlers (on, handlers, datadogHandler, cleanup) {
|
|
|
442
443
|
if (userHandlers.length === 0) {
|
|
443
444
|
if (datadogHandler) {
|
|
444
445
|
if (cleanup) {
|
|
445
|
-
on(
|
|
446
|
+
on(event, (...args) => Promise.resolve().then(() => datadogHandler(...args)).catch((error) => {
|
|
446
447
|
cleanup()
|
|
447
448
|
throw error
|
|
448
449
|
}))
|
|
449
450
|
} else {
|
|
450
|
-
on(
|
|
451
|
+
on(event, datadogHandler)
|
|
451
452
|
}
|
|
452
453
|
}
|
|
453
454
|
return
|
|
454
455
|
}
|
|
455
456
|
|
|
456
|
-
on(
|
|
457
|
+
on(event, (...args) => {
|
|
457
458
|
const callHandler = datadogHandler
|
|
458
|
-
? handler => runUserHandler(() => handler(
|
|
459
|
-
: handler => handler(
|
|
459
|
+
? handler => runUserHandler(() => handler(...args))
|
|
460
|
+
: handler => handler(...args)
|
|
460
461
|
const chain = userHandlers.reduce(
|
|
461
462
|
(promise, handler) => promise.then(() => callHandler(handler)),
|
|
462
463
|
Promise.resolve()
|
|
463
464
|
)
|
|
464
465
|
if (!datadogHandler) return chain
|
|
465
|
-
const finalization = finalizeAfterUserHandlers(chain, (...
|
|
466
|
+
const finalization = finalizeAfterUserHandlers(chain, (...errors) => {
|
|
467
|
+
// A failed setup hook must abort the run before Datadog starts its session.
|
|
468
|
+
if (event === 'before:run' && errors.length > 0) return
|
|
469
|
+
return datadogHandler(...args, ...errors)
|
|
470
|
+
})
|
|
466
471
|
if (!cleanup) return finalization
|
|
467
472
|
return finalization.catch((error) => {
|
|
468
473
|
cleanup()
|
|
@@ -514,6 +519,9 @@ function registerDdTraceHooks (
|
|
|
514
519
|
if (generatedSupportFiles) registerGeneratedFilesForExitCleanup(generatedSupportFiles)
|
|
515
520
|
|
|
516
521
|
const cleanupWrapper = () => {
|
|
522
|
+
// Open mode reuses this support file across runs, including failed setup attempts.
|
|
523
|
+
// The registered process-exit cleanup owns its lifetime instead.
|
|
524
|
+
if (config.isInteractive) return
|
|
517
525
|
if (generatedSupportFiles) cleanupGeneratedFiles(generatedSupportFiles)
|
|
518
526
|
}
|
|
519
527
|
|
|
@@ -537,8 +545,13 @@ function registerDdTraceHooks (
|
|
|
537
545
|
})
|
|
538
546
|
}
|
|
539
547
|
|
|
548
|
+
const registerBeforeRun = handler => {
|
|
549
|
+
registerLifecycleHandlers(on, 'before:run', userBeforeRunHandlers, handler, cleanupWrapper)
|
|
550
|
+
}
|
|
551
|
+
|
|
540
552
|
const registerNoopHandlers = () => {
|
|
541
|
-
|
|
553
|
+
registerBeforeRun()
|
|
554
|
+
registerLifecycleHandlers(on, 'after:spec', userAfterSpecHandlers)
|
|
542
555
|
for (const h of userAfterScreenshotHandlers) on('after:screenshot', h)
|
|
543
556
|
registerAfterRunWithCleanup()
|
|
544
557
|
on('task', noopTask)
|
|
@@ -555,8 +568,8 @@ function registerDdTraceHooks (
|
|
|
555
568
|
manualPlugin.initialConfig.experimentalInteractiveRunEvents = config.experimentalInteractiveRunEvents
|
|
556
569
|
}
|
|
557
570
|
}
|
|
558
|
-
|
|
559
|
-
|
|
571
|
+
registerBeforeRun(manualPlugin.beforeRunHandler)
|
|
572
|
+
registerLifecycleHandlers(on, 'after:spec', userAfterSpecHandlers, manualPlugin.afterSpecHandler, cleanupWrapper)
|
|
560
573
|
registerManualAfterScreenshotHandlers(on, userAfterScreenshotHandlers, manualPlugin.afterScreenshotHandler)
|
|
561
574
|
registerAfterRunWithCleanup(manualPlugin.afterRunHandler)
|
|
562
575
|
on('task', manualPlugin.taskHandler)
|
|
@@ -572,8 +585,6 @@ function registerDdTraceHooks (
|
|
|
572
585
|
)
|
|
573
586
|
}
|
|
574
587
|
|
|
575
|
-
for (const handler of userBeforeRunHandlers) on('before:run', handler)
|
|
576
|
-
|
|
577
588
|
if (!setupNodeEventsCh.hasSubscribers) {
|
|
578
589
|
registerNoopHandlers()
|
|
579
590
|
return config
|
|
@@ -588,6 +599,7 @@ function registerDdTraceHooks (
|
|
|
588
599
|
userAfterSpecHandlers,
|
|
589
600
|
userAfterRunHandlers,
|
|
590
601
|
userAfterScreenshotHandlers,
|
|
602
|
+
registerBeforeRun,
|
|
591
603
|
cleanupWrapper,
|
|
592
604
|
registered: false,
|
|
593
605
|
configPromise: undefined,
|
|
@@ -13,6 +13,7 @@ const {
|
|
|
13
13
|
} = require('./instrumentation-utils')
|
|
14
14
|
const hooks = require('./hooks')
|
|
15
15
|
const instrumentations = require('./instrumentations')
|
|
16
|
+
const { isRewriteActivationEnabled } = require('./rewriter/targets')
|
|
16
17
|
const disabledInstrumentations = getDisabledInstrumentations()
|
|
17
18
|
|
|
18
19
|
// register.js has now set up ritm (require-in-the-middle). In bundled
|
|
@@ -94,6 +95,11 @@ dc.subscribe(CHANNEL, (message) => {
|
|
|
94
95
|
const name = payload.package
|
|
95
96
|
if (disabledInstrumentations.has(name)) return
|
|
96
97
|
|
|
98
|
+
if (payload.activate && isRewriteActivationEnabled(name)) {
|
|
99
|
+
loadChannel.publish({ name })
|
|
100
|
+
return
|
|
101
|
+
}
|
|
102
|
+
|
|
97
103
|
const isPrefixedWithNode = name.startsWith('node:')
|
|
98
104
|
const isNodeModule = isPrefixedWithNode || !hooks[name]
|
|
99
105
|
|
|
@@ -69,6 +69,7 @@ const earlyLoadFrameworks = new Map([
|
|
|
69
69
|
*/
|
|
70
70
|
module.exports.checkForRequiredModules = function () {
|
|
71
71
|
const packages = require('./hooks')
|
|
72
|
+
const { isRewriteTargetName } = require('./rewriter/targets')
|
|
72
73
|
const naughties = new Set()
|
|
73
74
|
const frameworksSeen = new Set()
|
|
74
75
|
let didWarn = false
|
|
@@ -98,7 +99,7 @@ module.exports.checkForRequiredModules = function () {
|
|
|
98
99
|
continue
|
|
99
100
|
}
|
|
100
101
|
|
|
101
|
-
if (naughties.has(pkg) || !(pkg in packages)) continue
|
|
102
|
+
if (naughties.has(pkg) || (!(pkg in packages) && !isRewriteTargetName(pkg))) continue
|
|
102
103
|
|
|
103
104
|
loadOrderWarnings.push(
|
|
104
105
|
() => `Warning: Package '${pkg}' was loaded before dd-trace! This may break instrumentation.`
|
|
@@ -25,14 +25,12 @@ module.exports = {
|
|
|
25
25
|
'@anthropic-ai/sdk': { esmFirst: true, fn: () => require('../anthropic') },
|
|
26
26
|
'@apollo/server': () => require('../apollo-server'),
|
|
27
27
|
'@apollo/gateway': () => require('../apollo'),
|
|
28
|
-
'@langchain/langgraph': { esmFirst: true, fn: () => require('../langgraph') },
|
|
29
28
|
'@modelcontextprotocol/sdk': { esmFirst: true, fn: () => require('../modelcontextprotocol-sdk') },
|
|
30
29
|
'@openai/agents': () => require('../openai-agents'),
|
|
31
30
|
'@openai/agents-openai': () => require('../openai-agents'),
|
|
32
31
|
'apollo-server-core': () => require('../apollo-server-core'),
|
|
33
32
|
'@aws-sdk/smithy-client': () => require('../aws-sdk'),
|
|
34
33
|
'@aws/durable-execution-sdk-js': () => require('../aws-durable-execution-sdk-js'),
|
|
35
|
-
'@azure/cosmos': { esmFirst: true, fn: () => require('../azure-cosmos') },
|
|
36
34
|
'@azure/event-hubs': () => require('../azure-event-hubs'),
|
|
37
35
|
'@azure/functions': () => require('../azure-functions'),
|
|
38
36
|
'durable-functions': () => require('../azure-durable-functions'),
|
|
@@ -54,7 +52,6 @@ module.exports = {
|
|
|
54
52
|
'@jest/test-sequencer': () => require('../jest'),
|
|
55
53
|
'@jest/transform': () => require('../jest'),
|
|
56
54
|
'@koa/router': () => require('../koa'),
|
|
57
|
-
'@langchain/core': { esmFirst: true, fn: () => require('../langchain') },
|
|
58
55
|
'@node-redis/client': () => require('../redis'),
|
|
59
56
|
'@opensearch-project/opensearch': () => require('../opensearch'),
|
|
60
57
|
'@opentelemetry/sdk-trace': () => require('../otel-sdk-trace'),
|
|
@@ -78,7 +75,6 @@ module.exports = {
|
|
|
78
75
|
bluebird: () => require('../bluebird'),
|
|
79
76
|
'body-parser': () => require('../body-parser'),
|
|
80
77
|
'browser-bunyan': () => require('../browser-bunyan'),
|
|
81
|
-
bullmq: () => require('../bullmq'),
|
|
82
78
|
bunyan: () => require('../bunyan'),
|
|
83
79
|
'cassandra-driver': () => require('../cassandra-driver'),
|
|
84
80
|
connect: () => require('../connect'),
|
|
@@ -114,14 +110,12 @@ module.exports = {
|
|
|
114
110
|
'koa-router': () => require('../koa'),
|
|
115
111
|
'@confluentinc/kafka-javascript': () => require('../confluentinc-kafka-javascript'),
|
|
116
112
|
kafkajs: () => require('../kafkajs'),
|
|
117
|
-
langchain: () => require('../langchain'),
|
|
118
113
|
ldapjs: () => require('../ldapjs'),
|
|
119
114
|
'light-my-request': () => require('../light-my-request'),
|
|
120
115
|
'limitd-client': () => require('../limitd-client'),
|
|
121
116
|
lodash: () => require('../lodash'),
|
|
122
117
|
mariadb: { esmFirst: true, fn: () => require('../mariadb') },
|
|
123
118
|
memcached: () => require('../memcached'),
|
|
124
|
-
mercurius: () => require('../mercurius'),
|
|
125
119
|
'microgateway-core': () => require('../microgateway-core'),
|
|
126
120
|
mocha: () => require('../mocha'),
|
|
127
121
|
'mocha-each': () => require('../mocha'),
|
|
@@ -25,6 +25,7 @@ const pathSepExpr = new RegExp(`\\${path.sep}`, 'g')
|
|
|
25
25
|
const disabledInstrumentations = getDisabledInstrumentations()
|
|
26
26
|
|
|
27
27
|
const loadChannel = channel('dd-trace:instrumentation:load')
|
|
28
|
+
const orchestrionLoadChannel = channel('dd-trace:instrumentation:load:orchestrion')
|
|
28
29
|
|
|
29
30
|
// Globals
|
|
30
31
|
if (!disabledInstrumentations.has('fetch')) {
|
|
@@ -55,6 +56,25 @@ const instrumentedNodeModules = new Map()
|
|
|
55
56
|
const instrumentedIntegrationsSuccess = new Map()
|
|
56
57
|
/** @type {Set<string>} */
|
|
57
58
|
const alreadyLoggedIncompatibleIntegrations = new Set()
|
|
59
|
+
/** @type {Set<string>} */
|
|
60
|
+
const compatibleOrchestrionTargets = new Set()
|
|
61
|
+
|
|
62
|
+
orchestrionLoadChannel.subscribe(({ moduleName, version, result }) => {
|
|
63
|
+
const nameVersion = `${moduleName}@${version}`
|
|
64
|
+
|
|
65
|
+
if (result === 'unsupported') {
|
|
66
|
+
if (!compatibleOrchestrionTargets.has(nameVersion) && !instrumentedIntegrationsSuccess.has(nameVersion)) {
|
|
67
|
+
instrumentedIntegrationsSuccess.set(nameVersion, false)
|
|
68
|
+
}
|
|
69
|
+
return
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (result === 'matched' || result === 'rewritten') {
|
|
73
|
+
compatibleOrchestrionTargets.add(nameVersion)
|
|
74
|
+
instrumentedIntegrationsSuccess.set(nameVersion, true)
|
|
75
|
+
if (result === 'rewritten') loadChannel.publish({ name: moduleName })
|
|
76
|
+
}
|
|
77
|
+
})
|
|
58
78
|
|
|
59
79
|
for (const name of names) {
|
|
60
80
|
if (disabledInstrumentations.has(name)) continue
|
|
@@ -19,7 +19,7 @@ const { getRewriteTarget } = require('./targets')
|
|
|
19
19
|
* { code: string, map?: string|object }} transform
|
|
20
20
|
*
|
|
21
21
|
* @typedef {(content: string|Buffer|ArrayBuffer|Uint8Array, filename: string, format?: string,
|
|
22
|
-
* target?: { moduleName: string, filePath: string }, sourceMap?: string|object) =>
|
|
22
|
+
* target?: { moduleName: string, filePath: string, activate?: boolean }, sourceMap?: string|object) =>
|
|
23
23
|
* { code: string|Buffer|ArrayBuffer|Uint8Array, map?: string|object }} BundlerRewriter
|
|
24
24
|
*/
|
|
25
25
|
|
|
@@ -62,7 +62,7 @@ function normalizeFilename (filename) {
|
|
|
62
62
|
* @param {string|Buffer|ArrayBuffer|Uint8Array} content
|
|
63
63
|
* @param {string} filename
|
|
64
64
|
* @param {string} [format]
|
|
65
|
-
* @param {{ moduleName: string, filePath: string }} [target]
|
|
65
|
+
* @param {{ moduleName: string, filePath: string, activate?: boolean }} [target]
|
|
66
66
|
* @returns {string|Buffer|ArrayBuffer|Uint8Array}
|
|
67
67
|
*/
|
|
68
68
|
function rewrite (content, filename, format, target) {
|
|
@@ -74,7 +74,7 @@ function rewrite (content, filename, format, target) {
|
|
|
74
74
|
if (!target) return content
|
|
75
75
|
|
|
76
76
|
const moduleType = format === 'module' ? 'esm' : 'cjs'
|
|
77
|
-
const { moduleName, filePath } = target
|
|
77
|
+
const { moduleName, filePath, activate } = target
|
|
78
78
|
if (disabled.has(moduleName)) return content
|
|
79
79
|
|
|
80
80
|
const version = getVersion(filename, filePath)
|
|
@@ -82,10 +82,18 @@ function rewrite (content, filename, format, target) {
|
|
|
82
82
|
|
|
83
83
|
const transformer = getMatcher(moduleType).getTransformer(moduleName, version, filePath)
|
|
84
84
|
|
|
85
|
-
if (!transformer) return content
|
|
85
|
+
if (!transformer && !activate) return content
|
|
86
86
|
|
|
87
87
|
const source = getSourceText(content)
|
|
88
88
|
|
|
89
|
+
if (!transformer) {
|
|
90
|
+
return appendOrchestrionLoad(
|
|
91
|
+
source,
|
|
92
|
+
{ moduleName, version, result: 'unsupported' },
|
|
93
|
+
moduleType
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
|
|
89
97
|
// TODO: pass existing sourcemap as input for remapping
|
|
90
98
|
let { code, map } = transformer.transform(source, moduleType)
|
|
91
99
|
|
|
@@ -98,6 +106,11 @@ function rewrite (content, filename, format, target) {
|
|
|
98
106
|
map = shiftSourceMapLine(map)
|
|
99
107
|
}
|
|
100
108
|
|
|
109
|
+
if (activate) {
|
|
110
|
+
const result = code === source ? 'matched' : 'rewritten'
|
|
111
|
+
code = appendOrchestrionLoad(code, { moduleName, version, result }, moduleType)
|
|
112
|
+
}
|
|
113
|
+
|
|
101
114
|
if (!map) return code
|
|
102
115
|
|
|
103
116
|
const inlineMap = Buffer.from(typeof map === 'string' ? map : JSON.stringify(map)).toString('base64')
|
|
@@ -236,6 +249,30 @@ function getSourceText (source) {
|
|
|
236
249
|
return Buffer.from(source).toString('utf8')
|
|
237
250
|
}
|
|
238
251
|
|
|
252
|
+
/**
|
|
253
|
+
* Publish target-level compatibility on the application thread when a pure target is evaluated.
|
|
254
|
+
*
|
|
255
|
+
* @param {string} source
|
|
256
|
+
* @param {{ moduleName: string, version: string,
|
|
257
|
+
* result: 'unsupported'|'matched'|'rewritten' }} payload
|
|
258
|
+
* @param {'cjs'|'esm'} moduleType
|
|
259
|
+
*/
|
|
260
|
+
function appendOrchestrionLoad (source, payload, moduleType) {
|
|
261
|
+
const dcModule = JSON.stringify(getDcPolyfillSpecifier(moduleType) ?? 'diagnostics_channel')
|
|
262
|
+
const message = JSON.stringify(payload)
|
|
263
|
+
|
|
264
|
+
if (moduleType === 'esm') {
|
|
265
|
+
let binding = 'ddTraceOrchestrionDc'
|
|
266
|
+
let suffix = 0
|
|
267
|
+
while (source.includes(binding)) binding = `ddTraceOrchestrionDc${++suffix}`
|
|
268
|
+
|
|
269
|
+
return `${source};import ${binding} from ${dcModule};` +
|
|
270
|
+
`${binding}.channel('dd-trace:instrumentation:load:orchestrion').publish(${message});`
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
return `${source};require(${dcModule}).channel('dd-trace:instrumentation:load:orchestrion').publish(${message});`
|
|
274
|
+
}
|
|
275
|
+
|
|
239
276
|
/**
|
|
240
277
|
* Account for a shebang restored ahead of the generated program. The transformer already maps original positions
|
|
241
278
|
* past the input shebang, so only the generated side needs an additional empty line.
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
//
|
|
3
|
+
// Activated rewrites publish their module name to the plugin manager after evaluation.
|
|
4
|
+
// Only pure Orchestrion integrations that need this activation set activate: true.
|
|
5
|
+
// Other entries use hooks or another activation path, or do not need activation from a rewrite.
|
|
4
6
|
const registry = [
|
|
5
7
|
{ instrumentations: require('./instrumentations/ai') },
|
|
6
|
-
{
|
|
8
|
+
{ activate: true, instrumentations: require('./instrumentations/azure-cosmos') },
|
|
7
9
|
{ instrumentations: require('./instrumentations/azure-durable-functions') },
|
|
8
|
-
{
|
|
10
|
+
{ activate: true, instrumentations: require('./instrumentations/bullmq') },
|
|
9
11
|
{ instrumentations: require('./instrumentations/claude-agent-sdk') },
|
|
10
12
|
{ instrumentations: require('./instrumentations/graphql') },
|
|
11
13
|
{ instrumentations: require('./instrumentations/graphql-jit') },
|
|
12
|
-
{
|
|
13
|
-
{
|
|
14
|
-
{
|
|
14
|
+
{ activate: true, instrumentations: require('./instrumentations/langchain') },
|
|
15
|
+
{ activate: true, instrumentations: require('./instrumentations/langgraph') },
|
|
16
|
+
{ activate: true, instrumentations: require('./instrumentations/mercurius') },
|
|
15
17
|
{ instrumentations: require('./instrumentations/modelcontextprotocol-sdk') },
|
|
16
18
|
{ instrumentations: require('./instrumentations/openai-agents') },
|
|
17
19
|
{ instrumentations: require('./instrumentations/playwright') },
|
|
@@ -21,10 +23,10 @@ const registry = [
|
|
|
21
23
|
{ instrumentations: require('./instrumentations/supabase') },
|
|
22
24
|
]
|
|
23
25
|
|
|
24
|
-
const
|
|
25
|
-
for (const {
|
|
26
|
-
if (!
|
|
27
|
-
for (const { module } of instrumentations)
|
|
26
|
+
const activatedModules = new Set()
|
|
27
|
+
for (const { activate, instrumentations } of registry) {
|
|
28
|
+
if (!activate) continue
|
|
29
|
+
for (const { module } of instrumentations) activatedModules.add(module.name)
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
const instrumentations = registry.flatMap(entry => entry.instrumentations)
|
|
@@ -32,8 +34,8 @@ const instrumentations = registry.flatMap(entry => entry.instrumentations)
|
|
|
32
34
|
/**
|
|
33
35
|
* @param {string} moduleName
|
|
34
36
|
*/
|
|
35
|
-
function
|
|
36
|
-
return
|
|
37
|
+
function isRewriteActivationEnabled (moduleName) {
|
|
38
|
+
return activatedModules.has(moduleName)
|
|
37
39
|
}
|
|
38
40
|
|
|
39
|
-
module.exports = {
|
|
41
|
+
module.exports = { isRewriteActivationEnabled, instrumentations, registry }
|
package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/playwright.js
CHANGED
|
@@ -3,6 +3,49 @@
|
|
|
3
3
|
// Playwright keeps several hook targets in private local classes/functions.
|
|
4
4
|
// Keep these rewrites limited to bundled internals that addHook cannot wrap.
|
|
5
5
|
module.exports = [
|
|
6
|
+
{
|
|
7
|
+
module: {
|
|
8
|
+
name: '@playwright/test',
|
|
9
|
+
versionRange: '>=1.18.0 <1.38.0',
|
|
10
|
+
filePath: 'lib/reporters/multiplexer.js',
|
|
11
|
+
},
|
|
12
|
+
functionQuery: {
|
|
13
|
+
className: 'Multiplexer',
|
|
14
|
+
methodName: 'onError',
|
|
15
|
+
kind: 'Sync',
|
|
16
|
+
},
|
|
17
|
+
channelName: 'Multiplexer_onError',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
module: {
|
|
21
|
+
name: 'playwright',
|
|
22
|
+
versionRange: '>=1.44.0 <1.60.0',
|
|
23
|
+
filePath: 'lib/runner/runner.js',
|
|
24
|
+
},
|
|
25
|
+
astQuery: 'FunctionDeclaration[id.name="writeLastRunInfo"] ' +
|
|
26
|
+
'CallExpression[callee.property.name="map"] > ArrowFunctionExpression',
|
|
27
|
+
channelName: 'lastRunTestId',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
module: {
|
|
31
|
+
name: 'playwright',
|
|
32
|
+
versionRange: '>=1.44.0 <1.60.0',
|
|
33
|
+
filePath: 'lib/runner/lastRun.js',
|
|
34
|
+
},
|
|
35
|
+
astQuery: 'ClassDeclaration[id.name="LastRunReporter"] ' +
|
|
36
|
+
'CallExpression[callee.property.name="map"] > ArrowFunctionExpression',
|
|
37
|
+
channelName: 'lastRunTestId',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
module: {
|
|
41
|
+
name: 'playwright',
|
|
42
|
+
versionRange: '>=1.60.0',
|
|
43
|
+
filePath: 'lib/runner/index.js',
|
|
44
|
+
},
|
|
45
|
+
astQuery: 'VariableDeclarator[id.name="LastRunReporter"] ' +
|
|
46
|
+
'CallExpression[callee.property.name="map"] > ArrowFunctionExpression',
|
|
47
|
+
channelName: 'lastRunTestId',
|
|
48
|
+
},
|
|
6
49
|
{
|
|
7
50
|
module: {
|
|
8
51
|
name: 'playwright',
|
package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/webdriverio.js
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
module.exports = [
|
|
4
|
+
{
|
|
5
|
+
module: {
|
|
6
|
+
name: '@wdio/config',
|
|
7
|
+
versionRange: '>=9.0.0',
|
|
8
|
+
filePath: 'build/node/index.js',
|
|
9
|
+
},
|
|
10
|
+
functionQuery: {
|
|
11
|
+
className: 'ConfigParser',
|
|
12
|
+
methodName: 'shard',
|
|
13
|
+
kind: 'Sync',
|
|
14
|
+
},
|
|
15
|
+
channelName: 'ConfigParser_shard',
|
|
16
|
+
},
|
|
4
17
|
{
|
|
5
18
|
module: {
|
|
6
19
|
name: '@wdio/cli',
|