dd-trace 5.67.0 → 5.69.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 +6 -4
- package/README.md +0 -2
- package/ci/init.js +52 -54
- package/ext/exporters.d.ts +2 -1
- package/ext/exporters.js +2 -1
- package/index.d.ts +240 -3
- package/initialize.mjs +1 -1
- package/package.json +17 -11
- package/packages/datadog-core/src/storage.js +14 -13
- package/packages/datadog-esbuild/index.js +118 -26
- package/packages/datadog-instrumentations/src/aws-sdk.js +42 -4
- package/packages/datadog-instrumentations/src/azure-functions.js +1 -1
- package/packages/datadog-instrumentations/src/azure-service-bus.js +1 -1
- package/packages/datadog-instrumentations/src/cassandra-driver.js +2 -2
- package/packages/datadog-instrumentations/src/connect.js +6 -2
- package/packages/datadog-instrumentations/src/cucumber.js +31 -6
- package/packages/datadog-instrumentations/src/express.js +5 -6
- package/packages/datadog-instrumentations/src/fastify.js +3 -3
- package/packages/datadog-instrumentations/src/helpers/hook.js +28 -15
- package/packages/datadog-instrumentations/src/helpers/hooks.js +2 -0
- package/packages/datadog-instrumentations/src/helpers/instrument.js +15 -5
- package/packages/datadog-instrumentations/src/helpers/register.js +10 -3
- package/packages/datadog-instrumentations/src/http2/client.js +1 -0
- package/packages/datadog-instrumentations/src/http2/server.js +0 -1
- package/packages/datadog-instrumentations/src/ioredis.js +12 -1
- package/packages/datadog-instrumentations/src/jest.js +48 -36
- package/packages/datadog-instrumentations/src/limitd-client.js +2 -1
- package/packages/datadog-instrumentations/src/mocha/main.js +15 -7
- package/packages/datadog-instrumentations/src/mocha/utils.js +3 -0
- package/packages/datadog-instrumentations/src/mongoose.js +2 -1
- package/packages/datadog-instrumentations/src/oracledb.js +19 -13
- package/packages/datadog-instrumentations/src/pg.js +9 -5
- package/packages/datadog-instrumentations/src/pino.js +18 -6
- package/packages/datadog-instrumentations/src/playwright.js +15 -1
- package/packages/datadog-instrumentations/src/sequelize.js +1 -1
- package/packages/datadog-instrumentations/src/vitest.js +155 -62
- package/packages/datadog-plugin-ai/src/tracing.js +3 -3
- package/packages/datadog-plugin-aws-sdk/src/base.js +23 -8
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/tracing.js +2 -2
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/utils.js +101 -2
- package/packages/datadog-plugin-aws-sdk/src/util.js +1 -1
- package/packages/datadog-plugin-confluentinc-kafka-javascript/src/index.js +6 -0
- package/packages/datadog-plugin-cucumber/src/index.js +4 -56
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +6 -3
- package/packages/datadog-plugin-cypress/src/support.js +4 -0
- package/packages/datadog-plugin-express/src/code_origin.js +2 -2
- package/packages/datadog-plugin-fastify/src/code_origin.js +1 -2
- package/packages/datadog-plugin-jest/src/index.js +0 -21
- package/packages/datadog-plugin-mocha/src/index.js +3 -57
- package/packages/datadog-plugin-mongodb-core/src/index.js +38 -12
- package/packages/datadog-plugin-playwright/src/index.js +11 -5
- package/packages/datadog-plugin-vitest/src/index.js +5 -1
- package/packages/datadog-plugin-ws/src/close.js +1 -1
- package/packages/datadog-plugin-ws/src/producer.js +6 -1
- package/packages/datadog-plugin-ws/src/receiver.js +6 -1
- package/packages/dd-trace/src/aiguard/client.js +25 -0
- package/packages/dd-trace/src/aiguard/noop.js +9 -0
- package/packages/dd-trace/src/aiguard/sdk.js +173 -0
- package/packages/dd-trace/src/aiguard/tags.js +11 -0
- package/packages/dd-trace/src/appsec/iast/path-line.js +21 -4
- package/packages/dd-trace/src/appsec/iast/security-controls/parser.js +1 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +6 -3
- package/packages/dd-trace/src/appsec/stack_trace.js +20 -1
- package/packages/dd-trace/src/appsec/telemetry/waf.js +2 -2
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +4 -4
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/index.js +11 -3
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/writer.js +10 -1
- package/packages/dd-trace/src/config-helper.js +8 -1
- package/packages/dd-trace/src/config.js +92 -304
- package/packages/dd-trace/src/config_defaults.js +191 -0
- package/packages/dd-trace/src/crashtracking/crashtracker.js +2 -1
- package/packages/dd-trace/src/datastreams/fnv.js +2 -2
- package/packages/dd-trace/src/datastreams/index.js +23 -1
- package/packages/dd-trace/src/datastreams/writer.js +3 -2
- package/packages/dd-trace/src/debugger/devtools_client/config.js +2 -1
- package/packages/dd-trace/src/dogstatsd.js +4 -3
- package/packages/dd-trace/src/encode/0.4.js +1 -5
- package/packages/dd-trace/src/exporter.js +1 -0
- package/packages/dd-trace/src/exporters/agent/index.js +3 -2
- package/packages/dd-trace/src/exporters/agent/writer.js +1 -1
- package/packages/dd-trace/src/exporters/common/agent-info-exporter.js +3 -2
- package/packages/dd-trace/src/exporters/common/request.js +2 -1
- package/packages/dd-trace/src/exporters/span-stats/index.js +3 -2
- package/packages/dd-trace/src/llmobs/constants/tags.js +2 -0
- package/packages/dd-trace/src/llmobs/plugins/ai/index.js +15 -4
- package/packages/dd-trace/src/llmobs/plugins/ai/util.js +20 -7
- package/packages/dd-trace/src/llmobs/plugins/bedrockruntime.js +40 -13
- package/packages/dd-trace/src/llmobs/plugins/openai.js +7 -1
- package/packages/dd-trace/src/llmobs/tagger.js +8 -0
- package/packages/dd-trace/src/llmobs/telemetry.js +2 -1
- package/packages/dd-trace/src/log/index.js +27 -16
- package/packages/dd-trace/src/log/log.js +29 -5
- package/packages/dd-trace/src/log/writer.js +5 -5
- package/packages/dd-trace/src/noop/proxy.js +4 -0
- package/packages/dd-trace/src/noop/span.js +1 -0
- package/packages/dd-trace/src/opentelemetry/span.js +14 -3
- package/packages/dd-trace/src/opentracing/span.js +19 -5
- package/packages/dd-trace/src/payload-tagging/config/index.js +16 -0
- package/packages/dd-trace/src/payload-tagging/index.js +26 -15
- package/packages/dd-trace/src/payload-tagging/tagging.js +17 -8
- package/packages/dd-trace/src/pkg.js +3 -1
- package/packages/dd-trace/src/plugin_manager.js +20 -2
- package/packages/dd-trace/src/plugins/ci_plugin.js +97 -3
- package/packages/dd-trace/src/plugins/composite.js +3 -0
- package/packages/dd-trace/src/plugins/index.js +2 -0
- package/packages/dd-trace/src/plugins/plugin.js +67 -0
- package/packages/dd-trace/src/plugins/util/git-cache.js +129 -0
- package/packages/dd-trace/src/plugins/util/git.js +41 -27
- package/packages/dd-trace/src/plugins/util/test.js +56 -27
- package/packages/dd-trace/src/plugins/util/web.js +1 -1
- package/packages/dd-trace/src/priority_sampler.js +70 -46
- package/packages/dd-trace/src/profiler.js +4 -1
- package/packages/dd-trace/src/profiling/config.js +73 -42
- package/packages/dd-trace/src/profiling/profiler.js +3 -1
- package/packages/dd-trace/src/profiling/profilers/events.js +3 -8
- package/packages/dd-trace/src/profiling/profilers/space.js +1 -0
- package/packages/dd-trace/src/profiling/profilers/wall.js +196 -117
- package/packages/dd-trace/src/proxy.js +15 -0
- package/packages/dd-trace/src/rate_limiter.js +26 -1
- package/packages/dd-trace/src/remote_config/capabilities.js +5 -0
- package/packages/dd-trace/src/remote_config/manager.js +3 -2
- package/packages/dd-trace/src/sampling_rule.js +124 -2
- package/packages/dd-trace/src/span_sampler.js +19 -0
- package/packages/dd-trace/src/standalone/product.js +9 -0
- package/packages/dd-trace/src/standalone/tracesource.js +16 -1
- package/packages/dd-trace/src/standalone/tracesource_priority_sampler.js +13 -0
- package/packages/dd-trace/src/startup-log.js +21 -2
- package/packages/dd-trace/src/supported-configurations.json +9 -0
- package/packages/dd-trace/src/telemetry/logs/index.js +2 -2
- package/packages/dd-trace/src/util.js +1 -1
- package/register.js +1 -1
- package/version.js +4 -2
package/LICENSE-3rdparty.csv
CHANGED
|
@@ -16,7 +16,6 @@ require,import-in-the-middle,Apache license 2.0,Copyright 2021 Datadog Inc.
|
|
|
16
16
|
require,istanbul-lib-coverage,BSD-3-Clause,Copyright 2012-2015 Yahoo! Inc.
|
|
17
17
|
require,jest-docblock,MIT,Copyright Meta Platforms, Inc. and affiliates.
|
|
18
18
|
require,jsonpath-plus,MIT,Copyright (c) 2011-2019 Stefan Goessner, Subbu Allamaraju, Mike Brevoort, Robert Krahn, Brett Zamir, Richard Schneider
|
|
19
|
-
require,koalas,MIT,Copyright 2013-2017 Brian Woodward
|
|
20
19
|
require,limiter,MIT,Copyright 2011 John Hurliman
|
|
21
20
|
require,lodash.sortby,MIT,Copyright JS Foundation and other contributors
|
|
22
21
|
require,lru-cache,ISC,Copyright (c) 2010-2022 Isaac Z. Schlueter and Contributors
|
|
@@ -34,7 +33,11 @@ require,shell-quote,mit,Copyright (c) 2013 James Halliday
|
|
|
34
33
|
require,source-map,BSD-3-Clause,Copyright (c) 2009-2011, Mozilla Foundation and contributors
|
|
35
34
|
require,ttl-set,MIT,Copyright (c) 2024 Thomas Watson
|
|
36
35
|
dev,@babel/helpers,MIT,Copyright (c) 2014-present Sebastian McKenzie and other contributors
|
|
37
|
-
dev,@types/
|
|
36
|
+
dev,@types/chai,MIT,Copyright (c) Microsoft Corp.
|
|
37
|
+
dev,@types/mocha,MIT,Copyright (c) Microsoft Corp.
|
|
38
|
+
dev,@types/node,MIT,Copyright (c) Microsoft Corp.
|
|
39
|
+
dev,@types/sinon,MIT,Copyright (c) Microsoft Corp.
|
|
40
|
+
dev,@types/tap,MIT,Copyright (c) Microsoft Corp.
|
|
38
41
|
dev,@eslint/eslintrc,MIT,Copyright OpenJS Foundation and other contributors, <www.openjsf.org>
|
|
39
42
|
dev,@eslint/js,MIT,Copyright OpenJS Foundation and other contributors, <www.openjsf.org>
|
|
40
43
|
dev,@msgpack/msgpack,ISC,Copyright 2019 The MessagePack Community
|
|
@@ -51,7 +54,6 @@ dev,eslint-plugin-n,MIT,Copyright 2015 Toru Nagashima
|
|
|
51
54
|
dev,eslint-plugin-promise,ISC,jden and other contributors
|
|
52
55
|
dev,eslint-plugin-unicorn,MIT,Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
53
56
|
dev,express,MIT,Copyright 2009-2014 TJ Holowaychuk 2013-2014 Roman Shtylman 2014-2015 Douglas Christopher Wilson
|
|
54
|
-
dev,get-port,MIT,Copyright Sindre Sorhus
|
|
55
57
|
dev,glob,ISC,Copyright Isaac Z. Schlueter and Contributors
|
|
56
58
|
dev,globals,MIT,Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
57
59
|
dev,graphql,MIT,Copyright 2015 Facebook Inc.
|
|
@@ -62,12 +64,12 @@ dev,nock,MIT,Copyright 2017 Pedro Teixeira and other contributors
|
|
|
62
64
|
dev,nyc,ISC,Copyright 2015 Contributors
|
|
63
65
|
dev,octokit,MIT,Copyright 2023 Octokit contributors
|
|
64
66
|
dev,proxyquire,MIT,Copyright 2013 Thorsten Lorenz
|
|
65
|
-
dev,rimraf,ISC,Copyright Isaac Z. Schlueter and Contributors
|
|
66
67
|
dev,semver,ISC,Copyright Isaac Z. Schlueter and Contributors
|
|
67
68
|
dev,sinon,BSD-3-Clause,Copyright 2010-2017 Christian Johansen
|
|
68
69
|
dev,sinon-chai,WTFPL and BSD-2-Clause,Copyright 2004 Sam Hocevar 2012–2017 Domenic Denicola
|
|
69
70
|
dev,tap,ISC,Copyright 2011-2022 Isaac Z. Schlueter and Contributors
|
|
70
71
|
dev,tiktoken,MIT,Copyright (c) 2022 OpenAI, Shantanu Jain
|
|
72
|
+
dev,typescript,Apache license 2.0,Copyright Microsoft Corp.
|
|
71
73
|
dev,workerpool,Apache license 2.0,Copyright (C) 2014-2024 Jos de Jong wjosdejong@gmail.com
|
|
72
74
|
dev,yaml,ISC,Copyright Eemeli Aro <eemeli@gmail.com>
|
|
73
75
|
dev,yarn-deduplicate,Apache license 2.0,Copyright [yyyy] [name of copyright owner]
|
package/README.md
CHANGED
|
@@ -97,5 +97,3 @@ Please refer to the [SECURITY.md](https://github.com/DataDog/dd-trace-js/blob/ma
|
|
|
97
97
|
## Datadog With OpenTelemetery
|
|
98
98
|
|
|
99
99
|
Please refer to the [Node.js Custom Instrumentation using OpenTelemetry API](https://docs.datadoghq.com/tracing/trace_collection/custom_instrumentation/nodejs/otel/) document. It includes information on how to use the OpenTelemetry API with dd-trace-js.
|
|
100
|
-
|
|
101
|
-
Note that our internal implementation of the OpenTelemetry API is currently set within the version range `>=1.0.0 <1.9.0`. This range will be updated at a regular cadence therefore, we recommend updating your tracer to the latest release to ensure up to date support.
|
package/ci/init.js
CHANGED
|
@@ -6,80 +6,78 @@ const { isTrue, isFalse } = require('../packages/dd-trace/src/util')
|
|
|
6
6
|
const log = require('../packages/dd-trace/src/log')
|
|
7
7
|
const { getEnvironmentVariable } = require('../packages/dd-trace/src/config-helper')
|
|
8
8
|
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
const PACKAGE_MANAGERS = ['npm', 'yarn', 'pnpm']
|
|
10
|
+
const DEFAULT_FLUSH_INTERVAL = 5000
|
|
11
|
+
const JEST_FLUSH_INTERVAL = 0
|
|
12
|
+
const EXPORTER_MAP = {
|
|
13
|
+
jest: 'jest_worker',
|
|
14
|
+
cucumber: 'cucumber_worker',
|
|
15
|
+
mocha: 'mocha_worker',
|
|
16
|
+
playwright: 'playwright_worker',
|
|
17
|
+
vitest: 'vitest_worker'
|
|
18
|
+
}
|
|
14
19
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
function isPackageManager () {
|
|
21
|
+
return PACKAGE_MANAGERS.some(packageManager =>
|
|
22
|
+
process.argv[1]?.includes(`bin/${packageManager}`)
|
|
23
|
+
)
|
|
24
|
+
}
|
|
20
25
|
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
function detectTestWorkerType () {
|
|
27
|
+
if (getEnvironmentVariable('JEST_WORKER_ID')) return 'jest'
|
|
28
|
+
if (getEnvironmentVariable('CUCUMBER_WORKER_ID')) return 'cucumber'
|
|
29
|
+
if (getEnvironmentVariable('MOCHA_WORKER_ID')) return 'mocha'
|
|
30
|
+
if (getEnvironmentVariable('DD_PLAYWRIGHT_WORKER')) return 'playwright'
|
|
31
|
+
if (getEnvironmentVariable('TINYPOOL_WORKER_ID')) return 'vitest'
|
|
32
|
+
return null
|
|
23
33
|
}
|
|
24
34
|
|
|
25
|
-
const
|
|
35
|
+
const testWorkerType = detectTestWorkerType()
|
|
36
|
+
const isTestWorker = testWorkerType !== null
|
|
37
|
+
const isJestWorker = testWorkerType === 'jest'
|
|
38
|
+
|
|
39
|
+
const baseOptions = {
|
|
26
40
|
startupLogs: false,
|
|
27
41
|
isCiVisibility: true,
|
|
28
|
-
flushInterval: isJestWorker ?
|
|
42
|
+
flushInterval: isJestWorker ? JEST_FLUSH_INTERVAL : DEFAULT_FLUSH_INTERVAL
|
|
29
43
|
}
|
|
30
44
|
|
|
31
45
|
let shouldInit = !isFalse(getEnvironmentVariable('DD_CIVISIBILITY_ENABLED'))
|
|
46
|
+
const isAgentlessEnabled = isTrue(getEnvironmentVariable('DD_CIVISIBILITY_AGENTLESS_ENABLED'))
|
|
32
47
|
|
|
33
|
-
if (isPackageManager()) {
|
|
48
|
+
if (!isTestWorker && isPackageManager()) {
|
|
34
49
|
log.debug('dd-trace is not initialized in a package manager.')
|
|
35
50
|
shouldInit = false
|
|
36
51
|
}
|
|
37
52
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
options.experimental = {
|
|
43
|
-
exporter: 'datadog'
|
|
44
|
-
}
|
|
45
|
-
} else {
|
|
46
|
-
console.error('DD_CIVISIBILITY_AGENTLESS_ENABLED is set, but neither ' +
|
|
47
|
-
'DD_API_KEY nor DATADOG_API_KEY are set in your environment, so ' +
|
|
48
|
-
'dd-trace will not be initialized.')
|
|
49
|
-
shouldInit = false
|
|
53
|
+
if (isTestWorker) {
|
|
54
|
+
baseOptions.telemetry = { enabled: false }
|
|
55
|
+
baseOptions.experimental = {
|
|
56
|
+
exporter: EXPORTER_MAP[testWorkerType]
|
|
50
57
|
}
|
|
51
58
|
} else {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (isMochaWorker) {
|
|
70
|
-
options.experimental = {
|
|
71
|
-
exporter: 'mocha_worker'
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (isPlaywrightWorker) {
|
|
76
|
-
options.experimental = {
|
|
77
|
-
exporter: 'playwright_worker'
|
|
59
|
+
if (isAgentlessEnabled) {
|
|
60
|
+
if (getEnvironmentVariable('DD_API_KEY')) {
|
|
61
|
+
baseOptions.experimental = {
|
|
62
|
+
exporter: 'datadog'
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
console.error(
|
|
66
|
+
'DD_CIVISIBILITY_AGENTLESS_ENABLED is set, but neither ' +
|
|
67
|
+
'DD_API_KEY nor DATADOG_API_KEY are set in your environment, so ' +
|
|
68
|
+
'dd-trace will not be initialized.'
|
|
69
|
+
)
|
|
70
|
+
shouldInit = false
|
|
71
|
+
}
|
|
72
|
+
} else {
|
|
73
|
+
baseOptions.experimental = {
|
|
74
|
+
exporter: 'agent_proxy'
|
|
75
|
+
}
|
|
78
76
|
}
|
|
79
77
|
}
|
|
80
78
|
|
|
81
79
|
if (shouldInit) {
|
|
82
|
-
tracer.init(
|
|
80
|
+
tracer.init(baseOptions)
|
|
83
81
|
tracer.use('fs', false)
|
|
84
82
|
tracer.use('child_process', false)
|
|
85
83
|
}
|
package/ext/exporters.d.ts
CHANGED
|
@@ -6,7 +6,8 @@ declare const exporters: {
|
|
|
6
6
|
JEST_WORKER: 'jest_worker',
|
|
7
7
|
CUCUMBER_WORKER: 'cucumber_worker',
|
|
8
8
|
MOCHA_WORKER: 'mocha_worker',
|
|
9
|
-
PLAYWRIGHT_WORKER: 'playwright_worker'
|
|
9
|
+
PLAYWRIGHT_WORKER: 'playwright_worker',
|
|
10
|
+
VITEST_WORKER: 'vitest_worker'
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
export = exporters
|
package/ext/exporters.js
CHANGED
package/index.d.ts
CHANGED
|
@@ -139,6 +139,11 @@ interface Tracer extends opentracing.Tracer {
|
|
|
139
139
|
*/
|
|
140
140
|
llmobs: tracer.llmobs.LLMObs;
|
|
141
141
|
|
|
142
|
+
/**
|
|
143
|
+
* AI Guard SDK
|
|
144
|
+
*/
|
|
145
|
+
aiguard: tracer.aiguard.AIGuard;
|
|
146
|
+
|
|
142
147
|
/**
|
|
143
148
|
* @experimental
|
|
144
149
|
* Provide same functionality as OpenTelemetry Baggage:
|
|
@@ -253,7 +258,7 @@ declare namespace tracer {
|
|
|
253
258
|
/**
|
|
254
259
|
* An array of span links
|
|
255
260
|
*/
|
|
256
|
-
links?:
|
|
261
|
+
links?: { context: SpanContext, attributes?: Object }[]
|
|
257
262
|
}
|
|
258
263
|
|
|
259
264
|
/**
|
|
@@ -268,11 +273,34 @@ declare namespace tracer {
|
|
|
268
273
|
|
|
269
274
|
/**
|
|
270
275
|
* Causally links another span to the current span
|
|
276
|
+
*
|
|
277
|
+
* @deprecated In favor of addLink(link: { context: SpanContext, attributes?: Object }).
|
|
278
|
+
* This will be removed in the next major version.
|
|
271
279
|
* @param {SpanContext} context The context of the span to link to.
|
|
272
280
|
* @param {Object} attributes An optional key value pair of arbitrary values.
|
|
273
281
|
* @returns {void}
|
|
274
282
|
*/
|
|
275
283
|
addLink (context: SpanContext, attributes?: Object): void;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Adds a single link to the span.
|
|
287
|
+
*
|
|
288
|
+
* Links added after the creation will not affect the sampling decision.
|
|
289
|
+
* It is preferred span links be added at span creation.
|
|
290
|
+
*
|
|
291
|
+
* @param link the link to add.
|
|
292
|
+
*/
|
|
293
|
+
addLink (link: { context: SpanContext, attributes?: Object }): void;
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Adds multiple links to the span.
|
|
297
|
+
*
|
|
298
|
+
* Links added after the creation will not affect the sampling decision.
|
|
299
|
+
* It is preferred span links be added at span creation.
|
|
300
|
+
*
|
|
301
|
+
* @param links the links to add.
|
|
302
|
+
*/
|
|
303
|
+
addLinks (links: { context: SpanContext, attributes?: Object }[]): void;
|
|
276
304
|
}
|
|
277
305
|
|
|
278
306
|
/**
|
|
@@ -404,7 +432,7 @@ declare namespace tracer {
|
|
|
404
432
|
|
|
405
433
|
/**
|
|
406
434
|
* The address of the trace agent that the tracer will submit to.
|
|
407
|
-
* @default '
|
|
435
|
+
* @default '127.0.0.1'
|
|
408
436
|
*/
|
|
409
437
|
hostname?: string;
|
|
410
438
|
|
|
@@ -570,6 +598,29 @@ declare namespace tracer {
|
|
|
570
598
|
*/
|
|
571
599
|
enabled?: boolean
|
|
572
600
|
}
|
|
601
|
+
},
|
|
602
|
+
|
|
603
|
+
aiguard?: {
|
|
604
|
+
/**
|
|
605
|
+
* Set to `true` to enable the SDK.
|
|
606
|
+
*/
|
|
607
|
+
enabled?: boolean,
|
|
608
|
+
/**
|
|
609
|
+
* URL of the AI Guard REST API.
|
|
610
|
+
*/
|
|
611
|
+
endpoint?: string,
|
|
612
|
+
/**
|
|
613
|
+
* Timeout used in calls to the AI Guard REST API in milliseconds (default 5000)
|
|
614
|
+
*/
|
|
615
|
+
timeout?: number,
|
|
616
|
+
/**
|
|
617
|
+
* Maximum number of conversational messages allowed to be set in the meta-struct
|
|
618
|
+
*/
|
|
619
|
+
maxMessagesLength?: number,
|
|
620
|
+
/**
|
|
621
|
+
* Max size of the content property set in the meta-struct
|
|
622
|
+
*/
|
|
623
|
+
maxContentSize?: number
|
|
573
624
|
}
|
|
574
625
|
};
|
|
575
626
|
|
|
@@ -884,7 +935,7 @@ declare namespace tracer {
|
|
|
884
935
|
scope?: string,
|
|
885
936
|
|
|
886
937
|
/**
|
|
887
|
-
* Custom fields to attach to the user (RBAC, Oauth, etc
|
|
938
|
+
* Custom fields to attach to the user (RBAC, Oauth, etc...).
|
|
888
939
|
*/
|
|
889
940
|
[key: string]: string | undefined
|
|
890
941
|
}
|
|
@@ -1036,6 +1087,170 @@ declare namespace tracer {
|
|
|
1036
1087
|
eventTrackingV2: EventTrackingV2
|
|
1037
1088
|
}
|
|
1038
1089
|
|
|
1090
|
+
export namespace aiguard {
|
|
1091
|
+
|
|
1092
|
+
/**
|
|
1093
|
+
* Represents a tool call made by an AI assistant in an agentic workflow.
|
|
1094
|
+
*/
|
|
1095
|
+
export interface ToolCall {
|
|
1096
|
+
/**
|
|
1097
|
+
* Unique identifier for this specific tool call instance used to correlate the call with its response.
|
|
1098
|
+
*/
|
|
1099
|
+
id: string;
|
|
1100
|
+
/**
|
|
1101
|
+
* Details about the function being invoked.
|
|
1102
|
+
*/
|
|
1103
|
+
function: {
|
|
1104
|
+
/**
|
|
1105
|
+
* The name of the tool/function to be called.
|
|
1106
|
+
*/
|
|
1107
|
+
name: string;
|
|
1108
|
+
/**
|
|
1109
|
+
* String containing the arguments to pass to the tool.
|
|
1110
|
+
*/
|
|
1111
|
+
arguments: string;
|
|
1112
|
+
};
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
/**
|
|
1116
|
+
* A standard conversational message exchanged with a Large Language Model (LLM).
|
|
1117
|
+
*/
|
|
1118
|
+
export interface TextMessage {
|
|
1119
|
+
/**
|
|
1120
|
+
* The role of the message sender in the conversation (e.g.: 'system', 'user', 'assistant').
|
|
1121
|
+
*/
|
|
1122
|
+
role: string;
|
|
1123
|
+
/**
|
|
1124
|
+
* The textual content of the message.
|
|
1125
|
+
*/
|
|
1126
|
+
content: string;
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
/**
|
|
1130
|
+
* A message from an AI assistant containing only textual content.
|
|
1131
|
+
*/
|
|
1132
|
+
export interface AssistantTextMessage {
|
|
1133
|
+
/**
|
|
1134
|
+
* The role identifier, always set to 'assistant'
|
|
1135
|
+
*/
|
|
1136
|
+
role: "assistant";
|
|
1137
|
+
/**
|
|
1138
|
+
* The textual response content from the assistant.
|
|
1139
|
+
*/
|
|
1140
|
+
content: string;
|
|
1141
|
+
/**
|
|
1142
|
+
* Explicitly excluded when content is present to maintain type safety.
|
|
1143
|
+
*/
|
|
1144
|
+
tool_calls?: never;
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
/**
|
|
1148
|
+
* A message from an AI assistant that initiates one or more tool calls.
|
|
1149
|
+
*/
|
|
1150
|
+
export interface AssistantToolCallMessage {
|
|
1151
|
+
/**
|
|
1152
|
+
* The role identifier, always set to 'assistant'
|
|
1153
|
+
*/
|
|
1154
|
+
role: "assistant";
|
|
1155
|
+
/**
|
|
1156
|
+
* Array of tool calls that the assistant wants to execute.
|
|
1157
|
+
*/
|
|
1158
|
+
tool_calls: ToolCall[];
|
|
1159
|
+
/**
|
|
1160
|
+
* Explicitly excluded when tool calls are present to maintain type safety.
|
|
1161
|
+
*/
|
|
1162
|
+
content?: never;
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
/**
|
|
1166
|
+
* A message containing the result of a tool invocation.
|
|
1167
|
+
*/
|
|
1168
|
+
export interface ToolMessage {
|
|
1169
|
+
/**
|
|
1170
|
+
* The role identifier, always set to 'tool' for tool execution results.
|
|
1171
|
+
*/
|
|
1172
|
+
role: "tool";
|
|
1173
|
+
/**
|
|
1174
|
+
* The unique identifier linking this result to the original tool call.
|
|
1175
|
+
* Must correspond to a ToolCall.id from a previous AssistantToolCallMessage.
|
|
1176
|
+
*/
|
|
1177
|
+
tool_call_id: string;
|
|
1178
|
+
/**
|
|
1179
|
+
* The output returned by the tool execution.
|
|
1180
|
+
*/
|
|
1181
|
+
content: string;
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
export type Message =
|
|
1185
|
+
| TextMessage
|
|
1186
|
+
| AssistantTextMessage
|
|
1187
|
+
| AssistantToolCallMessage
|
|
1188
|
+
| ToolMessage;
|
|
1189
|
+
|
|
1190
|
+
/**
|
|
1191
|
+
* The result returned by AI Guard after evaluating a conversation.
|
|
1192
|
+
*/
|
|
1193
|
+
export interface Evaluation {
|
|
1194
|
+
/**
|
|
1195
|
+
* The security action determined by AI Guard:
|
|
1196
|
+
* - 'ALLOW': The conversation is safe to proceed
|
|
1197
|
+
* - 'DENY': The current conversation exchange should be blocked
|
|
1198
|
+
* - 'ABORT': The full workflow should be terminated immediately
|
|
1199
|
+
*/
|
|
1200
|
+
action: 'ALLOW' | 'DENY' | 'ABORT';
|
|
1201
|
+
/**
|
|
1202
|
+
* Human-readable explanation for why this action was chosen.
|
|
1203
|
+
*/
|
|
1204
|
+
reason: string;
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
/**
|
|
1208
|
+
* Error thrown when AI Guard evaluation determines that a conversation should be blocked
|
|
1209
|
+
* and the client is configured to enforce blocking mode.
|
|
1210
|
+
*/
|
|
1211
|
+
export interface AIGuardAbortError extends Error {
|
|
1212
|
+
/**
|
|
1213
|
+
* Human-readable explanation from AI Guard describing why the conversation was blocked.
|
|
1214
|
+
*/
|
|
1215
|
+
reason: string;
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
/**
|
|
1219
|
+
* Error thrown when the AI Guard SDK encounters communication failures or API errors while attempting to
|
|
1220
|
+
* evaluate conversations.
|
|
1221
|
+
*/
|
|
1222
|
+
export interface AIGuardClientError extends Error {
|
|
1223
|
+
/**
|
|
1224
|
+
* Detailed error information returned by the AI Guard API, formatted according to the JSON:API error
|
|
1225
|
+
* specification.
|
|
1226
|
+
*/
|
|
1227
|
+
errors?: unknown[];
|
|
1228
|
+
/**
|
|
1229
|
+
* The underlying error that caused the communication failure, such as network timeouts, connection refused,
|
|
1230
|
+
* or JSON parsing errors.
|
|
1231
|
+
*/
|
|
1232
|
+
cause?: Error;
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
/**
|
|
1236
|
+
* AI Guard security client for evaluating AI conversations.
|
|
1237
|
+
*/
|
|
1238
|
+
export interface AIGuard {
|
|
1239
|
+
/**
|
|
1240
|
+
* Evaluates a conversation thread.
|
|
1241
|
+
*
|
|
1242
|
+
* @param messages - Array of conversation messages
|
|
1243
|
+
* @param opts - Optional configuration object:
|
|
1244
|
+
* - `block`: When true, throws an exception if evaluation result is not 'ALLOW'
|
|
1245
|
+
* and the AI Guard service has blocking mode enabled (default: false).
|
|
1246
|
+
* @returns Promise resolving to an Evaluation with the security decision and reasoning.
|
|
1247
|
+
* The promise rejects with AIGuardAbortError when `opts.block` is true and the evaluation result would block the request.
|
|
1248
|
+
* The promise rejects with AIGuardClientError when communication with the AI Guard service fails.
|
|
1249
|
+
*/
|
|
1250
|
+
evaluate (messages: Message[], opts?: { block?: boolean }): Promise<Evaluation>;
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1039
1254
|
/** @hidden */
|
|
1040
1255
|
type anyObject = {
|
|
1041
1256
|
[key: string]: any;
|
|
@@ -2311,11 +2526,33 @@ declare namespace tracer {
|
|
|
2311
2526
|
|
|
2312
2527
|
/**
|
|
2313
2528
|
* Causally links another span to the current span
|
|
2529
|
+
*
|
|
2530
|
+
* @deprecated In favor of addLink(link: otel.Link). This will be removed in the next major version.
|
|
2314
2531
|
* @param {otel.SpanContext} context The context of the span to link to.
|
|
2315
2532
|
* @param {SpanAttributes} attributes An optional key value pair of arbitrary values.
|
|
2316
2533
|
* @returns {void}
|
|
2317
2534
|
*/
|
|
2318
2535
|
addLink(context: otel.SpanContext, attributes?: SpanAttributes): void;
|
|
2536
|
+
|
|
2537
|
+
/**
|
|
2538
|
+
* Adds a single link to the span.
|
|
2539
|
+
*
|
|
2540
|
+
* Links added after the creation will not affect the sampling decision.
|
|
2541
|
+
* It is preferred span links be added at span creation.
|
|
2542
|
+
*
|
|
2543
|
+
* @param link the link to add.
|
|
2544
|
+
*/
|
|
2545
|
+
addLink(link: otel.Link): this;
|
|
2546
|
+
|
|
2547
|
+
/**
|
|
2548
|
+
* Adds multiple links to the span.
|
|
2549
|
+
*
|
|
2550
|
+
* Links added after the creation will not affect the sampling decision.
|
|
2551
|
+
* It is preferred span links be added at span creation.
|
|
2552
|
+
*
|
|
2553
|
+
* @param links the links to add.
|
|
2554
|
+
*/
|
|
2555
|
+
addLinks(links: otel.Link[]): this;
|
|
2319
2556
|
}
|
|
2320
2557
|
|
|
2321
2558
|
/**
|
package/initialize.mjs
CHANGED
|
@@ -36,7 +36,7 @@ ${result.source}`
|
|
|
36
36
|
const [NODE_MAJOR, NODE_MINOR] = process.versions.node.split('.').map(Number)
|
|
37
37
|
|
|
38
38
|
const brokenLoaders = NODE_MAJOR === 18 && NODE_MINOR === 0
|
|
39
|
-
const iitmExclusions = [/langsmith/, /openai\/_shims/, /openai\/resources\/chat\/completions\/messages/]
|
|
39
|
+
const iitmExclusions = [/langsmith/, /openai\/_shims/, /openai\/resources\/chat\/completions\/messages/, /openai\/agents-core\/dist\/shims/]
|
|
40
40
|
|
|
41
41
|
export async function load (url, context, nextLoad) {
|
|
42
42
|
const iitmExclusionsMatch = iitmExclusions.some((exclusion) => exclusion.test(url))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dd-trace",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.69.0",
|
|
4
4
|
"description": "Datadog APM tracing client for JavaScript",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"bench": "node benchmark/index.js",
|
|
11
11
|
"bench:e2e:test-optimization": "node benchmark/e2e-test-optimization/benchmark-run.js",
|
|
12
12
|
"dependencies:dedupe": "yarn-deduplicate yarn.lock",
|
|
13
|
+
"type:check": "tsc --noEmit -p tsconfig.json",
|
|
13
14
|
"type:doc": "cd docs && yarn && yarn build",
|
|
14
15
|
"type:test": "cd docs && yarn && yarn test",
|
|
15
16
|
"lint": "node scripts/check_licenses.js && eslint . --concurrency=auto --max-warnings 0",
|
|
@@ -18,6 +19,8 @@
|
|
|
18
19
|
"release:proposal": "node scripts/release/proposal",
|
|
19
20
|
"services": "node ./scripts/install_plugin_modules && node packages/dd-trace/test/setup/services",
|
|
20
21
|
"test": "SERVICES=* yarn services && mocha --expose-gc 'packages/dd-trace/test/setup/node.js' 'packages/*/test/**/*.spec.js'",
|
|
22
|
+
"test:aiguard": "mocha -r \"packages/dd-trace/test/setup/mocha.js\" \"packages/dd-trace/test/aiguard/**/*.spec.js\"",
|
|
23
|
+
"test:aiguard:ci": "nyc --no-clean --include \"packages/dd-trace/src/aiguard/**/*.js\" -- npm run test:aiguard",
|
|
21
24
|
"test:appsec": "mocha -r \"packages/dd-trace/test/setup/mocha.js\" --exclude \"packages/dd-trace/test/appsec/**/*.plugin.spec.js\" \"packages/dd-trace/test/appsec/**/*.spec.js\"",
|
|
22
25
|
"test:appsec:ci": "nyc --no-clean --include \"packages/dd-trace/src/appsec/**/*.js\" --exclude \"packages/dd-trace/test/appsec/**/*.plugin.spec.js\" -- npm run test:appsec",
|
|
23
26
|
"test:appsec:plugins": "mocha -r \"packages/dd-trace/test/setup/mocha.js\" \"packages/dd-trace/test/appsec/**/*.@($(echo $PLUGINS)).plugin.spec.js\"",
|
|
@@ -47,6 +50,7 @@
|
|
|
47
50
|
"test:profiler": "tap \"packages/dd-trace/test/profiling/**/*.spec.js\"",
|
|
48
51
|
"test:profiler:ci": "npm run test:profiler -- --coverage --nyc-arg=--include=\"packages/dd-trace/src/profiling/**/*.js\"",
|
|
49
52
|
"test:integration": "mocha --timeout 60000 -r \"packages/dd-trace/test/setup/core.js\" \"integration-tests/*.spec.js\"",
|
|
53
|
+
"test:integration:aiguard": "mocha --timeout 60000 -r \"packages/dd-trace/test/setup/core.js\" \"integration-tests/aiguard/*.spec.js\"",
|
|
50
54
|
"test:integration:appsec": "mocha --timeout 60000 -r \"packages/dd-trace/test/setup/core.js\" \"integration-tests/appsec/*.spec.js\"",
|
|
51
55
|
"test:integration:cucumber": "mocha --timeout 60000 -r \"packages/dd-trace/test/setup/core.js\" \"integration-tests/cucumber/*.spec.js\"",
|
|
52
56
|
"test:integration:cypress": "mocha --timeout 60000 -r \"packages/dd-trace/test/setup/core.js\" \"integration-tests/cypress/*.spec.js\"",
|
|
@@ -121,8 +125,8 @@
|
|
|
121
125
|
"@datadog/sketches-js": "2.1.1",
|
|
122
126
|
"@datadog/wasm-js-rewriter": "4.0.1",
|
|
123
127
|
"@isaacs/ttlcache": "^1.4.1",
|
|
124
|
-
"@opentelemetry/api": "1.
|
|
125
|
-
"@opentelemetry/core": "
|
|
128
|
+
"@opentelemetry/api": ">=1.0.0 <1.10.0",
|
|
129
|
+
"@opentelemetry/core": ">=1.14.0 <1.31.0",
|
|
126
130
|
"crypto-randomuuid": "^1.0.0",
|
|
127
131
|
"dc-polyfill": "^0.1.10",
|
|
128
132
|
"ignore": "^7.0.5",
|
|
@@ -130,7 +134,6 @@
|
|
|
130
134
|
"istanbul-lib-coverage": "^3.2.2",
|
|
131
135
|
"jest-docblock": "^29.7.0",
|
|
132
136
|
"jsonpath-plus": "^10.3.0",
|
|
133
|
-
"koalas": "^1.0.2",
|
|
134
137
|
"limiter": "^1.1.5",
|
|
135
138
|
"lodash.sortby": "^4.7.0",
|
|
136
139
|
"lru-cache": "^10.4.3",
|
|
@@ -154,21 +157,24 @@
|
|
|
154
157
|
"@eslint/js": "^9.29.0",
|
|
155
158
|
"@msgpack/msgpack": "^3.1.2",
|
|
156
159
|
"@stylistic/eslint-plugin": "^5.0.0",
|
|
160
|
+
"@types/chai": "^4.3.16",
|
|
161
|
+
"@types/mocha": "^10.0.10",
|
|
157
162
|
"@types/node": "^18.19.106",
|
|
158
|
-
"
|
|
163
|
+
"@types/sinon": "^17.0.4",
|
|
164
|
+
"@types/tap": "^15.0.12",
|
|
165
|
+
"axios": "^1.12.2",
|
|
159
166
|
"benchmark": "^2.1.4",
|
|
160
167
|
"body-parser": "^2.2.0",
|
|
161
168
|
"chai": "^4.5.0",
|
|
162
169
|
"eslint": "^9.29.0",
|
|
163
170
|
"eslint-plugin-cypress": "^5.1.0",
|
|
164
171
|
"eslint-plugin-import": "^2.32.0",
|
|
165
|
-
"eslint-plugin-mocha": "^
|
|
172
|
+
"eslint-plugin-mocha": "^11.1.0",
|
|
166
173
|
"eslint-plugin-n": "^17.20.0",
|
|
167
174
|
"eslint-plugin-promise": "^7.2.1",
|
|
168
|
-
"eslint-plugin-unicorn": "^
|
|
175
|
+
"eslint-plugin-unicorn": "^61.0.2",
|
|
169
176
|
"express": "^5.1.0",
|
|
170
|
-
"
|
|
171
|
-
"glob": "^7.2.3",
|
|
177
|
+
"glob": "^10.4.5",
|
|
172
178
|
"globals": "^16.3.0",
|
|
173
179
|
"graphql": "*",
|
|
174
180
|
"jszip": "^3.10.1",
|
|
@@ -178,12 +184,12 @@
|
|
|
178
184
|
"nyc": "^15.1.0",
|
|
179
185
|
"octokit": "^5.0.3",
|
|
180
186
|
"proxyquire": "^2.1.3",
|
|
181
|
-
"rimraf": "^3.0.2",
|
|
182
187
|
"semver": "^7.7.2",
|
|
183
|
-
"sinon": "^
|
|
188
|
+
"sinon": "^21.0.0",
|
|
184
189
|
"sinon-chai": "^3.7.0",
|
|
185
190
|
"tap": "^16.3.10",
|
|
186
191
|
"tiktoken": "^1.0.21",
|
|
192
|
+
"typescript": "^5.9.2",
|
|
187
193
|
"workerpool": "^9.2.0",
|
|
188
194
|
"yaml": "^2.8.0",
|
|
189
195
|
"yarn-deduplicate": "^6.0.2"
|