dd-trace 6.25.0 → 6.27.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 +3 -0
- package/ci/cypress/support.js +2 -1
- package/ci/vitest-no-worker-init-node-setup.mjs +2 -1
- package/ci/vitest-no-worker-init-runner-setup.mjs +2 -1
- package/ci/vitest-no-worker-init-setup.mjs +729 -724
- package/ci/vitest-no-worker-init-v5-setup.mjs +2 -1
- package/index.d.ts +58 -1
- package/initialize.mjs +5 -3
- package/package.json +36 -32
- package/packages/datadog-esbuild/index.js +8 -15
- package/packages/datadog-esbuild/src/log.js +2 -29
- package/packages/datadog-instrumentations/src/ai.js +88 -122
- package/packages/datadog-instrumentations/src/aws-lambda.js +9 -0
- package/packages/datadog-instrumentations/src/cypress-config.js +20 -9
- package/packages/datadog-instrumentations/src/helpers/bundler-esm-exports.js +23 -1
- package/packages/datadog-instrumentations/src/helpers/bundler-log.js +38 -0
- package/packages/datadog-instrumentations/src/helpers/bundler-transform.js +9 -6
- package/packages/datadog-instrumentations/src/helpers/fetch.js +51 -6
- package/packages/datadog-instrumentations/src/helpers/hooks.js +0 -1
- package/packages/datadog-instrumentations/src/helpers/instrument.js +1 -3
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +6 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +12 -1
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/ai.js +2 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql-jit.js +5 -3
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/modelcontextprotocol-client.js +30 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/modelcontextprotocol-server.js +23 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/next.js +21 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/postgres.js +33 -4
- package/packages/datadog-instrumentations/src/helpers/rewriter/target-patterns.json +30 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +6 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms/postgres.js +122 -0
- package/packages/datadog-instrumentations/src/microgateway-core.js +1 -2
- package/packages/datadog-instrumentations/src/modelcontextprotocol-client.js +21 -0
- package/packages/datadog-instrumentations/src/modelcontextprotocol-sdk.js +32 -2
- package/packages/datadog-instrumentations/src/modelcontextprotocol-server.js +43 -0
- package/packages/datadog-instrumentations/src/next.js +184 -20
- package/packages/datadog-instrumentations/src/path-to-regexp.js +11 -11
- package/packages/datadog-instrumentations/src/router.js +52 -13
- package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +1 -1
- package/packages/datadog-instrumentations/src/vitest-main.js +10 -2
- package/packages/datadog-plugin-aws-lambda/src/arn.js +41 -0
- package/packages/datadog-plugin-aws-lambda/src/context/events.js +167 -0
- package/packages/datadog-plugin-aws-lambda/src/context/extractor.js +153 -0
- package/packages/datadog-plugin-aws-lambda/src/context/http.js +50 -0
- package/packages/datadog-plugin-aws-lambda/src/context/span-context.js +26 -0
- package/packages/datadog-plugin-aws-lambda/src/context/step-functions.js +142 -0
- package/packages/datadog-plugin-aws-lambda/src/context/types.d.ts +17 -0
- package/packages/datadog-plugin-aws-lambda/src/context/xray.js +67 -0
- package/packages/datadog-plugin-aws-lambda/src/event-type-guards.js +170 -0
- package/packages/datadog-plugin-aws-lambda/src/index.js +52 -4
- package/packages/datadog-plugin-aws-lambda/src/trigger.js +339 -0
- package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +7 -0
- package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +32 -10
- package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +10 -1
- package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +4 -0
- package/packages/datadog-plugin-aws-sdk/src/services/stepfunctions.js +3 -0
- package/packages/datadog-plugin-azure-functions/src/index.js +68 -12
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +30 -4
- package/packages/datadog-plugin-cypress/src/support.mjs +1353 -0
- package/packages/datadog-plugin-express/src/code_origin.js +2 -2
- package/packages/datadog-plugin-fastify/src/code_origin.js +2 -2
- package/packages/datadog-plugin-fetch/src/index.js +7 -0
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +10 -0
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +2 -0
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +7 -0
- package/packages/datadog-plugin-google-cloud-pubsub/src/resource-names.js +24 -0
- package/packages/datadog-plugin-graphql/src/tools/transforms.js +1 -0
- package/packages/datadog-plugin-http/src/client.js +14 -1
- package/packages/datadog-plugin-http/src/server.js +18 -4
- package/packages/datadog-plugin-http2/src/client.js +2 -1
- package/packages/datadog-plugin-modelcontextprotocol-sdk/src/tracing.js +28 -2
- package/packages/datadog-plugin-modelcontextprotocol-sdk/src/utils.js +1 -0
- package/packages/datadog-plugin-mongodb-core/src/query.js +17 -1
- package/packages/datadog-plugin-postgres/src/index.js +118 -41
- package/packages/datadog-plugin-supabase/src/supabase-auth-js-gotrueclient-getuser.js +18 -8
- package/packages/datadog-plugin-supabase/src/supabase-functions-js-functionsclient-invoke.js +49 -13
- package/packages/datadog-plugin-supabase/src/supabase-storage-js-handle-request.js +34 -9
- package/packages/datadog-plugin-vitest/src/index.js +3 -2
- package/packages/datadog-plugin-ws/src/close.js +3 -5
- package/packages/datadog-plugin-ws/src/producer.js +1 -4
- package/packages/datadog-plugin-ws/src/receiver.js +3 -5
- package/packages/datadog-plugin-ws/src/server.js +44 -13
- package/packages/datadog-vite/index.js +537 -0
- package/packages/datadog-vite/src/log.js +5 -0
- package/packages/datadog-webpack/src/log.js +2 -29
- package/packages/dd-trace/src/aiguard/client.js +7 -9
- package/packages/dd-trace/src/aiguard/evaluation.js +7 -2
- package/packages/dd-trace/src/aiguard/index.js +1 -1
- package/packages/dd-trace/src/aiguard/integrations/index.js +6 -5
- package/packages/dd-trace/src/aiguard/messages/utils.js +2 -2
- package/packages/dd-trace/src/aiguard/sdk.js +7 -2
- package/packages/dd-trace/src/appsec/api_security/normalized-route.js +273 -167
- package/packages/dd-trace/src/appsec/blocking/index.js +17 -1
- package/packages/dd-trace/src/appsec/channels.js +8 -0
- package/packages/dd-trace/src/appsec/downstream_requests.js +105 -0
- package/packages/dd-trace/src/appsec/graphql.js +10 -13
- package/packages/dd-trace/src/appsec/handlers/auth.js +1 -3
- package/packages/dd-trace/src/appsec/handlers/http-request.js +60 -65
- package/packages/dd-trace/src/appsec/handlers/http-response.js +61 -7
- package/packages/dd-trace/src/appsec/handlers/payments.js +23 -27
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +21 -14
- package/packages/dd-trace/src/appsec/index.js +9 -0
- package/packages/dd-trace/src/appsec/lambda.js +17 -17
- package/packages/dd-trace/src/appsec/rasp/command_injection.js +4 -4
- package/packages/dd-trace/src/appsec/rasp/index.js +64 -3
- package/packages/dd-trace/src/appsec/rasp/lfi.js +2 -2
- package/packages/dd-trace/src/appsec/rasp/sql_injection.js +7 -17
- package/packages/dd-trace/src/appsec/rasp/ssrf.js +80 -16
- package/packages/dd-trace/src/appsec/rasp/utils.js +47 -3
- package/packages/dd-trace/src/appsec/recommended.json +70 -3
- package/packages/dd-trace/src/appsec/reporter.js +9 -0
- package/packages/dd-trace/src/appsec/sdk/set_user.js +3 -3
- package/packages/dd-trace/src/appsec/sdk/track_event.js +4 -4
- package/packages/dd-trace/src/appsec/sdk/user_blocking.js +1 -1
- package/packages/dd-trace/src/appsec/user_tracking.js +6 -8
- package/packages/dd-trace/src/appsec/waf/index.js +65 -6
- package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +33 -38
- package/packages/dd-trace/src/appsec/waf/waf_manager.js +18 -2
- package/packages/dd-trace/src/carrier.js +7 -1
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +4 -2
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +31 -19
- package/packages/dd-trace/src/config/generated-config-types.d.ts +14 -5
- package/packages/dd-trace/src/config/index.js +73 -27
- package/packages/dd-trace/src/config/parsers.js +60 -0
- package/packages/dd-trace/src/config/remote-config-layers.js +38 -0
- package/packages/dd-trace/src/config/remote_config.js +2 -1
- package/packages/dd-trace/src/config/supported-configurations.json +41 -13
- package/packages/dd-trace/src/datastreams/fnv.js +27 -0
- package/packages/dd-trace/src/datastreams/http.js +57 -0
- package/packages/dd-trace/src/datastreams/index.js +24 -0
- package/packages/dd-trace/src/datastreams/pathway.js +142 -28
- package/packages/dd-trace/src/datastreams/processor.js +27 -7
- package/packages/dd-trace/src/debugger/config.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/request-options.js +7 -9
- package/packages/dd-trace/src/debugger/devtools_client/send.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/state.js +3 -1
- package/packages/dd-trace/src/debugger/devtools_client/tags.js +1 -1
- package/packages/dd-trace/src/debugger/index.js +2 -2
- package/packages/dd-trace/src/debugger/inspect-segment.js +3 -2
- package/packages/dd-trace/src/debugger/pause-duration-histogram.js +4 -1
- package/packages/dd-trace/src/debugger/probe_sampler.js +39 -17
- package/packages/dd-trace/src/debugger/unsupported-runtime.js +2 -0
- package/packages/dd-trace/src/git_metadata.js +2 -1
- package/packages/dd-trace/src/index.js +6 -3
- package/packages/dd-trace/src/lambda/facade.js +6 -5
- package/packages/dd-trace/src/lambda/handler-paths.js +1 -1
- package/packages/dd-trace/src/llmobs/constants/tags.js +1 -0
- package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/index.js +86 -3
- package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/utils.js +182 -1
- package/packages/dd-trace/src/llmobs/span_processor.js +3 -0
- package/packages/dd-trace/src/llmobs/tagger.js +9 -0
- package/packages/dd-trace/src/noop/span.js +0 -4
- package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +3 -0
- package/packages/dd-trace/src/openfeature/configuration_source.js +20 -0
- package/packages/dd-trace/src/openfeature/flagging_provider.js +17 -0
- package/packages/dd-trace/src/opentelemetry/logs/otlp_transformer.js +2 -1
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_transformer.js +2 -1
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_transformer_base.js +16 -1
- package/packages/dd-trace/src/opentelemetry/trace/index.js +5 -4
- package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +10 -6
- package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +42 -26
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +4 -4
- package/packages/dd-trace/src/plugin_manager.js +2 -0
- package/packages/dd-trace/src/plugins/ci_plugin.js +104 -9
- package/packages/dd-trace/src/plugins/index.js +2 -0
- package/packages/dd-trace/src/plugins/util/ci.js +34 -0
- package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +9 -14
- package/packages/dd-trace/src/plugins/util/inferred_proxy.js +3 -5
- package/packages/dd-trace/src/plugins/util/test.js +28 -1
- package/packages/dd-trace/src/plugins/util/url.js +9 -6
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +4 -4
- package/packages/dd-trace/src/process-tags/index.js +1 -1
- package/packages/dd-trace/src/profiler.js +74 -12
- package/packages/dd-trace/src/profiling/profiler.js +30 -2
- package/packages/dd-trace/src/profiling/profilers/space.js +3 -1
- package/packages/dd-trace/src/profiling/profilers/wall.js +4 -4
- package/packages/dd-trace/src/profiling/remote-config.js +354 -0
- package/packages/dd-trace/src/profiling/runtime-capabilities.js +11 -0
- package/packages/dd-trace/src/propagation-hash/index.js +7 -0
- package/packages/dd-trace/src/proxy.js +13 -1
- package/packages/dd-trace/src/register-loader.js +43 -0
- package/register.js +10 -44
- package/register.mjs +27 -0
- package/vendor/dist/@opentelemetry/core/LICENSE +11 -0
- package/vendor/dist/@opentelemetry/core/index.js +1 -1
- package/vite.d.ts +7 -0
- package/vite.js +3 -0
- package/lambda.d.ts +0 -39
- package/lambda.js +0 -3
- package/packages/datadog-plugin-cypress/src/support.js +0 -1348
package/packages/datadog-plugin-supabase/src/supabase-functions-js-functionsclient-invoke.js
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const { URL } = require('node:url')
|
|
4
|
+
|
|
3
5
|
const ClientPlugin = require('../../dd-trace/src/plugins/client')
|
|
4
|
-
const {
|
|
6
|
+
const {
|
|
7
|
+
INSTRUMENTATION_HTTP_RESOURCE,
|
|
8
|
+
otelHttpResourceName,
|
|
9
|
+
} = require('../../dd-trace/src/plugins/util/http-otel-semantics')
|
|
10
|
+
const { buildClientHttpUrl, extractPathFromUrl, getQsObfuscator } = require('../../dd-trace/src/plugins/util/url')
|
|
5
11
|
const { stripQueryAndFragment } = require('../../dd-trace/src/util')
|
|
12
|
+
const log = require('../../dd-trace/src/log')
|
|
6
13
|
const normalizeError = require('./error')
|
|
7
14
|
const getHostname = require('./url')
|
|
8
15
|
|
|
9
16
|
/**
|
|
10
17
|
* @typedef {{
|
|
11
|
-
* arguments: { [index: number]: unknown, length: number, 0?: string, 1?: { method?: string } },
|
|
12
|
-
* self: { url: string },
|
|
18
|
+
* arguments: { [index: number]: unknown, length: number, 0?: string, 1?: { method?: string, region?: string } },
|
|
19
|
+
* self: { url: string, region?: string },
|
|
13
20
|
* currentStore?: { span: import('../../..').Span },
|
|
14
21
|
* result?: { error?: Error | { message?: string } | null, response?: { status?: number } },
|
|
15
22
|
* error?: unknown
|
|
@@ -20,24 +27,53 @@ class SupabaseFunctionsClientInvokePlugin extends ClientPlugin {
|
|
|
20
27
|
static id = 'supabase'
|
|
21
28
|
static prefix = 'tracing:orchestrion:@supabase/functions-js:FunctionsClient_invoke'
|
|
22
29
|
|
|
30
|
+
configure (config) {
|
|
31
|
+
if (typeof config === 'boolean') return super.configure(config)
|
|
32
|
+
return super.configure({
|
|
33
|
+
...config,
|
|
34
|
+
queryStringObfuscation: config.DD_TRACE_OTEL_SEMANTICS_ENABLED && getQsObfuscator(config),
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
|
|
23
38
|
/** @param {FunctionsContext} ctx */
|
|
24
39
|
bindStart (ctx) {
|
|
25
40
|
const functionName = ctx.arguments?.[0]
|
|
26
41
|
const method = String(ctx.arguments?.[1]?.method || 'POST').toUpperCase()
|
|
27
|
-
const
|
|
42
|
+
const rawUrl = `${ctx.self?.url}/${functionName}`
|
|
43
|
+
const url = stripQueryAndFragment(rawUrl)
|
|
44
|
+
const otelSemantics = this.config.DD_TRACE_OTEL_SEMANTICS_ENABLED
|
|
45
|
+
const resource = otelSemantics ? otelHttpResourceName(method) : `${method} ${extractPathFromUrl(url)}`
|
|
46
|
+
let httpUrl = url
|
|
47
|
+
if (otelSemantics) {
|
|
48
|
+
try {
|
|
49
|
+
const requestUrl = new URL(rawUrl)
|
|
50
|
+
const region = ctx.arguments?.[1]?.region || ctx.self?.region
|
|
51
|
+
if (region && region !== 'any') {
|
|
52
|
+
requestUrl.searchParams.set('forceFunctionRegion', region)
|
|
53
|
+
}
|
|
54
|
+
requestUrl.hash = ''
|
|
55
|
+
httpUrl = buildClientHttpUrl(this.config, '', requestUrl.href, url)
|
|
56
|
+
} catch (error) {
|
|
57
|
+
log.debug('Could not build Supabase function request URL: %s', error.message)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const meta = {
|
|
61
|
+
component: 'supabase',
|
|
62
|
+
'span.kind': 'client',
|
|
63
|
+
'http.method': method,
|
|
64
|
+
'http.url': httpUrl,
|
|
65
|
+
'out.host': getHostname(url),
|
|
66
|
+
'faas.invoked_name': functionName,
|
|
67
|
+
}
|
|
68
|
+
if (otelSemantics) {
|
|
69
|
+
meta[INSTRUMENTATION_HTTP_RESOURCE] = resource
|
|
70
|
+
}
|
|
28
71
|
|
|
29
72
|
this.startSpan('supabase.http.invoke', {
|
|
30
73
|
service: { name: this.tracer._service },
|
|
31
74
|
type: 'http',
|
|
32
|
-
resource
|
|
33
|
-
meta
|
|
34
|
-
component: 'supabase',
|
|
35
|
-
'span.kind': 'client',
|
|
36
|
-
'http.method': method,
|
|
37
|
-
'http.url': url,
|
|
38
|
-
'out.host': getHostname(url),
|
|
39
|
-
'faas.invoked_name': functionName,
|
|
40
|
-
},
|
|
75
|
+
resource,
|
|
76
|
+
meta,
|
|
41
77
|
}, ctx)
|
|
42
78
|
|
|
43
79
|
return ctx.currentStore
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const StoragePlugin = require('../../dd-trace/src/plugins/storage')
|
|
4
|
-
const {
|
|
4
|
+
const {
|
|
5
|
+
INSTRUMENTATION_HTTP_RESOURCE,
|
|
6
|
+
otelHttpResourceName,
|
|
7
|
+
} = require('../../dd-trace/src/plugins/util/http-otel-semantics')
|
|
8
|
+
const {
|
|
9
|
+
buildClientHttpUrl,
|
|
10
|
+
extractPathFromUrl,
|
|
11
|
+
getQsObfuscator,
|
|
12
|
+
} = require('../../dd-trace/src/plugins/util/url')
|
|
5
13
|
const { stripQueryAndFragment } = require('../../dd-trace/src/util')
|
|
6
14
|
const getHostname = require('./url')
|
|
7
15
|
|
|
@@ -50,22 +58,39 @@ class SupabaseStorageHandleRequestPlugin extends StoragePlugin {
|
|
|
50
58
|
static id = 'supabase'
|
|
51
59
|
static prefix = 'tracing:orchestrion:@supabase/storage-js:handleRequest'
|
|
52
60
|
|
|
61
|
+
configure (config) {
|
|
62
|
+
if (typeof config === 'boolean') return super.configure(config)
|
|
63
|
+
return super.configure({
|
|
64
|
+
...config,
|
|
65
|
+
queryStringObfuscation: config.DD_TRACE_OTEL_SEMANTICS_ENABLED && getQsObfuscator(config),
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
|
|
53
69
|
/** @param {StorageContext} ctx */
|
|
54
70
|
bindStart (ctx) {
|
|
55
71
|
const method = String(ctx.arguments?.[1] || 'GET').toUpperCase()
|
|
56
72
|
const url = ctx.arguments?.[2]
|
|
73
|
+
const rawUrl = String(url)
|
|
74
|
+
const otelSemantics = this.config.DD_TRACE_OTEL_SEMANTICS_ENABLED
|
|
75
|
+
const resource = otelSemantics ? otelHttpResourceName(method) : `${method} ${getStorageRoute(url)}`
|
|
76
|
+
const meta = {
|
|
77
|
+
component: 'supabase',
|
|
78
|
+
'span.kind': 'client',
|
|
79
|
+
'http.method': method,
|
|
80
|
+
'http.url': otelSemantics
|
|
81
|
+
? buildClientHttpUrl(this.config, '', rawUrl, rawUrl)
|
|
82
|
+
: stripQueryAndFragment(rawUrl),
|
|
83
|
+
'out.host': getHostname(url),
|
|
84
|
+
}
|
|
85
|
+
if (otelSemantics) {
|
|
86
|
+
meta[INSTRUMENTATION_HTTP_RESOURCE] = resource
|
|
87
|
+
}
|
|
57
88
|
|
|
58
89
|
this.startSpan('supabase.storage.request', {
|
|
59
90
|
service: { name: this.tracer._service },
|
|
60
91
|
type: 'storage',
|
|
61
|
-
resource
|
|
62
|
-
meta
|
|
63
|
-
component: 'supabase',
|
|
64
|
-
'span.kind': 'client',
|
|
65
|
-
'http.method': method,
|
|
66
|
-
'http.url': stripQueryAndFragment(String(url)),
|
|
67
|
-
'out.host': getHostname(url),
|
|
68
|
-
},
|
|
92
|
+
resource,
|
|
93
|
+
meta,
|
|
69
94
|
}, ctx)
|
|
70
95
|
|
|
71
96
|
return ctx.currentStore
|
|
@@ -96,6 +96,8 @@ class VitestPlugin extends CiPlugin {
|
|
|
96
96
|
constructor (...args) {
|
|
97
97
|
super(...args)
|
|
98
98
|
|
|
99
|
+
this.filterDiBreakpointHitByStack = true
|
|
100
|
+
|
|
99
101
|
this.taskToFinishTime = new WeakMap()
|
|
100
102
|
|
|
101
103
|
this.addSub('ci:vitest:session:configuration', ({ onDone }) => {
|
|
@@ -204,9 +206,8 @@ class VitestPlugin extends CiPlugin {
|
|
|
204
206
|
ctx.parentStore = store
|
|
205
207
|
ctx.currentStore = { ...store, span }
|
|
206
208
|
|
|
207
|
-
// TODO: there might be multiple tests for which mightHitProbe is true, so activeTestSpan
|
|
208
|
-
// might be wrongly overwritten.
|
|
209
209
|
if (mightHitProbe) {
|
|
210
|
+
this.queueDiBreakpointHitSpan(span)
|
|
210
211
|
this.activeTestSpan = span
|
|
211
212
|
}
|
|
212
213
|
|
|
@@ -6,7 +6,6 @@ const {
|
|
|
6
6
|
SPAN_POINTER_DIRECTION,
|
|
7
7
|
SPAN_POINTER_DIRECTION_NAME,
|
|
8
8
|
} = require('../../dd-trace/src/constants')
|
|
9
|
-
const { getSegment } = require('../../dd-trace/src/util')
|
|
10
9
|
const {
|
|
11
10
|
incrementWebSocketCounter,
|
|
12
11
|
buildWebSocketSpanPointerHash,
|
|
@@ -30,12 +29,11 @@ class WSClosePlugin extends TracingPlugin {
|
|
|
30
29
|
|
|
31
30
|
const spanKind = isPeerClose ? 'consumer' : 'producer'
|
|
32
31
|
const spanTags = socket.spanTags
|
|
33
|
-
const path = getSegment(spanTags['resource.name'], ' ', 1)
|
|
34
32
|
const service = this.serviceName({ pluginConfig: this.config })
|
|
35
33
|
const span = this.startSpan(this.operationName(), {
|
|
36
34
|
service,
|
|
37
35
|
meta: {
|
|
38
|
-
'resource.name':
|
|
36
|
+
'resource.name': spanTags.messageResource,
|
|
39
37
|
'span.type': 'websocket',
|
|
40
38
|
'span.kind': spanKind,
|
|
41
39
|
'websocket.close.code': code,
|
|
@@ -48,8 +46,8 @@ class WSClosePlugin extends TracingPlugin {
|
|
|
48
46
|
}
|
|
49
47
|
|
|
50
48
|
if (isPeerClose && traceWebsocketMessagesInheritSampling && traceWebsocketMessagesSeparateTraces) {
|
|
51
|
-
span.setTag('_dd.dm.service', spanTags['service.name']
|
|
52
|
-
span.setTag('_dd.dm.resource', spanTags['resource.name']
|
|
49
|
+
span.setTag('_dd.dm.service', spanTags['service.name'])
|
|
50
|
+
span.setTag('_dd.dm.resource', spanTags['resource.name'])
|
|
53
51
|
span.setTag('_dd.dm.inherited', 1)
|
|
54
52
|
}
|
|
55
53
|
|
|
@@ -6,7 +6,6 @@ const {
|
|
|
6
6
|
SPAN_POINTER_DIRECTION,
|
|
7
7
|
SPAN_POINTER_DIRECTION_NAME,
|
|
8
8
|
} = require('../../dd-trace/src/constants')
|
|
9
|
-
const { getSegment } = require('../../dd-trace/src/util')
|
|
10
9
|
const {
|
|
11
10
|
incrementWebSocketCounter,
|
|
12
11
|
buildWebSocketSpanPointerHash,
|
|
@@ -23,8 +22,6 @@ class WSProducerPlugin extends TracingPlugin {
|
|
|
23
22
|
const { byteLength, socket, binary } = ctx
|
|
24
23
|
if (!socket?.spanContext) return
|
|
25
24
|
|
|
26
|
-
const spanTags = socket.spanTags
|
|
27
|
-
const path = getSegment(spanTags['resource.name'], ' ', 1)
|
|
28
25
|
const opCode = binary ? 'binary' : 'text'
|
|
29
26
|
const service = this.serviceName({ pluginConfig: this.config })
|
|
30
27
|
const span = this.startSpan(this.operationName(), {
|
|
@@ -32,7 +29,7 @@ class WSProducerPlugin extends TracingPlugin {
|
|
|
32
29
|
meta: {
|
|
33
30
|
'span.type': 'websocket',
|
|
34
31
|
'span.kind': 'producer',
|
|
35
|
-
'resource.name':
|
|
32
|
+
'resource.name': socket.spanTags.messageResource,
|
|
36
33
|
'websocket.message.type': opCode,
|
|
37
34
|
|
|
38
35
|
},
|
|
@@ -6,7 +6,6 @@ const {
|
|
|
6
6
|
SPAN_POINTER_DIRECTION,
|
|
7
7
|
SPAN_POINTER_DIRECTION_NAME,
|
|
8
8
|
} = require('../../dd-trace/src/constants')
|
|
9
|
-
const { getSegment } = require('../../dd-trace/src/util')
|
|
10
9
|
const {
|
|
11
10
|
incrementWebSocketCounter,
|
|
12
11
|
buildWebSocketSpanPointerHash,
|
|
@@ -29,7 +28,6 @@ class WSReceiverPlugin extends TracingPlugin {
|
|
|
29
28
|
if (!socket.spanContext) return
|
|
30
29
|
|
|
31
30
|
const spanTags = socket.spanTags
|
|
32
|
-
const path = getSegment(spanTags['resource.name'], ' ', 1)
|
|
33
31
|
const opCode = binary ? 'binary' : 'text'
|
|
34
32
|
|
|
35
33
|
const service = this.serviceName({ pluginConfig: this.config })
|
|
@@ -38,7 +36,7 @@ class WSReceiverPlugin extends TracingPlugin {
|
|
|
38
36
|
meta: {
|
|
39
37
|
'span.type': 'websocket',
|
|
40
38
|
'span.kind': 'consumer',
|
|
41
|
-
'resource.name':
|
|
39
|
+
'resource.name': spanTags.messageResource,
|
|
42
40
|
'websocket.duration.style': 'handler',
|
|
43
41
|
'websocket.message.type': opCode,
|
|
44
42
|
},
|
|
@@ -49,8 +47,8 @@ class WSReceiverPlugin extends TracingPlugin {
|
|
|
49
47
|
}, ctx)
|
|
50
48
|
|
|
51
49
|
if (traceWebsocketMessagesInheritSampling && traceWebsocketMessagesSeparateTraces) {
|
|
52
|
-
span.setTag('_dd.dm.service', spanTags['service.name']
|
|
53
|
-
span.setTag('_dd.dm.resource', spanTags['resource.name']
|
|
50
|
+
span.setTag('_dd.dm.service', spanTags['service.name'])
|
|
51
|
+
span.setTag('_dd.dm.resource', spanTags['resource.name'])
|
|
54
52
|
span.setTag('_dd.dm.inherited', 1)
|
|
55
53
|
}
|
|
56
54
|
|
|
@@ -4,6 +4,12 @@ const TracingPlugin = require('../../dd-trace/src/plugins/tracing.js')
|
|
|
4
4
|
const tags = require('../../../ext/tags.js')
|
|
5
5
|
const { HTTP_HEADERS } = require('../../../ext/formats')
|
|
6
6
|
const { getSegment } = require('../../dd-trace/src/util')
|
|
7
|
+
const { getQsObfuscator, obfuscateQs } = require('../../dd-trace/src/plugins/util/url')
|
|
8
|
+
const {
|
|
9
|
+
INSTRUMENTATION_HTTP_RESOURCE,
|
|
10
|
+
NETWORK_PEER_ADDRESS,
|
|
11
|
+
otelHttpResourceName,
|
|
12
|
+
} = require('../../dd-trace/src/plugins/util/http-otel-semantics')
|
|
7
13
|
const {
|
|
8
14
|
createWebSocketSpanContext,
|
|
9
15
|
hasTraceHeaders,
|
|
@@ -26,6 +32,16 @@ class WSServerPlugin extends TracingPlugin {
|
|
|
26
32
|
this.addBind('tracing:ws:server:connect:setSocket', () => {})
|
|
27
33
|
}
|
|
28
34
|
|
|
35
|
+
/**
|
|
36
|
+
* @param {object} config
|
|
37
|
+
*/
|
|
38
|
+
configure (config) {
|
|
39
|
+
return super.configure({
|
|
40
|
+
...config,
|
|
41
|
+
queryStringObfuscation: config.DD_TRACE_OTEL_SEMANTICS_ENABLED && getQsObfuscator(config),
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
|
|
29
45
|
bindStart (ctx) {
|
|
30
46
|
const req = ctx.req
|
|
31
47
|
|
|
@@ -38,9 +54,13 @@ class WSServerPlugin extends TracingPlugin {
|
|
|
38
54
|
const host = options.headers.host
|
|
39
55
|
const url = req.url
|
|
40
56
|
const indexOfParam = url.indexOf('?')
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const
|
|
57
|
+
const path = indexOfParam === -1 ? url : url.slice(0, indexOfParam)
|
|
58
|
+
const otelSemantics = this.config.DD_TRACE_OTEL_SEMANTICS_ENABLED
|
|
59
|
+
const requestTarget = otelSemantics
|
|
60
|
+
? obfuscateQs(this.config, url)
|
|
61
|
+
: path
|
|
62
|
+
const uri = `${protocol}//${host}${requestTarget}`
|
|
63
|
+
const resourceName = otelSemantics ? otelHttpResourceName(options.method) : `${options.method} ${path}`
|
|
44
64
|
|
|
45
65
|
ctx.args = { options }
|
|
46
66
|
|
|
@@ -48,24 +68,35 @@ class WSServerPlugin extends TracingPlugin {
|
|
|
48
68
|
const childOf = this.tracer.extract(HTTP_HEADERS, req.headers)
|
|
49
69
|
|
|
50
70
|
const service = this.serviceName({ pluginConfig: this.config })
|
|
71
|
+
const meta = {
|
|
72
|
+
'span.type': 'websocket',
|
|
73
|
+
'http.upgraded': 'websocket',
|
|
74
|
+
'http.method': options.method,
|
|
75
|
+
'http.url': uri,
|
|
76
|
+
'resource.name': resourceName,
|
|
77
|
+
'span.kind': 'server',
|
|
78
|
+
}
|
|
79
|
+
if (otelSemantics) {
|
|
80
|
+
meta[INSTRUMENTATION_HTTP_RESOURCE] = resourceName
|
|
81
|
+
|
|
82
|
+
const userAgent = options.headers['user-agent']
|
|
83
|
+
if (userAgent !== undefined) meta['http.useragent'] = userAgent
|
|
84
|
+
|
|
85
|
+
const peerAddress = req.socket?.remoteAddress
|
|
86
|
+
if (peerAddress) meta[NETWORK_PEER_ADDRESS] = peerAddress
|
|
87
|
+
}
|
|
88
|
+
|
|
51
89
|
const span = this.startSpan(this.operationName(), {
|
|
52
90
|
service,
|
|
53
91
|
childOf,
|
|
54
|
-
meta
|
|
55
|
-
'span.type': 'websocket',
|
|
56
|
-
'http.upgraded': 'websocket',
|
|
57
|
-
'http.method': options.method,
|
|
58
|
-
'http.url': uri,
|
|
59
|
-
'resource.name': resourceName,
|
|
60
|
-
'span.kind': 'server',
|
|
61
|
-
},
|
|
62
|
-
|
|
92
|
+
meta,
|
|
63
93
|
}, ctx)
|
|
64
94
|
ctx.span = span
|
|
65
95
|
|
|
66
96
|
ctx.socket.spanTags = {
|
|
97
|
+
messageResource: `websocket ${path}`,
|
|
67
98
|
'resource.name': resourceName,
|
|
68
|
-
'service.name': service,
|
|
99
|
+
'service.name': span.context().getTag('service.name'),
|
|
69
100
|
}
|
|
70
101
|
ctx.socket.spanContext = createWebSocketSpanContext(ctx.span._spanContext)
|
|
71
102
|
ctx.socket.hasTraceHeaders = hasTraceHeaders(req.headers)
|