dd-trace 5.79.0 → 5.81.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 +79 -87
- package/ext/tags.d.ts +1 -0
- package/ext/tags.js +1 -0
- package/index.d.ts +46 -39
- package/initialize.mjs +10 -10
- package/loader-hook.mjs +10 -3
- package/package.json +23 -40
- package/packages/datadog-core/src/storage.js +4 -4
- package/packages/datadog-esbuild/index.js +36 -19
- package/packages/datadog-esbuild/src/utils.js +5 -1
- package/packages/datadog-instrumentations/index.js +1 -0
- package/packages/datadog-instrumentations/src/anthropic.js +12 -0
- package/packages/datadog-instrumentations/src/aws-sdk.js +13 -2
- package/packages/datadog-instrumentations/src/azure-service-bus.js +43 -36
- package/packages/datadog-instrumentations/src/cucumber.js +2 -2
- package/packages/datadog-instrumentations/src/find-my-way.js +6 -5
- package/packages/datadog-instrumentations/src/google-genai.js +120 -0
- package/packages/datadog-instrumentations/src/graphql.js +20 -0
- package/packages/datadog-instrumentations/src/helpers/hook.js +1 -0
- package/packages/datadog-instrumentations/src/helpers/hooks.js +1 -0
- package/packages/datadog-instrumentations/src/helpers/instrument.js +12 -1
- package/packages/datadog-instrumentations/src/helpers/register.js +6 -1
- package/packages/datadog-instrumentations/src/helpers/rewriter/compiler.js +27 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +152 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/index.js +5 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/langchain.js +237 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/loader.js +9 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/loader.mjs +11 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +139 -0
- package/packages/datadog-instrumentations/src/jest.js +1 -1
- package/packages/datadog-instrumentations/src/langchain.js +3 -109
- package/packages/datadog-instrumentations/src/mocha/main.js +1 -1
- package/packages/datadog-instrumentations/src/mysql2.js +1 -1
- package/packages/datadog-instrumentations/src/playwright.js +65 -16
- package/packages/datadog-instrumentations/src/router.js +1 -1
- package/packages/datadog-instrumentations/src/selenium.js +3 -1
- package/packages/datadog-instrumentations/src/ws.js +35 -17
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/utils.js +3 -2
- package/packages/datadog-plugin-azure-service-bus/src/producer.js +14 -5
- package/packages/datadog-plugin-child_process/src/scrub-cmd-params.js +1 -1
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +23 -2
- package/packages/datadog-plugin-cypress/src/plugin.js +1 -1
- package/packages/datadog-plugin-cypress/src/support.js +73 -31
- package/packages/datadog-plugin-google-genai/src/index.js +17 -0
- package/packages/datadog-plugin-google-genai/src/tracing.js +41 -0
- package/packages/datadog-plugin-graphql/src/tools/transforms.js +5 -4
- package/packages/datadog-plugin-jest/src/util.js +4 -3
- package/packages/datadog-plugin-kafkajs/src/consumer.js +2 -1
- package/packages/datadog-plugin-kafkajs/src/producer.js +3 -1
- package/packages/datadog-plugin-langchain/src/tracing.js +7 -3
- package/packages/datadog-plugin-next/src/index.js +11 -3
- package/packages/datadog-plugin-openai/src/stream-helpers.js +1 -1
- package/packages/datadog-shimmer/src/shimmer.js +2 -2
- package/packages/dd-trace/src/aiguard/sdk.js +29 -14
- package/packages/dd-trace/src/appsec/api_security_sampler.js +1 -1
- package/packages/dd-trace/src/appsec/iast/overhead-controller.js +1 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter-esm.mjs +1 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +1 -2
- package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +1 -1
- package/packages/dd-trace/src/appsec/reporter.js +0 -4
- package/packages/dd-trace/src/baggage.js +11 -0
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +4 -8
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +1 -1
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +4 -2
- package/packages/dd-trace/src/config.js +81 -7
- package/packages/dd-trace/src/config_defaults.js +15 -2
- package/packages/dd-trace/src/datastreams/encoding.js +23 -6
- package/packages/dd-trace/src/datastreams/pathway.js +40 -1
- package/packages/dd-trace/src/datastreams/processor.js +1 -1
- package/packages/dd-trace/src/datastreams/schemas/schema_builder.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +15 -5
- package/packages/dd-trace/src/debugger/devtools_client/condition.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/config.js +2 -0
- package/packages/dd-trace/src/debugger/devtools_client/index.js +30 -15
- package/packages/dd-trace/src/debugger/devtools_client/inspector_promises_polyfill.js +2 -0
- package/packages/dd-trace/src/debugger/devtools_client/json-buffer.js +24 -18
- package/packages/dd-trace/src/debugger/devtools_client/send.js +18 -8
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/collector.js +103 -15
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/constants.js +25 -0
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/index.js +56 -25
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/processor.js +64 -23
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/symbols.js +3 -1
- package/packages/dd-trace/src/debugger/devtools_client/snapshot-pruner.js +404 -0
- package/packages/dd-trace/src/debugger/devtools_client/source-maps.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/state.js +7 -2
- 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/encode/0.4.js +3 -3
- package/packages/dd-trace/src/encode/coverage-ci-visibility.js +2 -2
- package/packages/dd-trace/src/encode/span-stats.js +7 -1
- package/packages/dd-trace/src/exporters/agent/writer.js +6 -13
- package/packages/dd-trace/src/histogram.js +1 -1
- package/packages/dd-trace/src/id.js +60 -0
- package/packages/dd-trace/src/lambda/runtime/ritm.js +2 -3
- package/packages/dd-trace/src/llmobs/constants/tags.js +1 -0
- package/packages/dd-trace/src/llmobs/index.js +5 -5
- package/packages/dd-trace/src/llmobs/noop.js +6 -0
- package/packages/dd-trace/src/llmobs/plugins/ai/index.js +1 -0
- package/packages/dd-trace/src/llmobs/plugins/genai/index.js +104 -0
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +486 -0
- package/packages/dd-trace/src/llmobs/plugins/langchain/index.js +2 -2
- package/packages/dd-trace/src/llmobs/plugins/{openai.js → openai/index.js} +87 -39
- package/packages/dd-trace/src/llmobs/plugins/openai/utils.js +114 -0
- package/packages/dd-trace/src/llmobs/sdk.js +10 -1
- package/packages/dd-trace/src/llmobs/span_processor.js +11 -6
- package/packages/dd-trace/src/llmobs/tagger.js +35 -17
- package/packages/dd-trace/src/msgpack/chunk.js +2 -2
- package/packages/dd-trace/src/msgpack/encoder.js +2 -3
- package/packages/dd-trace/src/msgpack/index.js +2 -2
- package/packages/dd-trace/src/openfeature/flagging_provider.js +5 -3
- package/packages/dd-trace/src/opentelemetry/logs/index.js +3 -3
- package/packages/dd-trace/src/opentelemetry/logs/logger.js +14 -8
- package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +6 -4
- package/packages/dd-trace/src/opentelemetry/logs/otlp_transformer.js +9 -17
- package/packages/dd-trace/src/opentelemetry/metrics/constants.js +34 -0
- package/packages/dd-trace/src/opentelemetry/metrics/index.js +81 -0
- package/packages/dd-trace/src/opentelemetry/metrics/instruments.js +225 -0
- package/packages/dd-trace/src/opentelemetry/metrics/meter.js +171 -0
- package/packages/dd-trace/src/opentelemetry/metrics/meter_provider.js +54 -0
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +62 -0
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_transformer.js +251 -0
- package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +532 -0
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +10 -18
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_transformer_base.js +36 -22
- package/packages/dd-trace/src/opentelemetry/otlp/protobuf_loader.js +2 -2
- package/packages/dd-trace/src/opentelemetry/span.js +1 -1
- package/packages/dd-trace/src/opentelemetry/tracer.js +1 -1
- package/packages/dd-trace/src/opentelemetry/tracer_provider.js +1 -1
- package/packages/dd-trace/src/payload-tagging/index.js +2 -2
- package/packages/dd-trace/src/plugin_manager.js +4 -2
- package/packages/dd-trace/src/plugins/database.js +1 -0
- package/packages/dd-trace/src/plugins/index.js +1 -0
- package/packages/dd-trace/src/plugins/plugin.js +7 -9
- package/packages/dd-trace/src/plugins/util/test.js +3 -3
- package/packages/dd-trace/src/plugins/util/url.js +119 -1
- package/packages/dd-trace/src/plugins/util/web.js +10 -41
- package/packages/dd-trace/src/process-tags/index.js +81 -0
- package/packages/dd-trace/src/profiling/config.js +1 -1
- package/packages/dd-trace/src/profiling/exporter_cli.js +7 -6
- package/packages/dd-trace/src/profiling/exporters/agent.js +1 -1
- package/packages/dd-trace/src/profiling/profilers/events.js +10 -1
- package/packages/dd-trace/src/proxy.js +5 -0
- package/packages/dd-trace/src/rate_limiter.js +1 -1
- package/packages/dd-trace/src/remote_config/manager.js +1 -1
- package/packages/dd-trace/src/require-package-json.js +1 -1
- package/packages/dd-trace/src/ritm.js +1 -1
- package/packages/dd-trace/src/service-naming/index.js +31 -4
- package/packages/dd-trace/src/service-naming/schemas/v0/web.js +4 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/web.js +4 -0
- package/packages/dd-trace/src/{format.js → span_format.js} +9 -4
- package/packages/dd-trace/src/span_processor.js +16 -11
- package/packages/dd-trace/src/span_stats.js +15 -4
- package/packages/dd-trace/src/spanleak.js +1 -1
- package/packages/dd-trace/src/supported-configurations.json +13 -0
- package/packages/dd-trace/src/telemetry/dependencies.js +1 -1
- package/packages/dd-trace/src/telemetry/telemetry.js +11 -2
- package/vendor/dist/@datadog/sketches-js/LICENSE +39 -0
- package/vendor/dist/@datadog/sketches-js/index.js +1 -0
- package/vendor/dist/@datadog/source-map/LICENSE +28 -0
- package/vendor/dist/@datadog/source-map/index.js +1 -0
- package/vendor/dist/@isaacs/ttlcache/LICENSE +55 -0
- package/vendor/dist/@isaacs/ttlcache/index.js +1 -0
- package/vendor/dist/@opentelemetry/core/LICENSE +201 -0
- package/vendor/dist/@opentelemetry/core/index.js +1 -0
- package/vendor/dist/@opentelemetry/resources/LICENSE +201 -0
- package/vendor/dist/@opentelemetry/resources/index.js +1 -0
- package/vendor/dist/astring/LICENSE +19 -0
- package/vendor/dist/astring/index.js +1 -0
- package/vendor/dist/crypto-randomuuid/index.js +1 -0
- package/vendor/dist/escape-string-regexp/LICENSE +9 -0
- package/vendor/dist/escape-string-regexp/index.js +1 -0
- package/vendor/dist/esquery/LICENSE +24 -0
- package/vendor/dist/esquery/index.js +1 -0
- package/vendor/dist/ignore/LICENSE +21 -0
- package/vendor/dist/ignore/index.js +1 -0
- package/vendor/dist/istanbul-lib-coverage/LICENSE +24 -0
- package/vendor/dist/istanbul-lib-coverage/index.js +1 -0
- package/vendor/dist/jest-docblock/LICENSE +21 -0
- package/vendor/dist/jest-docblock/index.js +1 -0
- package/vendor/dist/jsonpath-plus/LICENSE +22 -0
- package/vendor/dist/jsonpath-plus/index.js +1 -0
- package/vendor/dist/limiter/LICENSE +19 -0
- package/vendor/dist/limiter/index.js +1 -0
- package/vendor/dist/lodash.sortby/LICENSE +47 -0
- package/vendor/dist/lodash.sortby/index.js +1 -0
- package/vendor/dist/lru-cache/LICENSE +15 -0
- package/vendor/dist/lru-cache/index.js +1 -0
- package/vendor/dist/meriyah/LICENSE +7 -0
- package/vendor/dist/meriyah/index.js +1 -0
- package/vendor/dist/module-details-from-path/LICENSE +21 -0
- package/vendor/dist/module-details-from-path/index.js +1 -0
- package/vendor/dist/mutexify/promise/LICENSE +21 -0
- package/vendor/dist/mutexify/promise/index.js +1 -0
- package/vendor/dist/opentracing/LICENSE +201 -0
- package/vendor/dist/opentracing/binary_carrier.d.ts +11 -0
- package/vendor/dist/opentracing/constants.d.ts +61 -0
- package/vendor/dist/opentracing/examples/demo/demo.d.ts +2 -0
- package/vendor/dist/opentracing/ext/tags.d.ts +90 -0
- package/vendor/dist/opentracing/functions.d.ts +20 -0
- package/vendor/dist/opentracing/global_tracer.d.ts +14 -0
- package/vendor/dist/opentracing/index.d.ts +12 -0
- package/vendor/dist/opentracing/index.js +1 -0
- package/vendor/dist/opentracing/mock_tracer/index.d.ts +5 -0
- package/vendor/dist/opentracing/mock_tracer/mock_context.d.ts +13 -0
- package/vendor/dist/opentracing/mock_tracer/mock_report.d.ts +16 -0
- package/vendor/dist/opentracing/mock_tracer/mock_span.d.ts +50 -0
- package/vendor/dist/opentracing/mock_tracer/mock_tracer.d.ts +26 -0
- package/vendor/dist/opentracing/noop.d.ts +8 -0
- package/vendor/dist/opentracing/reference.d.ts +33 -0
- package/vendor/dist/opentracing/span.d.ts +147 -0
- package/vendor/dist/opentracing/span_context.d.ts +26 -0
- package/vendor/dist/opentracing/test/api_compatibility.d.ts +16 -0
- package/vendor/dist/opentracing/test/mocktracer_implemenation.d.ts +3 -0
- package/vendor/dist/opentracing/test/noop_implementation.d.ts +4 -0
- package/vendor/dist/opentracing/test/opentracing_api.d.ts +3 -0
- package/vendor/dist/opentracing/test/unittest.d.ts +2 -0
- package/vendor/dist/opentracing/tracer.d.ts +127 -0
- package/vendor/dist/path-to-regexp/LICENSE +21 -0
- package/vendor/dist/path-to-regexp/index.js +1 -0
- package/vendor/dist/pprof-format/LICENSE +8 -0
- package/vendor/dist/pprof-format/index.js +1 -0
- package/vendor/dist/protobufjs/LICENSE +39 -0
- package/vendor/dist/protobufjs/index.js +1 -0
- package/vendor/dist/protobufjs/minimal/LICENSE +39 -0
- package/vendor/dist/protobufjs/minimal/index.js +1 -0
- package/vendor/dist/retry/LICENSE +21 -0
- package/vendor/dist/retry/index.js +1 -0
- package/vendor/dist/rfdc/LICENSE +15 -0
- package/vendor/dist/rfdc/index.js +1 -0
- package/vendor/dist/semifies/LICENSE +201 -0
- package/vendor/dist/semifies/index.js +1 -0
- package/vendor/dist/shell-quote/LICENSE +24 -0
- package/vendor/dist/shell-quote/index.js +1 -0
- package/vendor/dist/source-map/LICENSE +28 -0
- package/vendor/dist/source-map/index.js +1 -0
- package/vendor/dist/source-map/lib/util/LICENSE +28 -0
- package/vendor/dist/source-map/lib/util/index.js +1 -0
- package/vendor/dist/source-map/mappings.wasm +0 -0
- package/vendor/dist/tlhunter-sorted-set/LICENSE +21 -0
- package/vendor/dist/tlhunter-sorted-set/index.js +1 -0
- package/vendor/dist/ttl-set/LICENSE +21 -0
- package/vendor/dist/ttl-set/index.js +1 -0
|
@@ -245,28 +245,45 @@ ${build.initialOptions.banner.js}`
|
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
-
|
|
248
|
+
try {
|
|
249
|
+
const packageJson = JSON.parse(fs.readFileSync(pathToPackageJson).toString())
|
|
249
250
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
251
|
+
const isESM = isESMFile(fullPathToModule, pathToPackageJson, packageJson)
|
|
252
|
+
if (isESM && !interceptedESMModules.has(fullPathToModule)) {
|
|
253
|
+
fullPathToModule += ESM_INTERCEPTED_SUFFIX
|
|
254
|
+
}
|
|
254
255
|
|
|
255
|
-
|
|
256
|
+
if (DEBUG) console.log(`RESOLVE: ${args.path}@${packageJson.version}`)
|
|
256
257
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
258
|
+
// https://esbuild.github.io/plugins/#on-resolve-arguments
|
|
259
|
+
return {
|
|
260
|
+
path: fullPathToModule,
|
|
261
|
+
pluginData: {
|
|
262
|
+
version: packageJson.version,
|
|
263
|
+
pkg: extracted.pkg,
|
|
264
|
+
path: extracted.path,
|
|
265
|
+
full: fullPathToModule,
|
|
266
|
+
raw: args.path,
|
|
267
|
+
pkgOfInterest: true,
|
|
268
|
+
kind: args.kind,
|
|
269
|
+
internal,
|
|
270
|
+
isESM
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
} catch (e) {
|
|
274
|
+
// Skip vendored dependencies which never have a `package.json`. This
|
|
275
|
+
// will use the default resolve logic of ESBuild which is what we want
|
|
276
|
+
// since those files should be treated as regular files and not modules
|
|
277
|
+
// even though they are in a `node_modules` folder.
|
|
278
|
+
if (e.code === 'ENOENT') {
|
|
279
|
+
if (DEBUG) {
|
|
280
|
+
console.log([
|
|
281
|
+
'Skipping `package.json` lookup.',
|
|
282
|
+
'This usually means the package was vendored but could indicate an issue otherwise.'
|
|
283
|
+
].join(' '))
|
|
284
|
+
}
|
|
285
|
+
} else {
|
|
286
|
+
throw e
|
|
270
287
|
}
|
|
271
288
|
}
|
|
272
289
|
}
|
|
@@ -65,7 +65,11 @@ function getSource (url, { format }) {
|
|
|
65
65
|
/**
|
|
66
66
|
* Generates the pieces of code for the proxy module before the path
|
|
67
67
|
*
|
|
68
|
-
* @param {
|
|
68
|
+
* @param {object} moduleData
|
|
69
|
+
* @param {string} moduleData.path
|
|
70
|
+
* @param {boolean} moduleData.internal
|
|
71
|
+
* @param {object} moduleData.context
|
|
72
|
+
* @param {boolean} moduleData.excludeDefault
|
|
69
73
|
* @returns {Promise<Map>}
|
|
70
74
|
*/
|
|
71
75
|
async function processModule ({ path, internal, context, excludeDefault }) {
|
|
@@ -112,4 +112,16 @@ for (const extension of extensions) {
|
|
|
112
112
|
|
|
113
113
|
return exports
|
|
114
114
|
})
|
|
115
|
+
|
|
116
|
+
addHook({
|
|
117
|
+
name: '@anthropic-ai/sdk',
|
|
118
|
+
file: `resources/beta/messages/messages.${extension}`,
|
|
119
|
+
versions: ['>=0.33.0']
|
|
120
|
+
}, exports => {
|
|
121
|
+
const Messages = exports.Messages
|
|
122
|
+
|
|
123
|
+
shimmer.wrap(Messages.prototype, 'create', wrapCreate)
|
|
124
|
+
|
|
125
|
+
return exports
|
|
126
|
+
})
|
|
115
127
|
}
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
const { channel, addHook } = require('./helpers/instrument')
|
|
4
4
|
const shimmer = require('../../datadog-shimmer')
|
|
5
5
|
|
|
6
|
+
const patchedClientConfigProtocols = new WeakSet()
|
|
7
|
+
|
|
6
8
|
function wrapRequest (send) {
|
|
7
9
|
return function wrappedRequest (cb) {
|
|
8
10
|
if (!this.service) return send.apply(this, arguments)
|
|
@@ -34,10 +36,11 @@ function wrapRequest (send) {
|
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
38
|
|
|
37
|
-
function wrapDeserialize (deserialize, channelSuffix) {
|
|
39
|
+
function wrapDeserialize (deserialize, channelSuffix, responseIndex = 0) {
|
|
38
40
|
const headersCh = channel(`apm:aws:response:deserialize:${channelSuffix}`)
|
|
39
41
|
|
|
40
|
-
return function (
|
|
42
|
+
return function () {
|
|
43
|
+
const response = arguments[responseIndex]
|
|
41
44
|
if (headersCh.hasSubscribers) {
|
|
42
45
|
headersCh.publish({ headers: response.headers })
|
|
43
46
|
}
|
|
@@ -66,6 +69,14 @@ function wrapSmithySend (send) {
|
|
|
66
69
|
|
|
67
70
|
if (typeof command.deserialize === 'function') {
|
|
68
71
|
shimmer.wrap(command, 'deserialize', deserialize => wrapDeserialize(deserialize, channelSuffix))
|
|
72
|
+
} else if (this.config?.protocol?.deserializeResponse && !patchedClientConfigProtocols.has(this.config.protocol)) {
|
|
73
|
+
shimmer.wrap(
|
|
74
|
+
this.config.protocol,
|
|
75
|
+
'deserializeResponse',
|
|
76
|
+
deserializeResponse => wrapDeserialize(deserializeResponse, channelSuffix, 2)
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
patchedClientConfigProtocols.add(this.config.protocol)
|
|
69
80
|
}
|
|
70
81
|
|
|
71
82
|
const ctx = {
|
|
@@ -8,57 +8,64 @@ const shimmer = require('../../datadog-shimmer')
|
|
|
8
8
|
const dc = require('dc-polyfill')
|
|
9
9
|
|
|
10
10
|
const producerCh = dc.tracingChannel('apm:azure-service-bus:send')
|
|
11
|
+
const isItDefault = new WeakSet()
|
|
11
12
|
|
|
12
|
-
addHook({ name: '@azure/service-bus', versions: ['>=7.9.2']
|
|
13
|
+
addHook({ name: '@azure/service-bus', versions: ['>=7.9.2'] }, (obj) => {
|
|
13
14
|
const ServiceBusClient = obj.ServiceBusClient
|
|
14
|
-
let didItShim = false
|
|
15
15
|
shimmer.wrap(ServiceBusClient.prototype, 'createSender',
|
|
16
16
|
createSender => function (queueOrTopicName) {
|
|
17
17
|
const sender = createSender.apply(this, arguments)
|
|
18
|
-
if (didItShim) return sender
|
|
19
18
|
const senderPrototype = sender.constructor.prototype
|
|
20
19
|
const senderSenderPrototype = sender._sender.constructor.prototype
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
|
|
21
|
+
if (!isItDefault.has(senderPrototype)) {
|
|
22
|
+
isItDefault.add(senderPrototype)
|
|
23
|
+
|
|
24
|
+
shimmer.wrap(senderPrototype, 'scheduleMessages', scheduleMessages =>
|
|
25
|
+
function (msg, scheduledEnqueueTimeUtc) {
|
|
26
|
+
const functionName = scheduleMessages.name
|
|
27
|
+
const config = this._context.config
|
|
28
|
+
const entityPath = this._entityPath
|
|
29
|
+
return producerCh.tracePromise(
|
|
30
|
+
scheduleMessages,
|
|
31
|
+
{ config, entityPath, functionName, msg, scheduledEnqueueTimeUtc },
|
|
32
|
+
this, ...arguments
|
|
33
|
+
)
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
shimmer.wrap(senderPrototype, 'createMessageBatch', createMessageBatch => async function () {
|
|
37
|
+
const batch = await createMessageBatch.apply(this, arguments)
|
|
38
|
+
shimmer.wrap(batch, 'tryAddMessage', tryAddMessage => function (msg) {
|
|
39
|
+
const functionName = tryAddMessage.name
|
|
40
|
+
const config = this._context.config
|
|
41
|
+
return producerCh.tracePromise(
|
|
42
|
+
tryAddMessage, { config, functionName, batch, msg }, this, ...arguments)
|
|
43
|
+
})
|
|
44
|
+
return batch
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (!isItDefault.has(senderSenderPrototype)) {
|
|
49
|
+
isItDefault.add(senderSenderPrototype)
|
|
50
|
+
|
|
51
|
+
shimmer.wrap(senderSenderPrototype, 'send', send => function (msg) {
|
|
52
|
+
const functionName = send.name
|
|
24
53
|
const config = this._context.config
|
|
25
|
-
const entityPath = this.
|
|
54
|
+
const entityPath = this.entityPath
|
|
26
55
|
return producerCh.tracePromise(
|
|
27
|
-
|
|
28
|
-
{ config, entityPath, functionName, msg, scheduledEnqueueTimeUtc },
|
|
29
|
-
this, ...arguments
|
|
56
|
+
send, { config, entityPath, functionName, msg }, this, ...arguments
|
|
30
57
|
)
|
|
31
58
|
})
|
|
32
59
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
shimmer.wrap(batch.constructor.prototype, 'tryAddMessage', tryAddMessage => function (msg) {
|
|
36
|
-
const functionName = tryAddMessage.name
|
|
60
|
+
shimmer.wrap(senderSenderPrototype, 'sendBatch', sendBatch => function (msg) {
|
|
61
|
+
const functionName = sendBatch.name
|
|
37
62
|
const config = this._context.config
|
|
63
|
+
const entityPath = this.entityPath
|
|
38
64
|
return producerCh.tracePromise(
|
|
39
|
-
|
|
65
|
+
sendBatch, { config, entityPath, functionName, msg }, this, ...arguments
|
|
66
|
+
)
|
|
40
67
|
})
|
|
41
|
-
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
shimmer.wrap(senderSenderPrototype, 'send', send => function (msg) {
|
|
45
|
-
const functionName = send.name
|
|
46
|
-
const config = this._context.config
|
|
47
|
-
const entityPath = this.entityPath
|
|
48
|
-
return producerCh.tracePromise(
|
|
49
|
-
send, { config, entityPath, functionName, msg }, this, ...arguments
|
|
50
|
-
)
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
shimmer.wrap(senderSenderPrototype, 'sendBatch', sendBatch => function (msg) {
|
|
54
|
-
const functionName = sendBatch.name
|
|
55
|
-
const config = this._context.config
|
|
56
|
-
const entityPath = this.entityPath
|
|
57
|
-
return producerCh.tracePromise(
|
|
58
|
-
sendBatch, { config, entityPath, functionName, msg }, this, ...arguments
|
|
59
|
-
)
|
|
60
|
-
})
|
|
61
|
-
didItShim = true
|
|
68
|
+
}
|
|
62
69
|
return sender
|
|
63
70
|
})
|
|
64
71
|
return obj
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use strict'
|
|
2
|
-
const { createCoverageMap } = require('istanbul-lib-coverage')
|
|
2
|
+
const { createCoverageMap } = require('../../../vendor/dist/istanbul-lib-coverage')
|
|
3
3
|
|
|
4
4
|
const { addHook, channel } = require('./helpers/instrument')
|
|
5
5
|
const shimmer = require('../../datadog-shimmer')
|
|
@@ -43,7 +43,7 @@ const {
|
|
|
43
43
|
CUCUMBER_WORKER_TRACE_PAYLOAD_CODE,
|
|
44
44
|
getIsFaultyEarlyFlakeDetection
|
|
45
45
|
} = require('../../dd-trace/src/plugins/util/test')
|
|
46
|
-
const satisfies = require('semifies')
|
|
46
|
+
const satisfies = require('../../../vendor/dist/semifies')
|
|
47
47
|
|
|
48
48
|
const isMarkedAsUnskippable = (pickle) => {
|
|
49
49
|
return pickle.tags.some(tag => tag.name === '@datadog:unskippable')
|
|
@@ -9,13 +9,13 @@ function wrapOn (on) {
|
|
|
9
9
|
return function onWithTrace (method, path, opts) {
|
|
10
10
|
const index = typeof opts === 'function' ? 2 : 3
|
|
11
11
|
const handler = arguments[index]
|
|
12
|
-
const wrapper = shimmer.wrapFunction(handler, handler => function (req) {
|
|
13
|
-
routeChannel.publish({ req, route: path })
|
|
14
|
-
|
|
15
|
-
return handler.apply(this, arguments)
|
|
16
|
-
})
|
|
17
12
|
|
|
18
13
|
if (typeof handler === 'function') {
|
|
14
|
+
const wrapper = shimmer.wrapFunction(handler, handler => function (req) {
|
|
15
|
+
routeChannel.publish({ req, route: path })
|
|
16
|
+
|
|
17
|
+
return handler.apply(this, arguments)
|
|
18
|
+
})
|
|
19
19
|
arguments[index] = wrapper
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -24,6 +24,7 @@ function wrapOn (on) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
addHook({ name: 'find-my-way', versions: ['>=1'] }, Router => {
|
|
27
|
+
// No need to wrap the off method as it would not contain the handler function.
|
|
27
28
|
shimmer.wrap(Router.prototype, 'on', wrapOn)
|
|
28
29
|
|
|
29
30
|
return Router
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { addHook } = require('./helpers/instrument')
|
|
4
|
+
const shimmer = require('../../datadog-shimmer')
|
|
5
|
+
const tracingChannel = require('dc-polyfill').tracingChannel
|
|
6
|
+
const channel = require('dc-polyfill').channel
|
|
7
|
+
|
|
8
|
+
const genaiTracingChannel = tracingChannel('apm:google:genai:request')
|
|
9
|
+
const onStreamedChunkCh = channel('apm:google:genai:request:chunk')
|
|
10
|
+
|
|
11
|
+
function wrapGenerateContent (method) {
|
|
12
|
+
return function wrappedGenerateContent (original) {
|
|
13
|
+
return function (...args) {
|
|
14
|
+
if (!genaiTracingChannel.start.hasSubscribers) {
|
|
15
|
+
return original.apply(this, args)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const normalizedName = normalizeMethodName(method)
|
|
19
|
+
|
|
20
|
+
const ctx = { args, methodName: normalizedName }
|
|
21
|
+
|
|
22
|
+
return genaiTracingChannel.start.runStores(ctx, () => {
|
|
23
|
+
let result
|
|
24
|
+
try {
|
|
25
|
+
result = original.apply(this, arguments)
|
|
26
|
+
} catch (error) {
|
|
27
|
+
finish(ctx, null, error)
|
|
28
|
+
throw error
|
|
29
|
+
} finally {
|
|
30
|
+
genaiTracingChannel.end.publish(ctx)
|
|
31
|
+
}
|
|
32
|
+
return result.then(response => {
|
|
33
|
+
if (response[Symbol.asyncIterator]) {
|
|
34
|
+
shimmer.wrap(response, Symbol.asyncIterator, iterator => wrapStreamIterator(iterator, ctx))
|
|
35
|
+
} else {
|
|
36
|
+
finish(ctx, response, null)
|
|
37
|
+
}
|
|
38
|
+
return response
|
|
39
|
+
}).catch(error => {
|
|
40
|
+
finish(ctx, null, error)
|
|
41
|
+
throw error
|
|
42
|
+
})
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function wrapStreamIterator (iterator, ctx) {
|
|
49
|
+
return function () {
|
|
50
|
+
const itr = iterator.apply(this, arguments)
|
|
51
|
+
shimmer.wrap(itr, 'next', next => function () {
|
|
52
|
+
return next.apply(this, arguments)
|
|
53
|
+
.then(res => {
|
|
54
|
+
const { done, value: chunk } = res
|
|
55
|
+
onStreamedChunkCh.publish({ ctx, chunk, done })
|
|
56
|
+
|
|
57
|
+
if (done) {
|
|
58
|
+
finish(ctx)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return res
|
|
62
|
+
})
|
|
63
|
+
.catch(error => {
|
|
64
|
+
finish(ctx, null, error)
|
|
65
|
+
throw error
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
return itr
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function finish (ctx, result, error) {
|
|
73
|
+
if (error) {
|
|
74
|
+
ctx.error = error
|
|
75
|
+
genaiTracingChannel.error.publish(ctx)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// streamed responses are handled and set separately
|
|
79
|
+
ctx.result ??= result
|
|
80
|
+
|
|
81
|
+
genaiTracingChannel.asyncEnd.publish(ctx)
|
|
82
|
+
}
|
|
83
|
+
// Hook the main package entry point
|
|
84
|
+
addHook({
|
|
85
|
+
name: '@google/genai',
|
|
86
|
+
versions: ['>=1.19.0']
|
|
87
|
+
}, exports => {
|
|
88
|
+
// Wrap GoogleGenAI to intercept when it creates Models instances
|
|
89
|
+
if (!exports.GoogleGenAI) return exports
|
|
90
|
+
|
|
91
|
+
shimmer.wrap(exports, 'GoogleGenAI', GoogleGenAI => {
|
|
92
|
+
return class extends GoogleGenAI {
|
|
93
|
+
constructor (...args) {
|
|
94
|
+
super(...args)
|
|
95
|
+
|
|
96
|
+
// We are patching the instance instead of the prototype because when it is compiled from
|
|
97
|
+
// typescript, the models property is not available on the prototype.
|
|
98
|
+
if (this.models) {
|
|
99
|
+
if (this.models.generateContent) {
|
|
100
|
+
shimmer.wrap(this.models, 'generateContent', wrapGenerateContent('generateContent'))
|
|
101
|
+
}
|
|
102
|
+
if (this.models.generateContentStream) {
|
|
103
|
+
shimmer.wrap(this.models, 'generateContentStream', wrapGenerateContent('generateContentStream'))
|
|
104
|
+
}
|
|
105
|
+
if (this.models.embedContent) {
|
|
106
|
+
shimmer.wrap(this.models, 'embedContent', wrapGenerateContent('embedContent'))
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
})
|
|
112
|
+
return exports
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
function normalizeMethodName (methodName) {
|
|
116
|
+
// Convert camelCase to snake_case and add Models prefix
|
|
117
|
+
return 'Models.' + methodName
|
|
118
|
+
.replaceAll(/([a-z0-9])([A-Z])/g, '$1_$2')
|
|
119
|
+
.toLowerCase()
|
|
120
|
+
}
|
|
@@ -6,6 +6,8 @@ const {
|
|
|
6
6
|
} = require('./helpers/instrument')
|
|
7
7
|
const shimmer = require('../../datadog-shimmer')
|
|
8
8
|
|
|
9
|
+
const ddGlobal = globalThis[Symbol.for('dd-trace')] ??= {}
|
|
10
|
+
|
|
9
11
|
/** cached objects */
|
|
10
12
|
|
|
11
13
|
const contexts = new WeakMap()
|
|
@@ -360,3 +362,21 @@ addHook({ name: 'graphql', file: 'validation/validate.js', versions: ['>=0.10']
|
|
|
360
362
|
|
|
361
363
|
return validate
|
|
362
364
|
})
|
|
365
|
+
|
|
366
|
+
addHook({ name: 'graphql', file: 'language/printer.js', versions: ['>=0.10'] }, printer => {
|
|
367
|
+
// HACK: It's possible `graphql` is loaded before `@apollo/gateway` so we
|
|
368
|
+
// can't use a channel as the latter plugin would load after the publish
|
|
369
|
+
// happened. Not sure how to handle this so for now use a global.
|
|
370
|
+
ddGlobal.graphql_printer = printer
|
|
371
|
+
return printer
|
|
372
|
+
})
|
|
373
|
+
|
|
374
|
+
addHook({ name: 'graphql', file: 'language/visitor.js', versions: ['>=0.10'] }, visitor => {
|
|
375
|
+
ddGlobal.graphql_visitor = visitor
|
|
376
|
+
return visitor
|
|
377
|
+
})
|
|
378
|
+
|
|
379
|
+
addHook({ name: 'graphql', file: 'utilities/index.js', versions: ['>=0.10'] }, utilities => {
|
|
380
|
+
ddGlobal.graphql_utilities = utilities
|
|
381
|
+
return utilities
|
|
382
|
+
})
|
|
@@ -8,6 +8,7 @@ const ritm = require('../../../dd-trace/src/ritm')
|
|
|
8
8
|
* In practice, `modules` is always an array with a single entry.
|
|
9
9
|
*
|
|
10
10
|
* @param {string[]} modules list of modules to hook into
|
|
11
|
+
* @param {object} hookOptions hook options
|
|
11
12
|
* @param {Function} onrequire callback to be executed upon encountering module
|
|
12
13
|
*/
|
|
13
14
|
function Hook (modules, hookOptions, onrequire) {
|
|
@@ -13,6 +13,7 @@ module.exports = {
|
|
|
13
13
|
'@playwright/test': () => require('../playwright'),
|
|
14
14
|
'@elastic/elasticsearch': () => require('../elasticsearch'),
|
|
15
15
|
'@elastic/transport': () => require('../elasticsearch'),
|
|
16
|
+
'@google/genai': () => require('../google-genai'),
|
|
16
17
|
'@google-cloud/pubsub': () => require('../google-cloud-pubsub'),
|
|
17
18
|
'@google-cloud/vertexai': () => require('../google-cloud-vertexai'),
|
|
18
19
|
'@graphql-tools/executor': () => require('../graphql'),
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const dc = require('dc-polyfill')
|
|
4
4
|
const instrumentations = require('./instrumentations')
|
|
5
|
+
const rewriterInstrumentations = require('./rewriter/instrumentations')
|
|
5
6
|
const { AsyncResource } = require('async_hooks')
|
|
6
7
|
|
|
7
8
|
const channelMap = {}
|
|
@@ -22,13 +23,23 @@ exports.tracingChannel = function (name) {
|
|
|
22
23
|
return tc
|
|
23
24
|
}
|
|
24
25
|
|
|
26
|
+
exports.getHooks = function getHooks (names) {
|
|
27
|
+
names = [names].flat()
|
|
28
|
+
|
|
29
|
+
return rewriterInstrumentations
|
|
30
|
+
.map(inst => inst.module)
|
|
31
|
+
.filter(({ name }) => names.includes(name))
|
|
32
|
+
.map(({ name, versionRange, filePath }) => ({ name, versions: [versionRange], file: filePath }))
|
|
33
|
+
}
|
|
34
|
+
|
|
25
35
|
/**
|
|
26
36
|
* @param {object} args
|
|
27
37
|
* @param {string|string[]} args.name module name
|
|
28
38
|
* @param {string[]} args.versions array of semver range strings
|
|
29
39
|
* @param {string} [args.file='index.js'] path to file within package to instrument
|
|
30
40
|
* @param {string} [args.filePattern] pattern to match files within package to instrument
|
|
31
|
-
* @param
|
|
41
|
+
* @param {boolean} [args.patchDefault] whether to patch the default export
|
|
42
|
+
* @param {(moduleExports: unknown, version: string) => unknown} hook
|
|
32
43
|
*/
|
|
33
44
|
exports.addHook = function addHook ({ name, versions, file, filePattern, patchDefault }, hook) {
|
|
34
45
|
if (typeof name === 'string') {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const { channel } = require('dc-polyfill')
|
|
4
4
|
const path = require('path')
|
|
5
|
-
const satisfies = require('semifies')
|
|
5
|
+
const satisfies = require('../../../../vendor/dist/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')
|
|
@@ -10,6 +10,7 @@ const checkRequireCache = require('./check-require-cache')
|
|
|
10
10
|
const telemetry = require('../../../dd-trace/src/guardrails/telemetry')
|
|
11
11
|
const { isInServerlessEnvironment } = require('../../../dd-trace/src/serverless')
|
|
12
12
|
const { getEnvironmentVariables } = require('../../../dd-trace/src/config-helper')
|
|
13
|
+
const rewriter = require('./rewriter')
|
|
13
14
|
|
|
14
15
|
const envs = getEnvironmentVariables()
|
|
15
16
|
|
|
@@ -48,6 +49,10 @@ if (DD_TRACE_DEBUG && DD_TRACE_DEBUG.toLowerCase() !== 'false') {
|
|
|
48
49
|
const seenCombo = new Set()
|
|
49
50
|
const allInstrumentations = {}
|
|
50
51
|
|
|
52
|
+
for (const inst of disabledInstrumentations) {
|
|
53
|
+
rewriter.disable(inst)
|
|
54
|
+
}
|
|
55
|
+
|
|
51
56
|
// TODO: make this more efficient
|
|
52
57
|
for (const packageName of names) {
|
|
53
58
|
if (disabledInstrumentations.has(packageName)) continue
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
let meriyah
|
|
4
|
+
let astring
|
|
5
|
+
let esquery
|
|
6
|
+
|
|
7
|
+
module.exports = {
|
|
8
|
+
parse: (...args) => {
|
|
9
|
+
meriyah ??= require('../../../../../vendor/dist/meriyah')
|
|
10
|
+
|
|
11
|
+
return meriyah.parse(...args)
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
generate: (...args) => {
|
|
15
|
+
astring ??= require('../../../../../vendor/dist/astring')
|
|
16
|
+
|
|
17
|
+
return astring.generate(...args)
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
traverse: (ast, query, visitor) => {
|
|
21
|
+
esquery ??= require('../../../../../vendor/dist/esquery').default
|
|
22
|
+
|
|
23
|
+
const selector = esquery.parse(query)
|
|
24
|
+
|
|
25
|
+
return esquery.traverse(ast, selector, visitor)
|
|
26
|
+
},
|
|
27
|
+
}
|