dd-trace 6.1.0 → 6.3.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/README.md +1 -1
- package/index.d.ts +7 -0
- package/initialize.mjs +4 -2
- package/package.json +5 -5
- package/packages/datadog-instrumentations/src/cookie.js +7 -1
- package/packages/datadog-instrumentations/src/helpers/hooks.js +3 -1
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +5 -1
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/index.js +1 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/mercurius.js +31 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/modelcontextprotocol-sdk.js +30 -54
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +19 -5
- package/packages/datadog-instrumentations/src/http/server.js +27 -0
- package/packages/datadog-instrumentations/src/mercurius.js +11 -0
- package/packages/datadog-instrumentations/src/modelcontextprotocol-sdk.js +248 -1
- package/packages/datadog-instrumentations/src/otel-sdk-trace.js +15 -0
- package/packages/datadog-instrumentations/src/playwright.js +40 -3
- package/packages/datadog-instrumentations/src/vitest-main.js +0 -2
- package/packages/datadog-instrumentations/src/vitest-util.js +0 -3
- package/packages/datadog-instrumentations/src/vitest-worker.js +0 -1
- package/packages/datadog-plugin-azure-functions/src/index.js +2 -1
- package/packages/datadog-plugin-graphql/src/execute.js +4 -15
- package/packages/datadog-plugin-graphql/src/index.js +6 -0
- package/packages/datadog-plugin-graphql/src/request.js +104 -0
- package/packages/datadog-plugin-graphql/src/utils.js +177 -0
- package/packages/datadog-plugin-graphql/src/validate.js +24 -1
- package/packages/datadog-plugin-modelcontextprotocol-sdk/src/tracing.js +144 -26
- package/packages/datadog-plugin-modelcontextprotocol-sdk/src/utils.js +30 -0
- package/packages/datadog-plugin-playwright/src/index.js +1 -1
- package/packages/datadog-plugin-vitest/src/index.js +0 -8
- package/packages/datadog-shimmer/src/shimmer.js +9 -2
- package/packages/dd-trace/src/appsec/channels.js +1 -0
- package/packages/dd-trace/src/appsec/index.js +6 -3
- package/packages/dd-trace/src/appsec/lambda.js +8 -8
- package/packages/dd-trace/src/appsec/waf/waf_manager.js +1 -1
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +23 -16
- package/packages/dd-trace/src/config/config-types.d.ts +8 -0
- package/packages/dd-trace/src/config/defaults.js +20 -15
- package/packages/dd-trace/src/config/index.js +13 -3
- package/packages/dd-trace/src/config/parsers.js +79 -0
- package/packages/dd-trace/src/datastreams/writer.js +14 -2
- package/packages/dd-trace/src/encode/0.4.js +23 -2
- package/packages/dd-trace/src/encode/0.5.js +12 -1
- package/packages/dd-trace/src/encode/agentless-ci-visibility.js +11 -1
- package/packages/dd-trace/src/encode/coverage-ci-visibility.js +20 -2
- package/packages/dd-trace/src/exporters/common/writer.js +17 -1
- package/packages/dd-trace/src/guardrails/index.js +3 -1
- package/packages/dd-trace/src/guardrails/telemetry.js +40 -3
- package/packages/dd-trace/src/llmobs/constants/tags.js +1 -0
- package/packages/dd-trace/src/llmobs/tagger.js +15 -1
- package/packages/dd-trace/src/msgpack/chunk.js +33 -1
- package/packages/dd-trace/src/msgpack/index.js +6 -1
- package/packages/dd-trace/src/opentelemetry/span_processor.js +7 -5
- package/packages/dd-trace/src/opentelemetry/tracer_provider.js +32 -16
- package/packages/dd-trace/src/plugins/index.js +3 -0
- package/packages/dd-trace/src/runtime_metrics/runtime_metrics.js +20 -11
- package/packages/dd-trace/src/service-naming/schemas/v0/graphql.js +6 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/graphql.js +8 -0
- package/vendor/dist/@apm-js-collab/code-transformer/index.js +5 -6
|
@@ -7,10 +7,16 @@ const os = require('os')
|
|
|
7
7
|
const process = require('process')
|
|
8
8
|
const { performance, PerformanceObserver, monitorEventLoopDelay } = require('perf_hooks')
|
|
9
9
|
const log = require('../log')
|
|
10
|
-
const { NODE_MAJOR } = require('../../../../version')
|
|
10
|
+
const { NODE_MAJOR, NODE_MINOR } = require('../../../../version')
|
|
11
11
|
const { createMetricsClient } = require('./client')
|
|
12
12
|
|
|
13
13
|
const eventLoopDelayResolution = 4
|
|
14
|
+
const EVENT_LOOP_SAMPLE_PER_ITERATION_AVAILABLE = NODE_MAJOR > 26 || (NODE_MAJOR === 26 && NODE_MINOR >= 5)
|
|
15
|
+
|
|
16
|
+
// @datadog/native-metrics is only needed on Node versions where
|
|
17
|
+
// monitorEventLoopDelay's samplePerIteration option is unavailable.
|
|
18
|
+
// TODO: remove @datadog/native-metrics and this branch once Node < 26.5 is no longer supported.
|
|
19
|
+
const NATIVE_METRICS_REQUIRED = !EVENT_LOOP_SAMPLE_PER_ITERATION_AVAILABLE
|
|
14
20
|
|
|
15
21
|
let nativeMetrics = null
|
|
16
22
|
let gcObserver = null
|
|
@@ -45,7 +51,10 @@ module.exports = {
|
|
|
45
51
|
startGCObserver()
|
|
46
52
|
}
|
|
47
53
|
|
|
48
|
-
|
|
54
|
+
// When per-iteration sampling is available we prefer it over the native
|
|
55
|
+
// addon: it provides accurate event loop delay measurements and lets us
|
|
56
|
+
// collect CPU/GC/heap metrics entirely from JS APIs.
|
|
57
|
+
const useNative = NATIVE_METRICS_REQUIRED && config.runtimeMetrics.native !== false
|
|
49
58
|
|
|
50
59
|
if (useNative) {
|
|
51
60
|
// Using no-gc prevents the native gc metrics from being tracked. Not
|
|
@@ -74,7 +83,10 @@ module.exports = {
|
|
|
74
83
|
lastCpuUsage = process.cpuUsage()
|
|
75
84
|
|
|
76
85
|
if (trackEventLoop) {
|
|
77
|
-
eventLoopDelayObserver = monitorEventLoopDelay({
|
|
86
|
+
eventLoopDelayObserver = monitorEventLoopDelay({
|
|
87
|
+
resolution: eventLoopDelayResolution,
|
|
88
|
+
samplePerIteration: EVENT_LOOP_SAMPLE_PER_ITERATION_AVAILABLE,
|
|
89
|
+
})
|
|
78
90
|
eventLoopDelayObserver.enable()
|
|
79
91
|
}
|
|
80
92
|
|
|
@@ -83,11 +95,6 @@ module.exports = {
|
|
|
83
95
|
captureCommonMetrics(trackEventLoop)
|
|
84
96
|
captureHeapSpace()
|
|
85
97
|
if (trackEventLoop) {
|
|
86
|
-
// Experimental: The Node.js implementation deviates from the native metrics.
|
|
87
|
-
// We normalize the metrics to the same format but the Node.js values
|
|
88
|
-
// are that way lower than they should be, while they are still nearer
|
|
89
|
-
// to the native ones that way.
|
|
90
|
-
// We use these only as fallback values.
|
|
91
98
|
captureEventLoopDelay()
|
|
92
99
|
}
|
|
93
100
|
client.flush()
|
|
@@ -195,12 +202,14 @@ function captureEventLoopDelay () {
|
|
|
195
202
|
eventLoopDelayObserver.disable()
|
|
196
203
|
|
|
197
204
|
if (eventLoopDelayObserver.count !== 0) {
|
|
198
|
-
|
|
205
|
+
// Node.js versions without iteration-based metrics use the default sampling method,
|
|
206
|
+
// which is interval-based and requires normalization because its values are much smaller
|
|
207
|
+
// than those from the original native implementation and iteration-based metrics.
|
|
208
|
+
const minimum = EVENT_LOOP_SAMPLE_PER_ITERATION_AVAILABLE ? 0 : eventLoopDelayResolution * 1e6
|
|
199
209
|
const avg = Math.max(eventLoopDelayObserver.mean - minimum, 0)
|
|
200
210
|
const sum = Math.round(avg * eventLoopDelayObserver.count)
|
|
201
211
|
|
|
202
212
|
if (sum !== 0) {
|
|
203
|
-
// Normalize the metrics to the same format as the native metrics.
|
|
204
213
|
const stats = {
|
|
205
214
|
min: Math.max(eventLoopDelayObserver.min - minimum, 0),
|
|
206
215
|
max: Math.max(eventLoopDelayObserver.max - minimum, 0),
|
|
@@ -214,7 +223,7 @@ function captureEventLoopDelay () {
|
|
|
214
223
|
histogram('runtime.node.event_loop.delay', stats)
|
|
215
224
|
}
|
|
216
225
|
}
|
|
217
|
-
eventLoopDelayObserver
|
|
226
|
+
eventLoopDelayObserver.reset()
|
|
218
227
|
eventLoopDelayObserver.enable()
|
|
219
228
|
}
|
|
220
229
|
|
|
@@ -8,6 +8,12 @@ const graphql = {
|
|
|
8
8
|
opName: () => 'graphql.execute',
|
|
9
9
|
serviceName: identityService,
|
|
10
10
|
},
|
|
11
|
+
// Top-level request span for drivers that funnel through a single entry
|
|
12
|
+
// point (mercurius). Matches the cross-tracer `graphql.request` v0 name.
|
|
13
|
+
request: {
|
|
14
|
+
opName: () => 'graphql.request',
|
|
15
|
+
serviceName: identityService,
|
|
16
|
+
},
|
|
11
17
|
},
|
|
12
18
|
}
|
|
13
19
|
|
|
@@ -8,6 +8,14 @@ const graphql = {
|
|
|
8
8
|
opName: () => 'graphql.server.request',
|
|
9
9
|
serviceName: identityService,
|
|
10
10
|
},
|
|
11
|
+
// Top-level request span for drivers that funnel through a single entry
|
|
12
|
+
// point (mercurius). Matches the cross-tracer `graphql.server.request` v1
|
|
13
|
+
// name. The v1 overlap with the execute span's name above is a known wart
|
|
14
|
+
// tracked for a separate cross-tracer unification (breaking) change.
|
|
15
|
+
request: {
|
|
16
|
+
opName: () => 'graphql.server.request',
|
|
17
|
+
serviceName: identityService,
|
|
18
|
+
},
|
|
11
19
|
},
|
|
12
20
|
}
|
|
13
21
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
const __apm$${T} = this["${T}"]
|
|
9
9
|
this["${T}"] = function () {}
|
|
10
10
|
if (typeof __apm$${T} === 'function') {
|
|
11
|
-
Object.defineProperty(this["${T}"], 'length', {
|
|
11
|
+
Object.defineProperty(this["${T}"], 'length', {
|
|
12
12
|
value: __apm$${T}.length,
|
|
13
13
|
configurable: true
|
|
14
14
|
})
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
if (typeof promise?.then !== 'function') {
|
|
95
95
|
__apm$ctx.result = promise;
|
|
96
96
|
${k}
|
|
97
|
-
return
|
|
97
|
+
return __apm$ctx.result;
|
|
98
98
|
}
|
|
99
99
|
// Mirror Node.js core diagnostics_channel behaviour: for native Promise
|
|
100
100
|
// instances, chain normally (safe since there is no subclass API to
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
${k}
|
|
110
110
|
${w}.asyncStart.publish(__apm$ctx);
|
|
111
111
|
${w}.asyncEnd.publish(__apm$ctx);
|
|
112
|
-
return result;
|
|
112
|
+
return __apm$ctx.result;
|
|
113
113
|
},
|
|
114
114
|
err => {
|
|
115
115
|
__apm$ctx.error = err;
|
|
@@ -151,10 +151,8 @@
|
|
|
151
151
|
|
|
152
152
|
return ${w}.start.runStores(__apm$ctx, () => {
|
|
153
153
|
try {
|
|
154
|
-
|
|
155
|
-
__apm$ctx.result = result;
|
|
154
|
+
__apm$ctx.result = __apm$traced();
|
|
156
155
|
${k}
|
|
157
|
-
return result;
|
|
158
156
|
} catch (err) {
|
|
159
157
|
__apm$ctx.error = err;
|
|
160
158
|
${w}.error.publish(__apm$ctx);
|
|
@@ -163,6 +161,7 @@
|
|
|
163
161
|
__apm$ctx.self ??= this;
|
|
164
162
|
${w}.end.publish(__apm$ctx);
|
|
165
163
|
}
|
|
164
|
+
return __apm$ctx.result;
|
|
166
165
|
});
|
|
167
166
|
}
|
|
168
167
|
`)}function declareIteratorChannel(i,s){let{channelName:k,module:{name:S}}=i,w=formatChannelVariable(k+":next");if(s.body.some(i=>i.declarations?.[0]?.id?.name===w))return;let C=formatChannelVariable(k),T=s.body.findIndex(i=>i.declarations?.[0]?.id?.name===C),_=`const ${w} = tr_ch_apm_tracingChannel("orchestrion:${S}:${k}:next")`;s.body.splice(T+1,0,E(_).body[0])}function generateIterPatch(i,s,k){let{channelName:S}=i,E=formatChannelVariable(S+":next");return declareIteratorChannel(i,k),`
|