dd-trace 5.94.0 → 5.96.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 +46 -44
- package/index.d.ts +191 -13
- package/package.json +2 -2
- package/packages/datadog-instrumentations/src/ai.js +112 -0
- package/packages/datadog-instrumentations/src/anthropic.js +1 -1
- package/packages/datadog-instrumentations/src/helpers/ai-messages.js +182 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/{orchestrion/compiler.js → compiler.js} +4 -13
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +16 -2
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/ai.js +25 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/langgraph.js +2 -2
- package/packages/datadog-instrumentations/src/helpers/rewriter/{orchestrion/transforms.js → transforms.js} +3 -89
- package/packages/datadog-instrumentations/src/mocha/utils.js +10 -0
- package/packages/datadog-plugin-dd-trace-api/src/index.js +1 -4
- package/packages/dd-trace/src/aiguard/index.js +64 -0
- package/packages/dd-trace/src/azure_metadata.js +15 -15
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +73 -1
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +76 -1
- package/packages/dd-trace/src/ci-visibility/lage.js +39 -0
- package/packages/dd-trace/src/ci-visibility/requests/fs-cache.js +259 -0
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +56 -0
- package/packages/dd-trace/src/config/config-base.d.ts +7 -0
- package/packages/dd-trace/src/config/config-base.js +5 -0
- package/packages/dd-trace/src/config/config-types.d.ts +78 -0
- package/packages/dd-trace/src/config/generated-config-types.d.ts +582 -0
- package/packages/dd-trace/src/config/index.js +5 -2
- package/packages/dd-trace/src/config/supported-configurations.json +24 -0
- package/packages/dd-trace/src/constants.js +1 -0
- package/packages/dd-trace/src/exporter.js +5 -2
- package/packages/dd-trace/src/llmobs/constants/tags.js +1 -0
- package/packages/dd-trace/src/llmobs/constants/text.js +4 -1
- package/packages/dd-trace/src/llmobs/constants/writers.js +1 -1
- package/packages/dd-trace/src/llmobs/index.js +9 -4
- package/packages/dd-trace/src/llmobs/plugins/anthropic.js +11 -2
- package/packages/dd-trace/src/llmobs/plugins/openai/index.js +4 -1
- package/packages/dd-trace/src/llmobs/writers/spans.js +1 -1
- package/packages/dd-trace/src/plugins/util/test.js +5 -0
- package/packages/dd-trace/src/priority_sampler.js +1 -1
- package/packages/dd-trace/src/proxy.js +4 -0
- package/packages/dd-trace/src/rate_limiter.js +2 -1
- package/packages/dd-trace/src/startup-log.js +9 -0
- package/packages/dd-trace/src/tagger.js +31 -35
- package/vendor/dist/@apm-js-collab/code-transformer/LICENSE +28 -0
- package/vendor/dist/@apm-js-collab/code-transformer/index.js +133 -0
- package/vendor/dist/@opentelemetry/core/index.js +1 -1
- package/vendor/dist/@opentelemetry/resources/index.js +1 -1
- package/vendor/dist/esquery/index.js +1 -1
- package/vendor/dist/meriyah/index.js +1 -1
- package/packages/datadog-instrumentations/src/helpers/rewriter/orchestrion/index.js +0 -43
- package/packages/datadog-instrumentations/src/helpers/rewriter/orchestrion/matcher.js +0 -49
- package/packages/datadog-instrumentations/src/helpers/rewriter/orchestrion/transformer.js +0 -121
- package/vendor/dist/astring/LICENSE +0 -19
- package/vendor/dist/astring/index.js +0 -1
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
module.exports = {
|
|
4
|
-
DROPPED_VALUE_TEXT: "[This value has been dropped because this span's size exceeds the
|
|
4
|
+
DROPPED_VALUE_TEXT: "[This value has been dropped because this span's size exceeds the 5MB size limit.]",
|
|
5
5
|
UNSERIALIZABLE_VALUE_TEXT: 'Unserializable value',
|
|
6
|
+
INCOMPATIBLE_INITIALIZATION:
|
|
7
|
+
'Cannot send LLM Observability data without a running agent or without both a Datadog API key and site. ' +
|
|
8
|
+
'Ensure these configurations are set before running your application.',
|
|
6
9
|
}
|
|
@@ -13,5 +13,5 @@ module.exports = {
|
|
|
13
13
|
EVALUATIONS_ENDPOINT: '/api/intake/llm-obs/v2/eval-metric',
|
|
14
14
|
|
|
15
15
|
EVP_PAYLOAD_SIZE_LIMIT: 5 << 20, // 5MB (actual limit is 5.1MB)
|
|
16
|
-
EVP_EVENT_SIZE_LIMIT:
|
|
16
|
+
EVP_EVENT_SIZE_LIMIT: 5 << 20, // 5MB (actual backend limit is 10MB; Python SDK defaults to 5MB)
|
|
17
17
|
}
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
const { channel } = require('dc-polyfill')
|
|
4
4
|
|
|
5
5
|
const log = require('../log')
|
|
6
|
+
const { DD_MAJOR } = require('../../../../version')
|
|
7
|
+
const startupLogs = require('../startup-log')
|
|
6
8
|
const {
|
|
7
9
|
ML_APP,
|
|
8
10
|
PROPAGATED_ML_APP_KEY,
|
|
@@ -15,6 +17,7 @@ const LLMObsEvalMetricsWriter = require('./writers/evaluations')
|
|
|
15
17
|
const LLMObsTagger = require('./tagger')
|
|
16
18
|
const LLMObsSpanWriter = require('./writers/spans')
|
|
17
19
|
const { setAgentStrategy } = require('./writers/util')
|
|
20
|
+
const { INCOMPATIBLE_INITIALIZATION } = require('./constants/text')
|
|
18
21
|
|
|
19
22
|
const spanFinishCh = channel('dd-trace:span:finish')
|
|
20
23
|
const evalMetricAppendCh = channel('llmobs:eval-metric:append')
|
|
@@ -66,10 +69,12 @@ function enable (config) {
|
|
|
66
69
|
|
|
67
70
|
setAgentStrategy(config, useAgentless => {
|
|
68
71
|
if (useAgentless && !(config.apiKey && config.site)) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
if (DD_MAJOR < 6 || !config?.startupLogs) {
|
|
73
|
+
// eslint-disable-next-line no-console
|
|
74
|
+
console.error(INCOMPATIBLE_INITIALIZATION)
|
|
75
|
+
} else {
|
|
76
|
+
startupLogs.logGenericError(INCOMPATIBLE_INITIALIZATION)
|
|
77
|
+
}
|
|
73
78
|
}
|
|
74
79
|
|
|
75
80
|
evalWriter?.setAgentless(useAgentless)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const { UNKNOWN_MODEL_PROVIDER } = require('../constants/tags')
|
|
3
4
|
const LLMObsPlugin = require('./base')
|
|
4
5
|
|
|
5
6
|
const ALLOWED_METADATA_KEYS = new Set([
|
|
@@ -108,16 +109,24 @@ class AnthropicLLMObsPlugin extends LLMObsPlugin {
|
|
|
108
109
|
}
|
|
109
110
|
|
|
110
111
|
getLLMObsSpanRegisterOptions (ctx) {
|
|
111
|
-
const { options } = ctx
|
|
112
|
+
const { options, baseUrl } = ctx
|
|
112
113
|
const { model } = options
|
|
114
|
+
const modelProvider = this._getModelProvider(baseUrl)
|
|
113
115
|
|
|
114
116
|
return {
|
|
115
117
|
kind: 'llm',
|
|
116
118
|
modelName: model,
|
|
117
|
-
modelProvider
|
|
119
|
+
modelProvider,
|
|
118
120
|
}
|
|
119
121
|
}
|
|
120
122
|
|
|
123
|
+
_getModelProvider (baseUrl = '') {
|
|
124
|
+
if (baseUrl.includes('anthropic')) {
|
|
125
|
+
return 'anthropic'
|
|
126
|
+
}
|
|
127
|
+
return UNKNOWN_MODEL_PROVIDER
|
|
128
|
+
}
|
|
129
|
+
|
|
121
130
|
setLLMObsTags (ctx) {
|
|
122
131
|
const span = ctx.currentStore?.span
|
|
123
132
|
if (!span) return
|
|
@@ -5,6 +5,7 @@ const {
|
|
|
5
5
|
PROMPT_TRACKING_INSTRUMENTATION_METHOD,
|
|
6
6
|
PROMPT_MULTIMODAL,
|
|
7
7
|
INSTRUMENTATION_METHOD_AUTO,
|
|
8
|
+
UNKNOWN_MODEL_PROVIDER,
|
|
8
9
|
} = require('../../constants/tags')
|
|
9
10
|
const {
|
|
10
11
|
extractChatTemplateFromInstructions,
|
|
@@ -90,10 +91,12 @@ class OpenAiLLMObsPlugin extends LLMObsPlugin {
|
|
|
90
91
|
_getModelProviderAndClient (baseUrl = '') {
|
|
91
92
|
if (baseUrl.includes('azure')) {
|
|
92
93
|
return { modelProvider: 'azure_openai', client: 'AzureOpenAI' }
|
|
94
|
+
} else if (baseUrl.includes('openai')) {
|
|
95
|
+
return { modelProvider: 'openai', client: 'OpenAI' }
|
|
93
96
|
} else if (baseUrl.includes('deepseek')) {
|
|
94
97
|
return { modelProvider: 'deepseek', client: 'DeepSeek' }
|
|
95
98
|
}
|
|
96
|
-
return { modelProvider:
|
|
99
|
+
return { modelProvider: UNKNOWN_MODEL_PROVIDER, client: 'OpenAI' }
|
|
97
100
|
}
|
|
98
101
|
|
|
99
102
|
_extractMetrics (response) {
|
|
@@ -32,7 +32,7 @@ class LLMObsSpanWriter extends BaseWriter {
|
|
|
32
32
|
let processedEventSizeBytes = eventSizeBytes
|
|
33
33
|
|
|
34
34
|
if (shouldTruncate) {
|
|
35
|
-
logger.warn(`Dropping event input/output because its size (${eventSizeBytes}) exceeds the
|
|
35
|
+
logger.warn(`Dropping event input/output because its size (${eventSizeBytes}) exceeds the 5MB event size limit`)
|
|
36
36
|
event = this._truncateSpanEvent(event)
|
|
37
37
|
processedEventSizeBytes = Buffer.byteLength(JSON.stringify(event))
|
|
38
38
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const path = require('path')
|
|
4
4
|
const fs = require('fs')
|
|
5
5
|
const { URL } = require('url')
|
|
6
|
+
const { getLageTestSessionName } = require('../../ci-visibility/lage')
|
|
6
7
|
const log = require('../../log')
|
|
7
8
|
const { getEnvironmentVariable } = require('../../config/helper')
|
|
8
9
|
const satisfies = require('../../../../../vendor/dist/semifies')
|
|
@@ -934,6 +935,10 @@ function getTestSessionName (config, trimmedCommand, envTags) {
|
|
|
934
935
|
if (config.ciVisibilityTestSessionName) {
|
|
935
936
|
return config.ciVisibilityTestSessionName
|
|
936
937
|
}
|
|
938
|
+
const lageTestSessionName = getLageTestSessionName()
|
|
939
|
+
if (lageTestSessionName) {
|
|
940
|
+
return lageTestSessionName
|
|
941
|
+
}
|
|
937
942
|
if (envTags[CI_JOB_NAME]) {
|
|
938
943
|
return `${envTags[CI_JOB_NAME]}-${trimmedCommand}`
|
|
939
944
|
}
|
|
@@ -249,7 +249,7 @@ class PrioritySampler {
|
|
|
249
249
|
}
|
|
250
250
|
const rawPriority = tags[SAMPLING_PRIORITY]
|
|
251
251
|
if (rawPriority !== undefined) {
|
|
252
|
-
const priority =
|
|
252
|
+
const priority = Math.trunc(rawPriority)
|
|
253
253
|
|
|
254
254
|
if (priority === 1 || priority === 2) {
|
|
255
255
|
return USER_KEEP
|
|
@@ -85,6 +85,7 @@ class Tracer extends NoopProxy {
|
|
|
85
85
|
// these requires must work with esm bundler
|
|
86
86
|
this._modules = {
|
|
87
87
|
appsec: new LazyModule(() => require('./appsec')),
|
|
88
|
+
aiguard: new LazyModule(() => require('./aiguard')),
|
|
88
89
|
iast: new LazyModule(() => require('./appsec/iast')),
|
|
89
90
|
llmobs: new LazyModule(() => require('./llmobs')),
|
|
90
91
|
rewriter: new LazyModule(() => require('./appsec/iast/taint-tracking/rewriter')),
|
|
@@ -272,7 +273,9 @@ class Tracer extends NoopProxy {
|
|
|
272
273
|
this.dataStreamsCheckpointer = this._tracer.dataStreamsCheckpointer
|
|
273
274
|
lazyProxy(this, 'appsec', () => require('./appsec/sdk'), this._tracer, config)
|
|
274
275
|
lazyProxy(this, 'llmobs', () => require('./llmobs/sdk'), this._tracer, this._modules.llmobs, config)
|
|
276
|
+
|
|
275
277
|
if (config.experimental?.aiguard?.enabled) {
|
|
278
|
+
this._modules.aiguard.enable(this._tracer, config)
|
|
276
279
|
lazyProxy(this, 'aiguard', () => require('./aiguard/sdk'), this._tracer, config)
|
|
277
280
|
}
|
|
278
281
|
this._tracingInitialized = true
|
|
@@ -287,6 +290,7 @@ class Tracer extends NoopProxy {
|
|
|
287
290
|
// This needs to be after the IAST module is enabled
|
|
288
291
|
} else if (this._tracingInitialized) {
|
|
289
292
|
this._modules.appsec.disable()
|
|
293
|
+
this._modules.aiguard.disable()
|
|
290
294
|
this._modules.iast.disable()
|
|
291
295
|
this._modules.llmobs.disable()
|
|
292
296
|
this._modules.openfeature.disable()
|
|
@@ -8,7 +8,8 @@ class RateLimiter {
|
|
|
8
8
|
* @param {'second'|'minute'|'hour'|'day'} [interval='second'] - Time window for the limiter.
|
|
9
9
|
*/
|
|
10
10
|
constructor (rateLimit, interval = 'second') {
|
|
11
|
-
|
|
11
|
+
// TODO: Change rateLimit to integers. Right now these are sometimes strings, sometimes numbers.
|
|
12
|
+
this._rateLimit = Math.trunc(rateLimit)
|
|
12
13
|
// The limiter constructor accepts a token count number and an interval string
|
|
13
14
|
this._limiter = new limiter.RateLimiter(this._rateLimit, interval)
|
|
14
15
|
this._tokensRequested = 0
|
|
@@ -63,6 +63,14 @@ function logAgentError (agentError) {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
function logGenericError (message) {
|
|
67
|
+
if (!config?.startupLogs) {
|
|
68
|
+
return
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
warn('DATADOG TRACER DIAGNOSTIC - Generic Error: ' + message)
|
|
72
|
+
}
|
|
73
|
+
|
|
66
74
|
/**
|
|
67
75
|
* Returns config info without integrations (used by startupLog).
|
|
68
76
|
* @returns {Record<string, unknown>}
|
|
@@ -143,4 +151,5 @@ module.exports = {
|
|
|
143
151
|
setSamplingRules,
|
|
144
152
|
tracerInfo,
|
|
145
153
|
errors,
|
|
154
|
+
logGenericError,
|
|
146
155
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// TODO: Rename and move file. This is a general purpose helper for adding tags to a carrier.
|
|
4
4
|
|
|
5
5
|
function addNonEmpty (carrier, key, value) {
|
|
6
6
|
if (key !== '') {
|
|
@@ -11,47 +11,43 @@ function addNonEmpty (carrier, key, value) {
|
|
|
11
11
|
function add (carrier, keyValuePairs) {
|
|
12
12
|
if (!carrier) return
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
let keyStart = 0
|
|
18
|
-
|
|
19
|
-
for (let i = 0; i < keyValuePairs.length; i++) {
|
|
20
|
-
const char = keyValuePairs[i]
|
|
21
|
-
|
|
22
|
-
if (char === ':') {
|
|
23
|
-
if (valueStart === 0) {
|
|
24
|
-
valueStart = i
|
|
25
|
-
}
|
|
26
|
-
} else if (char === ',') {
|
|
27
|
-
valueStart ||= i
|
|
28
|
-
addNonEmpty(
|
|
29
|
-
carrier,
|
|
30
|
-
keyValuePairs.slice(keyStart, valueStart).trim(),
|
|
31
|
-
keyValuePairs.slice(valueStart + 1, i).trim()
|
|
32
|
-
)
|
|
33
|
-
keyStart = i + 1
|
|
34
|
-
valueStart = 0
|
|
35
|
-
}
|
|
36
|
-
}
|
|
14
|
+
if (typeof keyValuePairs === 'string') {
|
|
15
|
+
let valueStart = 0
|
|
16
|
+
let keyStart = 0
|
|
37
17
|
|
|
38
|
-
|
|
39
|
-
|
|
18
|
+
for (let i = 0; i < keyValuePairs.length; i++) {
|
|
19
|
+
const char = keyValuePairs[i]
|
|
20
|
+
|
|
21
|
+
if (char === ':') {
|
|
22
|
+
if (valueStart === 0) {
|
|
23
|
+
valueStart = i
|
|
24
|
+
}
|
|
25
|
+
} else if (char === ',') {
|
|
26
|
+
valueStart ||= i
|
|
40
27
|
addNonEmpty(
|
|
41
28
|
carrier,
|
|
42
29
|
keyValuePairs.slice(keyStart, valueStart).trim(),
|
|
43
|
-
keyValuePairs.slice(valueStart + 1).trim()
|
|
30
|
+
keyValuePairs.slice(valueStart + 1, i).trim()
|
|
44
31
|
)
|
|
32
|
+
keyStart = i + 1
|
|
33
|
+
valueStart = 0
|
|
45
34
|
}
|
|
46
|
-
} else if (Array.isArray(keyValuePairs)) {
|
|
47
|
-
for (const tags of keyValuePairs) {
|
|
48
|
-
add(carrier, tags)
|
|
49
|
-
}
|
|
50
|
-
} else {
|
|
51
|
-
Object.assign(carrier, keyValuePairs)
|
|
52
35
|
}
|
|
53
|
-
|
|
54
|
-
|
|
36
|
+
|
|
37
|
+
if (keyValuePairs.at(-1) !== ',') {
|
|
38
|
+
valueStart ||= keyValuePairs.length
|
|
39
|
+
addNonEmpty(
|
|
40
|
+
carrier,
|
|
41
|
+
keyValuePairs.slice(keyStart, valueStart).trim(),
|
|
42
|
+
keyValuePairs.slice(valueStart + 1).trim()
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
} else if (Array.isArray(keyValuePairs)) {
|
|
46
|
+
for (const tags of keyValuePairs) {
|
|
47
|
+
add(carrier, tags)
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
Object.assign(carrier, keyValuePairs)
|
|
55
51
|
}
|
|
56
52
|
}
|
|
57
53
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
|
|
2
|
+
Copyright (c) 2009-2011, Mozilla Foundation and contributors
|
|
3
|
+
All rights reserved.
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
* Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
* Neither the names of the Mozilla Foundation nor the names of project
|
|
16
|
+
contributors may be used to endorse or promote products derived from this
|
|
17
|
+
software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
20
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
21
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|