dd-trace 5.108.0 → 5.110.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/ci/init.js +4 -3
- package/index.d.ts +88 -25
- package/loader-hook.mjs +88 -2
- package/package.json +19 -14
- package/packages/datadog-esbuild/index.js +26 -0
- package/packages/datadog-esbuild/src/utils.js +46 -3
- package/packages/datadog-instrumentations/src/ai.js +43 -48
- package/packages/datadog-instrumentations/src/aws-durable-execution-sdk-js-context-methods.js +18 -0
- package/packages/datadog-instrumentations/src/aws-durable-execution-sdk-js.js +111 -0
- package/packages/datadog-instrumentations/src/aws-sdk.js +3 -1
- package/packages/datadog-instrumentations/src/connect.js +4 -3
- package/packages/datadog-instrumentations/src/electron.js +1 -1
- package/packages/datadog-instrumentations/src/fastify.js +4 -12
- package/packages/datadog-instrumentations/src/graphql.js +17 -6
- package/packages/datadog-instrumentations/src/helpers/check-require-cache.js +81 -8
- package/packages/datadog-instrumentations/src/helpers/hooks.js +1 -0
- package/packages/datadog-instrumentations/src/helpers/instrument.js +27 -2
- package/packages/datadog-instrumentations/src/helpers/optional-peer-bundler.js +65 -0
- package/packages/datadog-instrumentations/src/helpers/register.js +6 -4
- package/packages/datadog-instrumentations/src/helpers/require-optional-peer.js +17 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/aws-durable-execution-sdk-js.js +31 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/index.js +1 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/loader.mjs +18 -2
- package/packages/datadog-instrumentations/src/http/client.js +12 -2
- package/packages/datadog-instrumentations/src/ioredis.js +0 -1
- package/packages/datadog-instrumentations/src/iovalkey.js +1 -2
- package/packages/datadog-instrumentations/src/koa.js +3 -2
- package/packages/datadog-instrumentations/src/mariadb.js +4 -2
- package/packages/datadog-instrumentations/src/mocha/main.js +3 -3
- package/packages/datadog-instrumentations/src/next.js +44 -10
- package/packages/datadog-instrumentations/src/openai.js +77 -18
- package/packages/datadog-instrumentations/src/otel-sdk-trace.js +7 -6
- package/packages/datadog-instrumentations/src/playwright.js +1 -1
- package/packages/datadog-instrumentations/src/redis.js +0 -1
- package/packages/datadog-instrumentations/src/restify.js +4 -3
- package/packages/datadog-instrumentations/src/router.js +18 -5
- package/packages/datadog-instrumentations/src/selenium.js +1 -2
- package/packages/datadog-instrumentations/src/tedious.js +28 -0
- package/packages/datadog-instrumentations/src/vitest.js +323 -7
- package/packages/datadog-plugin-avsc/src/schema_iterator.js +2 -2
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/checkpoint.js +31 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/client.js +55 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/context.js +114 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/handler.js +128 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/index.js +19 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/trace-checkpoint.js +224 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/util.js +43 -0
- package/packages/datadog-plugin-aws-sdk/src/base.js +14 -16
- package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +43 -6
- package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +100 -37
- package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +108 -99
- package/packages/datadog-plugin-bullmq/src/filter.js +35 -0
- package/packages/datadog-plugin-bullmq/src/producer.js +84 -4
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +9 -1
- package/packages/datadog-plugin-fs/src/index.js +1 -0
- package/packages/datadog-plugin-http/src/client.js +8 -3
- package/packages/datadog-plugin-http2/src/client.js +5 -2
- package/packages/datadog-plugin-mysql/src/index.js +7 -2
- package/packages/datadog-plugin-protobufjs/src/schema_iterator.js +2 -2
- package/packages/datadog-plugin-redis/src/index.js +1 -2
- package/packages/datadog-plugin-undici/src/index.js +5 -2
- package/packages/datadog-plugin-vitest/src/index.js +11 -2
- package/packages/datadog-webpack/index.js +17 -1
- package/packages/datadog-webpack/src/optional-peer-loader.js +17 -0
- package/packages/dd-trace/src/aiguard/channels.js +0 -1
- package/packages/dd-trace/src/aiguard/index.js +11 -49
- package/packages/dd-trace/src/aiguard/integrations/evaluate.js +46 -0
- package/packages/dd-trace/src/aiguard/integrations/openai.js +66 -0
- package/packages/dd-trace/src/aiguard/integrations/vercel-ai.js +78 -0
- package/packages/{datadog-instrumentations/src/helpers/ai-messages.js → dd-trace/src/aiguard/messages/openai.js} +85 -193
- package/packages/dd-trace/src/aiguard/messages/vercel-ai.js +185 -0
- package/packages/dd-trace/src/aiguard/sdk.js +13 -1
- package/packages/dd-trace/src/appsec/api_security/index.js +55 -0
- package/packages/dd-trace/src/appsec/api_security/sampler.js +147 -0
- package/packages/dd-trace/src/appsec/channels.js +1 -0
- package/packages/dd-trace/src/appsec/downstream_requests.js +111 -58
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/ldap-sensitive-analyzer.js +54 -12
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/url-sensitive-analyzer.js +5 -1
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +29 -4
- package/packages/dd-trace/src/appsec/index.js +10 -6
- package/packages/dd-trace/src/appsec/rasp/ssrf.js +19 -11
- package/packages/dd-trace/src/appsec/reporter.js +1 -0
- package/packages/dd-trace/src/appsec/telemetry/api_security.js +34 -0
- package/packages/dd-trace/src/appsec/telemetry/index.js +26 -0
- package/packages/dd-trace/src/ci-visibility/requests/request.js +1 -17
- package/packages/dd-trace/src/config/defaults.js +22 -3
- package/packages/dd-trace/src/config/generated-config-types.d.ts +538 -1
- package/packages/dd-trace/src/config/helper.js +133 -33
- package/packages/dd-trace/src/config/index.js +4 -1
- package/packages/dd-trace/src/config/parsers.js +19 -1
- package/packages/dd-trace/src/config/supported-configurations.json +45 -5
- package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +49 -35
- package/packages/dd-trace/src/debugger/devtools_client/index.js +31 -66
- package/packages/dd-trace/src/debugger/devtools_client/probe_sampler.js +83 -0
- package/packages/dd-trace/src/debugger/devtools_client/state.js +1 -0
- package/packages/dd-trace/src/debugger/index.js +5 -0
- package/packages/dd-trace/src/debugger/probe_sampler.js +112 -0
- package/packages/dd-trace/src/debugger/probe_sampler_constants.js +19 -0
- package/packages/dd-trace/src/dogstatsd.js +15 -8
- package/packages/dd-trace/src/encode/agentless-ci-visibility.js +77 -26
- package/packages/dd-trace/src/exporters/agentless/index.js +7 -5
- package/packages/dd-trace/src/exporters/agentless/intake.js +43 -0
- package/packages/dd-trace/src/exporters/agentless/writer.js +5 -4
- package/packages/dd-trace/src/exporters/common/request.js +1 -20
- package/packages/dd-trace/src/exporters/common/url.js +34 -0
- package/packages/dd-trace/src/exporters/span-stats/writer.js +1 -3
- package/packages/dd-trace/src/guardrails/index.js +8 -5
- package/packages/dd-trace/src/index.js +6 -4
- package/packages/dd-trace/src/llmobs/constants/tags.js +6 -0
- package/packages/dd-trace/src/llmobs/index.js +16 -5
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +3 -3
- package/packages/dd-trace/src/llmobs/plugins/langchain/index.js +5 -1
- package/packages/dd-trace/src/llmobs/sdk.js +5 -3
- package/packages/dd-trace/src/llmobs/span_processor.js +4 -0
- package/packages/dd-trace/src/llmobs/tagger.js +55 -0
- package/packages/dd-trace/src/llmobs/telemetry.js +1 -0
- package/packages/dd-trace/src/log/index.js +18 -20
- package/packages/dd-trace/src/openfeature/flagging_provider.js +3 -1
- package/packages/dd-trace/src/opentelemetry/bridge-span-base.js +5 -4
- package/packages/dd-trace/src/opentelemetry/metrics/instruments.js +2 -1
- package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +4 -3
- package/packages/dd-trace/src/opentelemetry/metrics/time.js +19 -0
- package/packages/dd-trace/src/opentelemetry/otlp/common.proto +2 -2
- package/packages/dd-trace/src/opentelemetry/otlp/logs.proto +1 -1
- package/packages/dd-trace/src/opentelemetry/otlp/logs_service.proto +1 -1
- package/packages/dd-trace/src/opentelemetry/otlp/metrics.proto +1 -1
- package/packages/dd-trace/src/opentelemetry/otlp/metrics_service.proto +1 -1
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +11 -4
- package/packages/dd-trace/src/opentelemetry/span-helpers.js +29 -13
- package/packages/dd-trace/src/opentelemetry/span.js +14 -3
- package/packages/dd-trace/src/opentelemetry/span_context.js +1 -0
- package/packages/dd-trace/src/opentelemetry/trace/index.js +2 -1
- package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +3 -2
- package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +26 -13
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +3 -3
- package/packages/dd-trace/src/opentracing/span_context.js +17 -0
- package/packages/dd-trace/src/plugin_manager.js +7 -1
- package/packages/dd-trace/src/plugins/ci_plugin.js +36 -3
- package/packages/dd-trace/src/plugins/index.js +3 -0
- package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +276 -0
- package/packages/dd-trace/src/plugins/util/test.js +80 -0
- package/packages/dd-trace/src/plugins/util/url.js +68 -1
- package/packages/dd-trace/src/plugins/util/web.js +19 -36
- package/packages/dd-trace/src/priority_sampler.js +1 -13
- package/packages/dd-trace/src/profiling/config.js +129 -198
- package/packages/dd-trace/src/profiling/constants.js +4 -7
- package/packages/dd-trace/src/profiling/exporter_cli.js +10 -10
- package/packages/dd-trace/src/profiling/exporters/agent.js +23 -16
- package/packages/dd-trace/src/profiling/exporters/event_serializer.js +45 -14
- package/packages/dd-trace/src/profiling/exporters/file.js +16 -5
- package/packages/dd-trace/src/profiling/oom.js +71 -0
- package/packages/dd-trace/src/profiling/profiler.js +35 -23
- package/packages/dd-trace/src/profiling/profilers/events.js +14 -7
- package/packages/dd-trace/src/profiling/profilers/space.js +27 -18
- package/packages/dd-trace/src/profiling/profilers/wall.js +35 -25
- package/packages/dd-trace/src/ritm.js +4 -2
- package/packages/dd-trace/src/serverless.js +1 -2
- package/packages/dd-trace/src/service-naming/schemas/util.js +36 -5
- package/packages/dd-trace/src/service-naming/schemas/v0/serverless.js +12 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/serverless.js +12 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/web.js +5 -3
- package/packages/dd-trace/src/span_format.js +2 -1
- package/packages/dd-trace/src/span_processor.js +6 -0
- package/packages/dd-trace/src/telemetry/send-data.js +12 -10
- package/packages/dd-trace/src/tracer.js +15 -1
- package/packages/dd-trace/src/util.js +14 -0
- package/register.js +58 -1
- package/vendor/dist/@apm-js-collab/code-transformer/index.js +1 -1
- package/vendor/dist/@datadog/sketches-js/index.js +1 -1
- package/vendor/dist/pprof-format/index.js +1 -1
- package/vendor/dist/protobufjs/index.js +1 -1
- package/vendor/dist/protobufjs/minimal/index.js +1 -1
- package/packages/datadog-instrumentations/src/helpers/openai-ai-guard.js +0 -284
- package/packages/dd-trace/src/appsec/api_security_sampler.js +0 -117
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const { identityService, httpPluginClientService, optionServiceSource } = require('../util')
|
|
3
|
+
const { identityService, httpPluginClientService, optionServiceSource, awsServiceV1 } = require('../util')
|
|
4
4
|
|
|
5
5
|
const web = {
|
|
6
6
|
client: {
|
|
@@ -38,11 +38,13 @@ const web = {
|
|
|
38
38
|
},
|
|
39
39
|
aws: {
|
|
40
40
|
opName: ({ awsService }) => `aws.${awsService}.request`,
|
|
41
|
-
serviceName:
|
|
41
|
+
serviceName: awsServiceV1,
|
|
42
|
+
serviceSource: optionServiceSource,
|
|
42
43
|
},
|
|
43
44
|
lambda: {
|
|
44
45
|
opName: () => 'aws.lambda.invoke',
|
|
45
|
-
serviceName:
|
|
46
|
+
serviceName: awsServiceV1,
|
|
47
|
+
serviceSource: optionServiceSource,
|
|
46
48
|
},
|
|
47
49
|
undici: {
|
|
48
50
|
opName: () => 'undici.request',
|
|
@@ -176,7 +176,8 @@ function extractTags (formattedSpan, span) {
|
|
|
176
176
|
metrics[MEASURED] = 1
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
-
const
|
|
179
|
+
const tracer = span.tracer()
|
|
180
|
+
const tracerService = tracer.serviceLower
|
|
180
181
|
if (tags['service.name']?.toLowerCase() !== tracerService) {
|
|
181
182
|
span.setTag(BASE_SERVICE, tracerService)
|
|
182
183
|
|
|
@@ -5,6 +5,7 @@ const spanFormat = require('./span_format')
|
|
|
5
5
|
const SpanSampler = require('./span_sampler')
|
|
6
6
|
const GitMetadataTagger = require('./git_metadata_tagger')
|
|
7
7
|
const processTags = require('./process-tags')
|
|
8
|
+
const { applyHttpOtelSemantics } = require('./plugins/util/http-otel-semantics')
|
|
8
9
|
|
|
9
10
|
const startedSpans = new WeakSet()
|
|
10
11
|
const finishedSpans = new WeakSet()
|
|
@@ -61,7 +62,12 @@ class SpanProcessor {
|
|
|
61
62
|
} else {
|
|
62
63
|
const formattedSpan = spanFormat(span, isFirstSpanInChunk, this._processTags)
|
|
63
64
|
isFirstSpanInChunk = false
|
|
65
|
+
// Span stats read Datadog HTTP tag names from the formatted span, so
|
|
66
|
+
// record them before the OTel rename — an export-only transform.
|
|
64
67
|
this._stats?.onSpanFinished(formattedSpan)
|
|
68
|
+
if (this._config.DD_TRACE_OTEL_SEMANTICS_ENABLED) {
|
|
69
|
+
applyHttpOtelSemantics(formattedSpan)
|
|
70
|
+
}
|
|
65
71
|
formatted.push(formattedSpan)
|
|
66
72
|
}
|
|
67
73
|
}
|
|
@@ -182,7 +182,13 @@ function sendData (config, application, host, reqType, payload = {}, cb = () =>
|
|
|
182
182
|
agentTelemetry = false
|
|
183
183
|
}
|
|
184
184
|
// figure out which data center to send to
|
|
185
|
-
|
|
185
|
+
let backendUrl
|
|
186
|
+
try {
|
|
187
|
+
backendUrl = new URL(getAgentlessTelemetryEndpoint(config.site))
|
|
188
|
+
} catch {
|
|
189
|
+
log.error('Invalid Telemetry URL')
|
|
190
|
+
return
|
|
191
|
+
}
|
|
186
192
|
const backendHeader = { ...options.headers, 'DD-API-KEY': config.apiKey }
|
|
187
193
|
const backendOptions = {
|
|
188
194
|
...options,
|
|
@@ -190,15 +196,11 @@ function sendData (config, application, host, reqType, payload = {}, cb = () =>
|
|
|
190
196
|
headers: backendHeader,
|
|
191
197
|
path: '/api/v2/apmtelemetry',
|
|
192
198
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
})
|
|
199
|
-
} else {
|
|
200
|
-
log.error('Invalid Telemetry URL')
|
|
201
|
-
}
|
|
199
|
+
request(data, backendOptions, (error) => {
|
|
200
|
+
if (error) {
|
|
201
|
+
log.error('Error sending telemetry data', error)
|
|
202
|
+
}
|
|
203
|
+
})
|
|
202
204
|
}
|
|
203
205
|
|
|
204
206
|
if (!error && !agentTelemetry) {
|
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
const tags = require('../../../ext/tags')
|
|
4
4
|
const { ERROR_MESSAGE, ERROR_TYPE, ERROR_STACK } = require('../../dd-trace/src/constants')
|
|
5
|
-
const {
|
|
5
|
+
const {
|
|
6
|
+
flushStartupLogs,
|
|
7
|
+
flushFrameworkWarnings,
|
|
8
|
+
flushLoadOrderWarnings,
|
|
9
|
+
} = require('../../datadog-instrumentations/src/helpers/check-require-cache')
|
|
6
10
|
const Tracer = require('./opentracing/tracer')
|
|
7
11
|
const Scope = require('./scope')
|
|
8
12
|
const { isError } = require('./util')
|
|
@@ -10,6 +14,10 @@ const { setStartupLogConfig } = require('./startup-log')
|
|
|
10
14
|
const { DataStreamsCheckpointer, DataStreamsManager, DataStreamsProcessor } = require('./datastreams')
|
|
11
15
|
const { IS_SERVERLESS } = require('./serverless')
|
|
12
16
|
const log = require('./log')
|
|
17
|
+
// Always-on writer (console.warn), not the channel-gated `log`: these surface regardless of
|
|
18
|
+
// DD_TRACE_DEBUG.
|
|
19
|
+
const { warn } = require('./log/writer')
|
|
20
|
+
const logDiagnostic = message => warn('DATADOG TRACER DIAGNOSTIC - ' + message)
|
|
13
21
|
|
|
14
22
|
const SPAN_TYPE = tags.SPAN_TYPE
|
|
15
23
|
const RESOURCE_NAME = tags.RESOURCE_NAME
|
|
@@ -25,6 +33,12 @@ class DatadogTracer extends Tracer {
|
|
|
25
33
|
this._scope = new Scope()
|
|
26
34
|
setStartupLogConfig(config)
|
|
27
35
|
flushStartupLogs(log)
|
|
36
|
+
// Curated frameworks (e.g. Next.js) silently no-op when loaded first and their users enable
|
|
37
|
+
// no logging (#5430 / #5432), so surface those unconditionally.
|
|
38
|
+
flushFrameworkWarnings(logDiagnostic)
|
|
39
|
+
if (config.startupLogs) {
|
|
40
|
+
flushLoadOrderWarnings(logDiagnostic)
|
|
41
|
+
}
|
|
28
42
|
|
|
29
43
|
if (!IS_SERVERLESS) {
|
|
30
44
|
const storeConfig = require('./tracer_metadata')
|
|
@@ -91,6 +91,19 @@ function normalizePluginEnvName (envPluginName, makeLowercase = false) {
|
|
|
91
91
|
return makeLowercase ? envPluginName.toLowerCase() : envPluginName
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
/**
|
|
95
|
+
* Formats a sampling rate as a string with up to 6 decimal digits and no trailing zeros.
|
|
96
|
+
*
|
|
97
|
+
* @param {number} rate
|
|
98
|
+
*/
|
|
99
|
+
function formatKnuthRate (rate) {
|
|
100
|
+
const string = Number(rate).toFixed(6)
|
|
101
|
+
for (let i = string.length - 1; i > 0; i--) {
|
|
102
|
+
if (string[i] === '0') continue
|
|
103
|
+
return string.slice(0, i + (string[i] === '.' ? 0 : 1))
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
94
107
|
module.exports = {
|
|
95
108
|
isEmpty,
|
|
96
109
|
isTrue,
|
|
@@ -99,4 +112,5 @@ module.exports = {
|
|
|
99
112
|
globMatch,
|
|
100
113
|
ddBasePath: globalThis.__DD_ESBUILD_BASEPATH || calculateDDBasePath(__dirname),
|
|
101
114
|
normalizePluginEnvName,
|
|
115
|
+
formatKnuthRate,
|
|
102
116
|
}
|
package/register.js
CHANGED
|
@@ -4,5 +4,62 @@
|
|
|
4
4
|
|
|
5
5
|
const { register } = require('node:module')
|
|
6
6
|
const { pathToFileURL } = require('node:url')
|
|
7
|
+
const { NODE_MAJOR, NODE_MINOR, NODE_PATCH } = require('./version')
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
const parentURL = pathToFileURL(__filename)
|
|
10
|
+
let isSyncLoaderRegistered = false
|
|
11
|
+
|
|
12
|
+
if (shouldRegisterSyncLoaderHooks()) {
|
|
13
|
+
let registerSyncLoaderHooks
|
|
14
|
+
let syncRegistrationError
|
|
15
|
+
try {
|
|
16
|
+
({ registerSyncLoaderHooks } = require('./loader-hook.mjs'))
|
|
17
|
+
if (registerSyncLoaderHooks) {
|
|
18
|
+
isSyncLoaderRegistered = registerSyncLoaderHooks()
|
|
19
|
+
}
|
|
20
|
+
} catch (error) {
|
|
21
|
+
syncRegistrationError = error
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (!isSyncLoaderRegistered) {
|
|
25
|
+
warnSyncLoaderFallback(syncRegistrationError)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (!isSyncLoaderRegistered) {
|
|
30
|
+
register('./loader-hook.mjs', parentURL)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function shouldRegisterSyncLoaderHooks () {
|
|
34
|
+
if (!isSyncLoaderHookVersionSupported()) {
|
|
35
|
+
return false
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
return require('import-in-the-middle/create-hook.mjs').supportsSyncHooks()
|
|
40
|
+
} catch (error) {
|
|
41
|
+
if (error?.code !== 'ERR_REQUIRE_ESM') {
|
|
42
|
+
warnSyncLoaderFallback(error)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return false
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function isSyncLoaderHookVersionSupported () {
|
|
50
|
+
if (NODE_MAJOR >= 26) return true
|
|
51
|
+
if (NODE_MAJOR === 25) return NODE_MINOR >= 1
|
|
52
|
+
if (NODE_MAJOR === 24) return NODE_MINOR > 11 || (NODE_MINOR === 11 && NODE_PATCH >= 1)
|
|
53
|
+
if (NODE_MAJOR === 22) return NODE_MINOR > 22 || (NODE_MINOR === 22 && NODE_PATCH >= 3)
|
|
54
|
+
return false
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function warnSyncLoaderFallback (error) {
|
|
58
|
+
let message = 'dd-trace could not register synchronous loader hooks. Falling back to the asynchronous loader.'
|
|
59
|
+
|
|
60
|
+
if (error?.message) {
|
|
61
|
+
message += ` ${error.message}`
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
process.emitWarning(message)
|
|
65
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(()=>{var i={"./@apm-js-collab/code-transformer/index.js"(i,s,k){"use strict";i.exports=k("./@apm-js-collab/code-transformer/lib/index.js")},"./@apm-js-collab/code-transformer/lib/index.js"(i,s,k){"use strict";let{InstrumentationMatcher:S}=k("./@apm-js-collab/code-transformer/lib/matcher.js");i.exports={create:function(i,s){return new S(i,s)}}},"./@apm-js-collab/code-transformer/lib/matcher.js"(i,s,k){"use strict";let S=k("./semifies/index.js"),{Transformer:E}=k("./@apm-js-collab/code-transformer/lib/transformer.js");let InstrumentationMatcher=class InstrumentationMatcher{#e=[];#t=null;#r={};#n={};constructor(i,s){this.#e=i,this.#t=s||"diagnostics_channel"}free(){this.#r={}}addTransform(i,s){this.#n[i]=s}getTransformer(i,s,k){k=k.replace(/\\/g,"/");let w=`${i}/${k}@${s}`;if(this.#r[w])return this.#r[w];let C=this.#e.filter(({module:E})=>E.name===i&&E.filePath===k&&S(s,E.versionRange));if(0!==C.length)return this.#r[w]=new E(i,s,k,C,this.#t,this.#n),this.#r[w]}};i.exports={InstrumentationMatcher}},"./@apm-js-collab/code-transformer/lib/transformer.js"(i,s,k){"use strict";let S,E,w=k("./esquery/dist/esquery.min.js"),{parse:C}=k("./meriyah/dist/meriyah.cjs"),{generate:T}=k("./astring/dist/astring.js"),_=k("./@apm-js-collab/code-transformer/lib/transforms.js");let Transformer=class Transformer{#a=null;#o=null;#i=null;#e=[];#t=null;#n={};constructor(i,s,k,S,E,w={}){this.#a=i,this.#o=s,this.#i=k,this.#e=S,this.#t=E,this.#n=w}free(){}get moduleName(){return this.#a}get filePath(){return this.#i}transform(i,s,_){let O;if(Buffer.isBuffer(i)&&(i=i.toString()),!i)return{code:i};let N={},D=0;for(let k of this.#e){let{astQuery:S,functionQuery:E={}}=k;if(!O){let k={loc:!0,ranges:!0,raw:!0,module:"esm"===s};try{O=C(i,k)}catch{O=C(i,{...k,module:!k.module})}"esm"===s&&(N=this.#s(O))}let T=this.#l(E,N),_=S||this.#c(T),q={...k,dcModule:this.#t,moduleType:s,moduleVersion:this.#o,functionQuery:T};q.operator=this.#u(q),w.traverse(O,w.parse(_),(...i)=>{D++,this.#p(q,...i)})}if(0===D&&this.#e.length>0){let i=this.#e.map(({functionQuery:i={}})=>{let s=this.#l(i,N),k=i.methodName||i.privateMethodName||i.functionName||i.expressionName||"constructor",S=i.className||i.functionName||i.expressionName,E=s.className||s.functionName||s.expressionName;return S&&S!==E?`${S} (local name: ${E})`:k});throw Error(`Failed to find injection points for: ${JSON.stringify(i)}`)}if(O){S??=k("./@apm-js-collab/code-transformer/node_modules/source-map/source-map.js").SourceMapConsumer,E??=k("./@apm-js-collab/code-transformer/node_modules/source-map/source-map.js").SourceMapGenerator;let
|
|
1
|
+
(()=>{var i={"./@apm-js-collab/code-transformer/index.js"(i,s,k){"use strict";i.exports=k("./@apm-js-collab/code-transformer/lib/index.js")},"./@apm-js-collab/code-transformer/lib/index.js"(i,s,k){"use strict";let{InstrumentationMatcher:S}=k("./@apm-js-collab/code-transformer/lib/matcher.js");i.exports={create:function(i,s){return new S(i,s)}}},"./@apm-js-collab/code-transformer/lib/matcher.js"(i,s,k){"use strict";let S=k("./semifies/index.js"),{Transformer:E}=k("./@apm-js-collab/code-transformer/lib/transformer.js");let InstrumentationMatcher=class InstrumentationMatcher{#e=[];#t=null;#r={};#n={};constructor(i,s){this.#e=i,this.#t=s||"diagnostics_channel"}free(){this.#r={}}addTransform(i,s){this.#n[i]=s}getTransformer(i,s,k){k=k.replace(/\\/g,"/");let w=`${i}/${k}@${s}`;if(this.#r[w])return this.#r[w];let C=this.#e.filter(({module:E})=>E.name===i&&E.filePath===k&&S(s,E.versionRange));if(0!==C.length)return this.#r[w]=new E(i,s,k,C,this.#t,this.#n),this.#r[w]}};i.exports={InstrumentationMatcher}},"./@apm-js-collab/code-transformer/lib/transformer.js"(i,s,k){"use strict";let S,E,w=k("./esquery/dist/esquery.min.js"),{parse:C}=k("./meriyah/dist/meriyah.cjs"),{generate:T}=k("./astring/dist/astring.js"),_=k("./@apm-js-collab/code-transformer/lib/transforms.js");let Transformer=class Transformer{#a=null;#o=null;#i=null;#e=[];#t=null;#n={};constructor(i,s,k,S,E,w={}){this.#a=i,this.#o=s,this.#i=k,this.#e=S,this.#t=E,this.#n=w}free(){}get moduleName(){return this.#a}get filePath(){return this.#i}transform(i,s,_){let O;if(Buffer.isBuffer(i)&&(i=i.toString()),!i)return{code:i};let N={},D=0;for(let k of this.#e){let{astQuery:S,functionQuery:E={}}=k;if(!O){let k={loc:!0,ranges:!0,raw:!0,module:"esm"===s};try{O=C(i,k)}catch{O=C(i,{...k,module:!k.module})}"esm"===s&&(N=this.#s(O))}let T=this.#l(E,N),_=S||this.#c(T),q={...k,dcModule:this.#t,moduleType:s,moduleVersion:this.#o,functionQuery:T};q.operator=this.#u(q),w.traverse(O,w.parse(_),(...i)=>{D++,this.#p(q,...i)})}if(0===D&&this.#e.length>0){let i=this.#e.map(({functionQuery:i={}})=>{let s=this.#l(i,N),k=i.methodName||i.privateMethodName||i.functionName||i.expressionName||"constructor",S=i.className||i.functionName||i.expressionName,E=s.className||s.functionName||s.expressionName;return S&&S!==E?`${S} (local name: ${E})`:k});throw Error(`Failed to find injection points for: ${JSON.stringify(i)}`)}if(O){let i;S??=k("./@apm-js-collab/code-transformer/node_modules/source-map/source-map.js").SourceMapConsumer,E??=k("./@apm-js-collab/code-transformer/node_modules/source-map/source-map.js").SourceMapGenerator;let s=`${this.#a}/${this.#i}`;if(_){let k=new S(_);k.file=s,i=E.fromSourceMap(k)}else i=new E({file:s});return{code:T(O,{sourceMap:i}),map:i.toString()}}return{code:i}}#p(i,...s){let k=this.#n[i.operator]??_[i.operator],{index:S=0}=i.functionQuery,[E]=s,w=E.init?.type||E.type;if("ClassDeclaration"===w||"ClassExpression"===w||"VariableDeclarator"!==E.type&&(i.functionIndex=++i.functionIndex||0,null===S||S===i.functionIndex))k(i,...s)}#u({transform:i,functionQuery:{kind:s}}){if(i)return i;switch(s){case"Async":return"tracePromise";case"Auto":return"traceAuto";case"Callback":return"traceCallback";default:return"traceSync"}}#s(i){let s={};for(let k of i.body)if("ExportNamedDeclaration"===k.type&&!k.source){for(let i of k.specifiers)if(i.exported&&i.local){let k=i.exported.name??i.exported.value,S=i.local.name??i.local.value;k&&S&&(s[k]=S)}}return s}#l(i,s){if(!i.isExportAlias)return i;let{functionName:k,expressionName:S,className:E}=i;return k&&s[k]?{...i,functionName:s[k]}:S&&s[S]?{...i,expressionName:s[S]}:E&&s[E]?{...i,className:s[E]}:i}#c(i){let{functionName:s,expressionName:k,className:S,objectName:E,propertyName:w}=i,C=i.privateMethodName?"PrivateIdentifier":"Identifier",T=[],_=i.methodName||i.privateMethodName;if(S?(_??="constructor",T.push(`[id.name="${S}"]`,`[id.name="${S}"] > ClassExpression`,`[id.name="${S}"] > ClassBody > [key.name="${_}"][key.type=${C}] > [async]`,`[id.name="${S}"] > ClassExpression > ClassBody > [key.name="${_}"][key.type=${C}] > [async]`)):_&&T.push(`ClassBody > [key.name="${_}"][key.type=${C}] > [async]`,`Property[key.name="${_}"][key.type=${C}] > [async]`),s?T.push(`FunctionDeclaration[id.name="${s}"][async]`):k&&T.push(`FunctionExpression[id.name="${k}"][async]`,`ArrowFunctionExpression[id.name="${k}"][async]`,`VariableDeclarator[id.name="${k}"] > FunctionExpression[async]`,`VariableDeclarator[id.name="${k}"] > ArrowFunctionExpression[async]`,`AssignmentExpression[left.property.name="${k}"] > FunctionExpression[async]`,`AssignmentExpression[left.property.name="${k}"] > ArrowFunctionExpression[async]`,`AssignmentExpression[left.name="${k}"] > FunctionExpression[async]`,`AssignmentExpression[left.name="${k}"] > ArrowFunctionExpression[async]`),E||w){if(!E||!w)throw Error(`functionQuery: 'objectName' and 'propertyName' must be used together (got objectName=${E}, propertyName=${w})`);let i="this"===E?"left.object.type=ThisExpression":`left.object.name="${E}"`;T.push(`AssignmentExpression[${i}][left.property.name="${w}"] > [async]`)}return T.join(", ")}};i.exports={Transformer}},"./@apm-js-collab/code-transformer/lib/transforms.js"(i,s,k){"use strict";let S=k("./esquery/dist/esquery.min.js"),{parse:E}=k("./meriyah/dist/meriyah.cjs"),tracingChannelPredicate=i=>i.declarations?.[0]?.id?.properties?.[0]?.value?.name==="tr_ch_apm_tracingChannel",w=/[^\w]/g,formatChannelVariable=i=>`tr_ch_apm$${i.replace(w,"_")}`,C=i.exports={tracingChannelImport({dcModule:i,moduleType:s},k){if(k.body.some(tracingChannelPredicate))return;let S={module:"esm"===s},w=k.body.findIndex(i=>"use strict"===i.directive),C="esm"===s?`import tr_ch_apm_dc from "${i}"`:`const tr_ch_apm_dc = require("${i}")`,T=`const tr_ch_apm_hasSubscribers = ch => ch.start.hasSubscribers
|
|
2
2
|
|| ch.end.hasSubscribers
|
|
3
3
|
|| ch.asyncStart.hasSubscribers
|
|
4
4
|
|| ch.asyncEnd.hasSubscribers
|