dd-trace 5.41.1 → 5.42.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 -0
- package/index.d.ts +8 -1
- package/package.json +6 -3
- package/packages/datadog-esbuild/index.js +3 -1
- package/packages/datadog-instrumentations/src/cucumber.js +37 -29
- package/packages/datadog-instrumentations/src/google-cloud-vertexai.js +102 -0
- package/packages/datadog-instrumentations/src/{check_require_cache.js → helpers/check-require-cache.js} +2 -2
- package/packages/datadog-instrumentations/src/helpers/hooks.js +2 -2
- package/packages/datadog-instrumentations/src/helpers/register.js +4 -1
- package/packages/datadog-instrumentations/src/jest.js +72 -49
- package/packages/datadog-instrumentations/src/langchain.js +29 -10
- package/packages/datadog-instrumentations/src/mocha/main.js +53 -34
- package/packages/datadog-instrumentations/src/mocha/utils.js +34 -24
- package/packages/datadog-instrumentations/src/mocha/worker.js +7 -8
- package/packages/datadog-instrumentations/src/openai.js +1 -1
- package/packages/datadog-instrumentations/src/playwright.js +37 -30
- package/packages/datadog-instrumentations/src/vitest.js +64 -29
- package/packages/datadog-plugin-cucumber/src/index.js +13 -4
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +41 -35
- package/packages/datadog-plugin-cypress/src/plugin.js +10 -0
- package/packages/datadog-plugin-google-cloud-vertexai/src/index.js +195 -0
- package/packages/datadog-plugin-jest/src/index.js +18 -6
- package/packages/datadog-plugin-langchain/src/handlers/embedding.js +4 -1
- package/packages/datadog-plugin-mocha/src/index.js +13 -4
- package/packages/datadog-plugin-playwright/src/index.js +19 -5
- package/packages/datadog-plugin-vitest/src/index.js +41 -17
- package/packages/dd-trace/src/appsec/api_security_sampler.js +7 -3
- package/packages/dd-trace/src/appsec/blocking.js +23 -16
- package/packages/dd-trace/src/appsec/graphql.js +13 -6
- package/packages/dd-trace/src/appsec/rasp/utils.js +0 -1
- package/packages/dd-trace/src/appsec/reporter.js +35 -0
- package/packages/dd-trace/src/appsec/sdk/user_blocking.js +1 -3
- package/packages/dd-trace/src/appsec/telemetry/index.js +5 -1
- package/packages/dd-trace/src/appsec/telemetry/rasp.js +16 -1
- package/packages/dd-trace/src/appsec/telemetry/waf.js +16 -1
- package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +43 -13
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +2 -2
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +15 -14
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +1 -2
- package/packages/dd-trace/src/ci-visibility/telemetry.js +2 -1
- package/packages/dd-trace/src/ci-visibility/{quarantined-tests/get-quarantined-tests.js → test-management/get-test-management-tests.js} +5 -5
- package/packages/dd-trace/src/config.js +11 -1
- package/packages/dd-trace/src/encode/agentless-ci-visibility.js +9 -2
- package/packages/dd-trace/src/lambda/runtime/patch.js +5 -3
- package/packages/dd-trace/src/lambda/runtime/ritm.js +13 -18
- package/packages/dd-trace/src/llmobs/plugins/openai.js +27 -2
- package/packages/dd-trace/src/opentracing/span.js +3 -0
- package/packages/dd-trace/src/plugins/ci_plugin.js +38 -10
- package/packages/dd-trace/src/plugins/index.js +1 -0
- package/packages/dd-trace/src/plugins/util/git.js +7 -3
- package/packages/dd-trace/src/plugins/util/test.js +10 -0
- package/packages/dd-trace/src/plugins/util/web.js +5 -2
- package/packages/dd-trace/src/priority_sampler.js +116 -15
- package/packages/dd-trace/src/sampler.js +9 -0
- package/packages/dd-trace/src/standalone/product.js +6 -2
- package/packages/dd-trace/src/startup-log.js +2 -1
- package/packages/dd-trace/src/telemetry/metrics.js +0 -8
- package/packages/dd-trace/src/tracer.js +1 -1
- /package/packages/datadog-instrumentations/src/{utils/src → helpers}/extract-package-and-module-path.js +0 -0
package/LICENSE-3rdparty.csv
CHANGED
|
@@ -32,6 +32,7 @@ require,shell-quote,mit,Copyright (c) 2013 James Halliday
|
|
|
32
32
|
require,source-map,BSD-3-Clause,Copyright (c) 2009-2011, Mozilla Foundation and contributors
|
|
33
33
|
require,ttl-set,MIT,Copyright (c) 2024 Thomas Watson
|
|
34
34
|
dev,@apollo/server,MIT,Copyright (c) 2016-2020 Apollo Graph, Inc. (Formerly Meteor Development Group, Inc.)
|
|
35
|
+
dev,@babel/helpers,MIT,Copyright (c) 2014-present Sebastian McKenzie and other contributors
|
|
35
36
|
dev,@types/node,MIT,Copyright Authors
|
|
36
37
|
dev,@eslint/eslintrc,MIT,Copyright OpenJS Foundation and other contributors, <www.openjsf.org>
|
|
37
38
|
dev,@eslint/js,MIT,Copyright OpenJS Foundation and other contributors, <www.openjsf.org>
|
package/index.d.ts
CHANGED
|
@@ -165,6 +165,7 @@ interface Plugins {
|
|
|
165
165
|
"fetch": tracer.plugins.fetch;
|
|
166
166
|
"generic-pool": tracer.plugins.generic_pool;
|
|
167
167
|
"google-cloud-pubsub": tracer.plugins.google_cloud_pubsub;
|
|
168
|
+
"google-cloud-vertexai": tracer.plugins.google_cloud_vertexai;
|
|
168
169
|
"graphql": tracer.plugins.graphql;
|
|
169
170
|
"grpc": tracer.plugins.grpc;
|
|
170
171
|
"hapi": tracer.plugins.hapi;
|
|
@@ -1370,6 +1371,12 @@ declare namespace tracer {
|
|
|
1370
1371
|
*/
|
|
1371
1372
|
interface google_cloud_pubsub extends Integration {}
|
|
1372
1373
|
|
|
1374
|
+
/**
|
|
1375
|
+
* This plugin automatically instruments the
|
|
1376
|
+
* [@google-cloud/vertexai](https://github.com/googleapis/nodejs-vertexai) module.
|
|
1377
|
+
*/
|
|
1378
|
+
interface google_cloud_vertexai extends Integration {}
|
|
1379
|
+
|
|
1373
1380
|
/** @hidden */
|
|
1374
1381
|
interface ExecutionArgs {
|
|
1375
1382
|
schema: any,
|
|
@@ -2340,7 +2347,7 @@ declare namespace tracer {
|
|
|
2340
2347
|
* ```javascript
|
|
2341
2348
|
* llmobs.trace({ kind: 'llm', name: 'myLLM', modelName: 'gpt-4o', modelProvider: 'openai' }, () => {
|
|
2342
2349
|
* llmobs.annotate({
|
|
2343
|
-
* inputData: [{ content: 'system prompt, role: 'system' }, { content: 'user prompt', role: 'user' }],
|
|
2350
|
+
* inputData: [{ content: 'system prompt', role: 'system' }, { content: 'user prompt', role: 'user' }],
|
|
2344
2351
|
* outputData: { content: 'response', role: 'ai' },
|
|
2345
2352
|
* metadata: { temperature: 0.7 },
|
|
2346
2353
|
* tags: { host: 'localhost' },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dd-trace",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.42.0",
|
|
4
4
|
"description": "Datadog APM tracing client for JavaScript",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -28,6 +28,8 @@
|
|
|
28
28
|
"test:trace:core:ci": "npm run test:trace:core -- --coverage --nyc-arg=--include=\"packages/dd-trace/src/**/*.js\"",
|
|
29
29
|
"test:instrumentations": "mocha -r 'packages/dd-trace/test/setup/mocha.js' 'packages/datadog-instrumentations/test/**/*.spec.js'",
|
|
30
30
|
"test:instrumentations:ci": "nyc --no-clean --include 'packages/datadog-instrumentations/src/**/*.js' -- npm run test:instrumentations",
|
|
31
|
+
"test:instrumentations:misc": "mocha -r 'packages/dd-trace/test/setup/mocha.js' 'packages/datadog-instrumentations/test/*/**/*.spec.js'",
|
|
32
|
+
"test:instrumentations:misc:ci": "nyc --no-clean --include 'packages/datadog-instrumentations/src/**/*.js' -- npm run test:instrumentations:misc",
|
|
31
33
|
"test:core": "tap \"packages/datadog-core/test/**/*.spec.js\"",
|
|
32
34
|
"test:core:ci": "npm run test:core -- --coverage --nyc-arg=--include=\"packages/datadog-core/src/**/*.js\"",
|
|
33
35
|
"test:lambda": "mocha -r \"packages/dd-trace/test/setup/mocha.js\" \"packages/dd-trace/test/lambda/**/*.spec.js\"",
|
|
@@ -83,7 +85,7 @@
|
|
|
83
85
|
},
|
|
84
86
|
"dependencies": {
|
|
85
87
|
"@datadog/libdatadog": "^0.5.0",
|
|
86
|
-
"@datadog/native-appsec": "8.
|
|
88
|
+
"@datadog/native-appsec": "8.5.0",
|
|
87
89
|
"@datadog/native-iast-rewriter": "2.8.0",
|
|
88
90
|
"@datadog/native-iast-taint-tracking": "3.3.0",
|
|
89
91
|
"@datadog/native-metrics": "^3.1.0",
|
|
@@ -117,6 +119,7 @@
|
|
|
117
119
|
},
|
|
118
120
|
"devDependencies": {
|
|
119
121
|
"@apollo/server": "^4.11.0",
|
|
122
|
+
"@babel/helpers": "^7.26.10",
|
|
120
123
|
"@eslint/eslintrc": "^3.2.0",
|
|
121
124
|
"@eslint/js": "^9.19.0",
|
|
122
125
|
"@msgpack/msgpack": "^3.0.0-beta3",
|
|
@@ -125,7 +128,7 @@
|
|
|
125
128
|
"application-config-path": "^1.0.0",
|
|
126
129
|
"autocannon": "^4.5.2",
|
|
127
130
|
"aws-sdk": "^2.1446.0",
|
|
128
|
-
"axios": "^1.
|
|
131
|
+
"axios": "^1.8.2",
|
|
129
132
|
"benchmark": "^2.1.4",
|
|
130
133
|
"body-parser": "^1.20.3",
|
|
131
134
|
"chai": "^4.3.7",
|
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
const instrumentations = require('../datadog-instrumentations/src/helpers/instrumentations.js')
|
|
6
6
|
const hooks = require('../datadog-instrumentations/src/helpers/hooks.js')
|
|
7
|
-
const extractPackageAndModulePath = require(
|
|
7
|
+
const extractPackageAndModulePath = require(
|
|
8
|
+
'../datadog-instrumentations/src/helpers/extract-package-and-module-path.js'
|
|
9
|
+
)
|
|
8
10
|
|
|
9
11
|
for (const hook of Object.values(hooks)) {
|
|
10
12
|
if (typeof hook === 'object') {
|
|
@@ -22,7 +22,7 @@ const knownTestsCh = channel('ci:cucumber:known-tests')
|
|
|
22
22
|
const skippableSuitesCh = channel('ci:cucumber:test-suite:skippable')
|
|
23
23
|
const sessionStartCh = channel('ci:cucumber:session:start')
|
|
24
24
|
const sessionFinishCh = channel('ci:cucumber:session:finish')
|
|
25
|
-
const
|
|
25
|
+
const testManagementTestsCh = channel('ci:cucumber:test-management-tests')
|
|
26
26
|
|
|
27
27
|
const workerReportTraceCh = channel('ci:cucumber:worker-report:trace')
|
|
28
28
|
|
|
@@ -72,8 +72,8 @@ let earlyFlakeDetectionFaultyThreshold = 0
|
|
|
72
72
|
let isEarlyFlakeDetectionFaulty = false
|
|
73
73
|
let isFlakyTestRetriesEnabled = false
|
|
74
74
|
let isKnownTestsEnabled = false
|
|
75
|
-
let
|
|
76
|
-
let
|
|
75
|
+
let isTestManagementTestsEnabled = false
|
|
76
|
+
let testManagementTests = {}
|
|
77
77
|
let numTestRetries = 0
|
|
78
78
|
let knownTests = []
|
|
79
79
|
let skippedSuites = []
|
|
@@ -120,15 +120,11 @@ function isNewTest (testSuite, testName) {
|
|
|
120
120
|
return !testsForSuite.includes(testName)
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
function
|
|
124
|
-
|
|
125
|
-
?.cucumber
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
?.tests
|
|
129
|
-
?.[testName]
|
|
130
|
-
?.properties
|
|
131
|
-
?.quarantined
|
|
123
|
+
function getTestProperties (testSuite, testName) {
|
|
124
|
+
const { disabled, quarantined } =
|
|
125
|
+
testManagementTests?.cucumber?.suites?.[testSuite]?.tests?.[testName]?.properties || {}
|
|
126
|
+
|
|
127
|
+
return { disabled, quarantined }
|
|
132
128
|
}
|
|
133
129
|
|
|
134
130
|
function getTestStatusFromRetries (testStatuses) {
|
|
@@ -155,10 +151,10 @@ function getErrorFromCucumberResult (cucumberResult) {
|
|
|
155
151
|
return error
|
|
156
152
|
}
|
|
157
153
|
|
|
158
|
-
function getChannelPromise (channelToPublishTo) {
|
|
154
|
+
function getChannelPromise (channelToPublishTo, isParallel = false) {
|
|
159
155
|
return new Promise(resolve => {
|
|
160
156
|
sessionAsyncResource.runInAsyncScope(() => {
|
|
161
|
-
channelToPublishTo.publish({ onDone: resolve })
|
|
157
|
+
channelToPublishTo.publish({ onDone: resolve, isParallel })
|
|
162
158
|
})
|
|
163
159
|
})
|
|
164
160
|
}
|
|
@@ -307,6 +303,7 @@ function wrapRun (pl, isLatestVersion) {
|
|
|
307
303
|
}
|
|
308
304
|
let isNew = false
|
|
309
305
|
let isEfdRetry = false
|
|
306
|
+
let isDisabled = false
|
|
310
307
|
let isQuarantined = false
|
|
311
308
|
if (isKnownTestsEnabled && status !== 'skip') {
|
|
312
309
|
const numRetries = numRetriesByPickleId.get(this.pickle.id)
|
|
@@ -314,9 +311,13 @@ function wrapRun (pl, isLatestVersion) {
|
|
|
314
311
|
isNew = numRetries !== undefined
|
|
315
312
|
isEfdRetry = numRetries > 0
|
|
316
313
|
}
|
|
317
|
-
if (
|
|
314
|
+
if (isTestManagementTestsEnabled) {
|
|
318
315
|
const testSuitePath = getTestSuitePath(testFileAbsolutePath, process.cwd())
|
|
319
|
-
|
|
316
|
+
const testProperties = getTestProperties(testSuitePath, this.pickle.name)
|
|
317
|
+
isDisabled = testProperties.disabled
|
|
318
|
+
if (!isDisabled) {
|
|
319
|
+
isQuarantined = testProperties.quarantined
|
|
320
|
+
}
|
|
320
321
|
}
|
|
321
322
|
const attemptAsyncResource = numAttemptToAsyncResource.get(numAttempt)
|
|
322
323
|
|
|
@@ -333,6 +334,7 @@ function wrapRun (pl, isLatestVersion) {
|
|
|
333
334
|
isNew,
|
|
334
335
|
isEfdRetry,
|
|
335
336
|
isFlakyRetry: numAttempt > 0,
|
|
337
|
+
isDisabled,
|
|
336
338
|
isQuarantined
|
|
337
339
|
})
|
|
338
340
|
})
|
|
@@ -414,7 +416,7 @@ function getWrappedStart (start, frameworkVersion, isParallel = false, isCoordin
|
|
|
414
416
|
}
|
|
415
417
|
let errorSkippableRequest
|
|
416
418
|
|
|
417
|
-
const configurationResponse = await getChannelPromise(libraryConfigurationCh)
|
|
419
|
+
const configurationResponse = await getChannelPromise(libraryConfigurationCh, isParallel)
|
|
418
420
|
|
|
419
421
|
isEarlyFlakeDetectionEnabled = configurationResponse.libraryConfig?.isEarlyFlakeDetectionEnabled
|
|
420
422
|
earlyFlakeDetectionNumRetries = configurationResponse.libraryConfig?.earlyFlakeDetectionNumRetries
|
|
@@ -423,7 +425,7 @@ function getWrappedStart (start, frameworkVersion, isParallel = false, isCoordin
|
|
|
423
425
|
isFlakyTestRetriesEnabled = configurationResponse.libraryConfig?.isFlakyTestRetriesEnabled
|
|
424
426
|
numTestRetries = configurationResponse.libraryConfig?.flakyTestRetriesCount
|
|
425
427
|
isKnownTestsEnabled = configurationResponse.libraryConfig?.isKnownTestsEnabled
|
|
426
|
-
|
|
428
|
+
isTestManagementTestsEnabled = configurationResponse.libraryConfig?.isTestManagementEnabled
|
|
427
429
|
|
|
428
430
|
if (isKnownTestsEnabled) {
|
|
429
431
|
const knownTestsResponse = await getChannelPromise(knownTestsCh)
|
|
@@ -481,12 +483,12 @@ function getWrappedStart (start, frameworkVersion, isParallel = false, isCoordin
|
|
|
481
483
|
}
|
|
482
484
|
}
|
|
483
485
|
|
|
484
|
-
if (
|
|
485
|
-
const
|
|
486
|
-
if (!
|
|
487
|
-
|
|
486
|
+
if (isTestManagementTestsEnabled) {
|
|
487
|
+
const testManagementTestsResponse = await getChannelPromise(testManagementTestsCh)
|
|
488
|
+
if (!testManagementTestsResponse.err) {
|
|
489
|
+
testManagementTests = testManagementTestsResponse.testManagementTests
|
|
488
490
|
} else {
|
|
489
|
-
|
|
491
|
+
isTestManagementTestsEnabled = false
|
|
490
492
|
}
|
|
491
493
|
}
|
|
492
494
|
|
|
@@ -537,7 +539,7 @@ function getWrappedStart (start, frameworkVersion, isParallel = false, isCoordin
|
|
|
537
539
|
hasForcedToRunSuites: isForcedToRun,
|
|
538
540
|
isEarlyFlakeDetectionEnabled,
|
|
539
541
|
isEarlyFlakeDetectionFaulty,
|
|
540
|
-
|
|
542
|
+
isTestManagementTestsEnabled,
|
|
541
543
|
isParallel
|
|
542
544
|
})
|
|
543
545
|
})
|
|
@@ -574,6 +576,7 @@ function getWrappedRunTestCase (runTestCaseFunction, isNewerCucumberVersion = fa
|
|
|
574
576
|
}
|
|
575
577
|
|
|
576
578
|
let isNew = false
|
|
579
|
+
let isDisabled = false
|
|
577
580
|
let isQuarantined = false
|
|
578
581
|
|
|
579
582
|
if (isKnownTestsEnabled) {
|
|
@@ -582,10 +585,15 @@ function getWrappedRunTestCase (runTestCaseFunction, isNewerCucumberVersion = fa
|
|
|
582
585
|
numRetriesByPickleId.set(pickle.id, 0)
|
|
583
586
|
}
|
|
584
587
|
}
|
|
585
|
-
if (
|
|
586
|
-
|
|
588
|
+
if (isTestManagementTestsEnabled) {
|
|
589
|
+
const testProperties = getTestProperties(testSuitePath, pickle.name)
|
|
590
|
+
isDisabled = testProperties.disabled
|
|
591
|
+
if (isDisabled) {
|
|
592
|
+
this.options.dryRun = true
|
|
593
|
+
} else {
|
|
594
|
+
isQuarantined = testProperties.quarantined
|
|
595
|
+
}
|
|
587
596
|
}
|
|
588
|
-
|
|
589
597
|
// TODO: for >=11 we could use `runTestCaseResult` instead of accumulating results in `lastStatusByPickleId`
|
|
590
598
|
let runTestCaseResult = await runTestCaseFunction.apply(this, arguments)
|
|
591
599
|
|
|
@@ -617,7 +625,7 @@ function getWrappedRunTestCase (runTestCaseFunction, isNewerCucumberVersion = fa
|
|
|
617
625
|
}
|
|
618
626
|
}
|
|
619
627
|
|
|
620
|
-
if (
|
|
628
|
+
if (isTestManagementTestsEnabled && isQuarantined) {
|
|
621
629
|
this.success = true
|
|
622
630
|
shouldBePassedByQuarantine = true
|
|
623
631
|
}
|
|
@@ -653,7 +661,7 @@ function getWrappedRunTestCase (runTestCaseFunction, isNewerCucumberVersion = fa
|
|
|
653
661
|
return shouldBePassedByEFD
|
|
654
662
|
}
|
|
655
663
|
|
|
656
|
-
if (isNewerCucumberVersion &&
|
|
664
|
+
if (isNewerCucumberVersion && isTestManagementTestsEnabled && isQuarantined) {
|
|
657
665
|
return shouldBePassedByQuarantine
|
|
658
666
|
}
|
|
659
667
|
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { addHook } = require('./helpers/instrument')
|
|
4
|
+
const shimmer = require('../../datadog-shimmer')
|
|
5
|
+
|
|
6
|
+
const vertexaiTracingChannel = require('dc-polyfill').tracingChannel('apm:vertexai:request')
|
|
7
|
+
|
|
8
|
+
function wrapGenerate (generate) {
|
|
9
|
+
return function (request) {
|
|
10
|
+
if (!vertexaiTracingChannel.start.hasSubscribers) {
|
|
11
|
+
return generate.apply(this, arguments)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const ctx = {
|
|
15
|
+
request,
|
|
16
|
+
instance: this,
|
|
17
|
+
resource: [this.constructor.name, generate.name].join('.')
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return vertexaiTracingChannel.tracePromise(generate, ctx, this, ...arguments)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function wrapGenerateStream (generateStream) {
|
|
25
|
+
return function (request) {
|
|
26
|
+
if (!vertexaiTracingChannel.start.hasSubscribers) {
|
|
27
|
+
return generateStream.apply(this, arguments)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const ctx = {
|
|
31
|
+
request,
|
|
32
|
+
instance: this,
|
|
33
|
+
resource: [this.constructor.name, generateStream.name].join('.'),
|
|
34
|
+
stream: true
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return vertexaiTracingChannel.start.runStores(ctx, () => {
|
|
38
|
+
let streamingResult
|
|
39
|
+
try {
|
|
40
|
+
streamingResult = generateStream.apply(this, arguments)
|
|
41
|
+
} catch (e) {
|
|
42
|
+
finish(ctx, null, e, true)
|
|
43
|
+
throw e
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
vertexaiTracingChannel.end.publish(ctx)
|
|
47
|
+
|
|
48
|
+
return streamingResult.then(stream => {
|
|
49
|
+
stream.response.then(response => {
|
|
50
|
+
finish(ctx, response, null)
|
|
51
|
+
}).catch(e => {
|
|
52
|
+
finish(ctx, null, e)
|
|
53
|
+
throw e
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
return stream
|
|
57
|
+
}).catch(e => {
|
|
58
|
+
finish(ctx, null, e)
|
|
59
|
+
throw e
|
|
60
|
+
})
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function finish (ctx, response, err, publishEndEvent = false) {
|
|
66
|
+
if (err) {
|
|
67
|
+
ctx.error = err
|
|
68
|
+
vertexaiTracingChannel.error.publish(ctx)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
ctx.result = { response }
|
|
72
|
+
|
|
73
|
+
if (publishEndEvent) vertexaiTracingChannel.end.publish(ctx)
|
|
74
|
+
|
|
75
|
+
vertexaiTracingChannel.asyncEnd.publish(ctx)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
addHook({
|
|
79
|
+
name: '@google-cloud/vertexai',
|
|
80
|
+
file: 'build/src/models/generative_models.js',
|
|
81
|
+
versions: ['>=1']
|
|
82
|
+
}, exports => {
|
|
83
|
+
const GenerativeModel = exports.GenerativeModel
|
|
84
|
+
|
|
85
|
+
shimmer.wrap(GenerativeModel.prototype, 'generateContent', wrapGenerate)
|
|
86
|
+
shimmer.wrap(GenerativeModel.prototype, 'generateContentStream', wrapGenerateStream)
|
|
87
|
+
|
|
88
|
+
return exports
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
addHook({
|
|
92
|
+
name: '@google-cloud/vertexai',
|
|
93
|
+
file: 'build/src/models/chat_session.js',
|
|
94
|
+
versions: ['>=1']
|
|
95
|
+
}, exports => {
|
|
96
|
+
const ChatSession = exports.ChatSession
|
|
97
|
+
|
|
98
|
+
shimmer.wrap(ChatSession.prototype, 'sendMessage', wrapGenerate)
|
|
99
|
+
shimmer.wrap(ChatSession.prototype, 'sendMessageStream', wrapGenerateStream)
|
|
100
|
+
|
|
101
|
+
return exports
|
|
102
|
+
})
|
|
@@ -26,7 +26,7 @@ const potentialConflicts = new Set([
|
|
|
26
26
|
'sqreen'
|
|
27
27
|
])
|
|
28
28
|
|
|
29
|
-
const extractPackageAndModulePath = require('./
|
|
29
|
+
const extractPackageAndModulePath = require('./extract-package-and-module-path')
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* The lowest hanging fruit to debug an app that isn't tracing
|
|
@@ -45,7 +45,7 @@ const extractPackageAndModulePath = require('./utils/src/extract-package-and-mod
|
|
|
45
45
|
* This is OK as the tracer should be loaded earlier anyway.
|
|
46
46
|
*/
|
|
47
47
|
module.exports.checkForRequiredModules = function () {
|
|
48
|
-
const packages = require('
|
|
48
|
+
const packages = require('./hooks')
|
|
49
49
|
const naughties = new Set()
|
|
50
50
|
let didWarn = false
|
|
51
51
|
|
|
@@ -11,6 +11,7 @@ module.exports = {
|
|
|
11
11
|
'@elastic/elasticsearch': () => require('../elasticsearch'),
|
|
12
12
|
'@elastic/transport': () => require('../elasticsearch'),
|
|
13
13
|
'@google-cloud/pubsub': () => require('../google-cloud-pubsub'),
|
|
14
|
+
'@google-cloud/vertexai': () => require('../google-cloud-vertexai'),
|
|
14
15
|
'@graphql-tools/executor': () => require('../graphql'),
|
|
15
16
|
'@grpc/grpc-js': () => require('../grpc'),
|
|
16
17
|
'@hapi/hapi': () => require('../hapi'),
|
|
@@ -20,7 +21,6 @@ module.exports = {
|
|
|
20
21
|
'@jest/transform': () => require('../jest'),
|
|
21
22
|
'@koa/router': () => require('../koa'),
|
|
22
23
|
'@langchain/core': { esmFirst: true, fn: () => require('../langchain') },
|
|
23
|
-
'@langchain/openai': { esmFirst: true, fn: () => require('../langchain') },
|
|
24
24
|
'@node-redis/client': () => require('../redis'),
|
|
25
25
|
'@opensearch-project/opensearch': () => require('../opensearch'),
|
|
26
26
|
'@opentelemetry/sdk-trace-node': () => require('../otel-sdk-trace'),
|
|
@@ -50,7 +50,7 @@ module.exports = {
|
|
|
50
50
|
'express-session': () => require('../express-session'),
|
|
51
51
|
fastify: () => require('../fastify'),
|
|
52
52
|
'find-my-way': () => require('../find-my-way'),
|
|
53
|
-
fs: () => require('../fs'),
|
|
53
|
+
fs: { serverless: false, fn: () => require('../fs') },
|
|
54
54
|
'generic-pool': () => require('../generic-pool'),
|
|
55
55
|
graphql: () => require('../graphql'),
|
|
56
56
|
grpc: () => require('../grpc'),
|
|
@@ -6,8 +6,9 @@ const satisfies = require('semifies')
|
|
|
6
6
|
const Hook = require('./hook')
|
|
7
7
|
const requirePackageJson = require('../../../dd-trace/src/require-package-json')
|
|
8
8
|
const log = require('../../../dd-trace/src/log')
|
|
9
|
-
const checkRequireCache = require('
|
|
9
|
+
const checkRequireCache = require('./check-require-cache')
|
|
10
10
|
const telemetry = require('../../../dd-trace/src/guardrails/telemetry')
|
|
11
|
+
const { isInServerlessEnvironment } = require('../../../dd-trace/src/serverless')
|
|
11
12
|
|
|
12
13
|
const {
|
|
13
14
|
DD_TRACE_DISABLED_INSTRUMENTATIONS = '',
|
|
@@ -60,6 +61,8 @@ for (const packageName of names) {
|
|
|
60
61
|
let hook = hooks[packageName]
|
|
61
62
|
|
|
62
63
|
if (typeof hook === 'object') {
|
|
64
|
+
if (hook.serverless === false && isInServerlessEnvironment()) continue
|
|
65
|
+
|
|
63
66
|
hookOptions.internals = hook.esmFirst
|
|
64
67
|
hook = hook.fn
|
|
65
68
|
}
|