dd-trace 6.24.0 → 6.25.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 +2 -22
- package/ext/exporters.js +0 -1
- package/index.d.ts +105 -5
- package/initialize.mjs +5 -2
- package/lambda.d.ts +39 -0
- package/lambda.js +3 -0
- package/package.json +11 -9
- package/packages/datadog-esbuild/index.js +8 -55
- package/packages/datadog-instrumentations/src/aws-lambda.js +88 -0
- package/packages/datadog-instrumentations/src/cucumber.js +5 -2
- package/packages/datadog-instrumentations/src/elevenlabs/activity.js +114 -0
- package/packages/datadog-instrumentations/src/elevenlabs/audio.js +104 -0
- package/packages/datadog-instrumentations/src/elevenlabs/index.js +288 -0
- package/packages/datadog-instrumentations/src/elevenlabs/session.js +444 -0
- package/packages/datadog-instrumentations/src/graphql.js +20 -17
- package/packages/{datadog-esbuild/src/utils.js → datadog-instrumentations/src/helpers/bundler-esm-exports.js} +282 -40
- package/packages/datadog-instrumentations/src/helpers/bundler-transform.js +573 -0
- package/packages/datadog-instrumentations/src/helpers/bundler-utils.js +104 -0
- package/packages/datadog-instrumentations/src/helpers/hook.js +29 -1
- package/packages/datadog-instrumentations/src/helpers/hooks.js +3 -7
- package/packages/datadog-instrumentations/src/helpers/lambda-handler.js +189 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +2 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +18 -1
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/async-mutex.js +41 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/elevenlabs.js +25 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql.js +0 -36
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/next.js +40 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/openai-agents-realtime.js +23 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/trpc.js +148 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/target-patterns.json +50 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +17 -3
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +59 -2
- package/packages/datadog-instrumentations/src/ioredis.js +101 -3
- package/packages/datadog-instrumentations/src/next.js +19 -6
- package/packages/datadog-instrumentations/src/openai-agents-realtime.js +149 -0
- package/packages/datadog-instrumentations/src/openai-realtime/audio-accumulator.js +27 -0
- package/packages/datadog-instrumentations/src/openai-realtime/index.js +17 -6
- package/packages/datadog-instrumentations/src/openai-realtime/server-playback.js +887 -0
- package/packages/datadog-instrumentations/src/openai-realtime/session.js +150 -25
- package/packages/datadog-instrumentations/src/openai-realtime/turns.js +29 -2
- package/packages/datadog-instrumentations/src/otel-sdk-trace.js +11 -9
- package/packages/datadog-instrumentations/src/webdriverio.js +12 -12
- package/packages/datadog-plugin-async-mutex/src/index.js +50 -0
- package/packages/datadog-plugin-aws-lambda/src/index.js +106 -0
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +22 -11
- package/packages/datadog-plugin-elevenlabs/src/index.js +69 -0
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +10 -7
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +19 -52
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +4 -2
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-request-context.js +25 -4
- package/packages/datadog-plugin-http/src/client.js +32 -9
- package/packages/datadog-plugin-http2/src/client.js +38 -13
- package/packages/datadog-plugin-next/src/index.js +112 -14
- package/packages/datadog-plugin-prisma/src/datadog-tracing-helper.js +5 -3
- package/packages/datadog-plugin-trpc/src/index.js +15 -0
- package/packages/datadog-plugin-trpc/src/procedure.js +48 -0
- package/packages/datadog-plugin-trpc/src/request.js +81 -0
- package/packages/datadog-plugin-undici/src/index.js +22 -7
- package/packages/datadog-turbopack/index.js +4 -28
- package/packages/datadog-turbopack/src/loader.js +14 -452
- package/packages/datadog-webpack/index.js +3 -55
- package/packages/dd-trace/src/aiguard/evaluation.js +62 -1
- package/packages/dd-trace/src/aiguard/sdk.js +8 -2
- package/packages/dd-trace/src/aiguard/tags.js +2 -0
- package/packages/dd-trace/src/appsec/blocking/index.js +4 -0
- package/packages/dd-trace/src/appsec/graphql.js +91 -6
- package/packages/dd-trace/src/appsec/recommended.json +1287 -90
- package/packages/dd-trace/src/before-exit.js +32 -0
- package/packages/dd-trace/src/bootstrap.js +5 -3
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +15 -2
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +12 -34
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +41 -13
- package/packages/dd-trace/src/ci-visibility/exporters/request.js +2 -3
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +1 -2
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +1 -1
- package/packages/dd-trace/src/ci-visibility/telemetry.js +6 -0
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +1 -1
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache-schema.js +9 -134
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache.js +11 -156
- package/packages/dd-trace/src/config/config-types.d.ts +3 -0
- package/packages/dd-trace/src/config/defaults.js +5 -0
- package/packages/dd-trace/src/config/generated-config-types.d.ts +42 -2
- package/packages/dd-trace/src/config/index.js +17 -5
- package/packages/dd-trace/src/config/parsers.js +9 -0
- package/packages/dd-trace/src/config/supported-configurations.json +158 -4
- package/packages/dd-trace/src/constants.js +1 -0
- package/packages/dd-trace/src/debugger/pause-duration-histogram.js +2 -1
- package/packages/dd-trace/src/exporter.js +0 -11
- package/packages/dd-trace/src/exporters/common/request.js +81 -48
- package/packages/dd-trace/src/exporters/common/retry.js +12 -7
- package/packages/dd-trace/src/exporters/common/url.js +1 -1
- package/packages/dd-trace/src/id.js +1 -1
- package/packages/dd-trace/src/lambda/facade.js +74 -0
- package/packages/dd-trace/src/lambda/handler.js +3 -41
- package/packages/dd-trace/src/lambda/index.js +38 -15
- package/packages/dd-trace/src/lambda/runtime/patch.js +19 -3
- package/packages/dd-trace/src/lambda/wrap.js +44 -0
- package/packages/dd-trace/src/llmobs/constants/tags.js +2 -0
- package/packages/dd-trace/src/llmobs/experiments/experiment.js +10 -5
- package/packages/dd-trace/src/llmobs/plugins/elevenlabs.js +96 -0
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +19 -6
- package/packages/dd-trace/src/llmobs/plugins/openai/realtime.js +38 -11
- package/packages/dd-trace/src/llmobs/plugins/vertexai.js +10 -2
- package/packages/dd-trace/src/llmobs/sdk.js +19 -0
- package/packages/dd-trace/src/llmobs/span_processor.js +9 -0
- package/packages/dd-trace/src/llmobs/tagger.js +22 -0
- package/packages/dd-trace/src/log/channels.js +4 -0
- package/packages/dd-trace/src/log/writer.js +6 -1
- package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +4 -0
- package/packages/dd-trace/src/openfeature/configuration_source.js +35 -27
- package/packages/dd-trace/src/openfeature/flag-selection.js +152 -0
- package/packages/dd-trace/src/openfeature/flagging_provider.js +19 -1
- package/packages/dd-trace/src/openfeature/writers/base.js +1 -3
- package/packages/dd-trace/src/opentelemetry/logs/index.js +11 -0
- package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/metrics/index.js +7 -1
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_exporter.js +4 -1
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +19 -1
- package/packages/dd-trace/src/opentelemetry/span-ending-hook.js +5 -1
- package/packages/dd-trace/src/opentelemetry/span-helpers.js +6 -1
- package/packages/dd-trace/src/opentelemetry/span.js +2 -2
- package/packages/dd-trace/src/opentelemetry/startup-config.js +174 -0
- package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +7 -1
- package/packages/dd-trace/src/opentracing/propagation/tracestate.js +77 -23
- package/packages/dd-trace/src/opentracing/tracer.js +24 -0
- package/packages/dd-trace/src/otel-thread-ctx.js +28 -31
- package/packages/dd-trace/src/plugin_manager.js +34 -7
- package/packages/dd-trace/src/plugins/ci_plugin.js +41 -10
- package/packages/dd-trace/src/plugins/index.js +6 -0
- package/packages/dd-trace/src/plugins/plugin.js +4 -2
- package/packages/dd-trace/src/plugins/tracing.js +1 -1
- package/packages/dd-trace/src/plugins/util/ci.js +18 -1
- package/packages/dd-trace/src/plugins/util/git-cache.js +4 -4
- package/packages/dd-trace/src/plugins/util/git.js +263 -82
- package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +75 -46
- package/packages/dd-trace/src/plugins/util/inferred_proxy.js +12 -4
- package/packages/dd-trace/src/plugins/util/status-validator.js +23 -10
- package/packages/dd-trace/src/plugins/util/tags.js +6 -0
- package/packages/dd-trace/src/plugins/util/test.js +64 -39
- package/packages/dd-trace/src/plugins/util/url.js +10 -2
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +2 -2
- package/packages/dd-trace/src/plugins/util/web.js +65 -10
- package/packages/dd-trace/src/profiling/webspan-utils.js +6 -5
- package/packages/dd-trace/src/proxy.js +33 -53
- package/packages/dd-trace/src/span_processor.js +20 -0
- package/packages/dd-trace/src/startup-log.js +8 -6
- package/packages/dd-trace/src/telemetry/metrics.js +2 -1
- package/packages/dd-trace/src/tracer.js +0 -2
- package/packages/dd-trace/src/web-tags-cache.js +8 -9
- package/register.js +2 -1
- package/vendor/dist/@apm-js-collab/code-transformer/LICENSE +489 -0
- package/vendor/dist/@datadog/flagging-core/LICENSE +221 -0
- package/vendor/dist/@datadog/flagging-core/index.js +1 -0
- package/vendor/dist/@datadog/openfeature-node-server/LICENSE +21 -1
- package/vendor/dist/@datadog/openfeature-node-server/rules-based/LICENSE +3 -1
- package/vendor/dist/@datadog/sketches-js/LICENSE +263 -0
- package/vendor/dist/@datadog/source-map/LICENSE +1 -0
- package/vendor/dist/@isaacs/ttlcache/LICENSE +13 -0
- package/vendor/dist/@opentelemetry/core/LICENSE +209 -1
- package/vendor/dist/crypto-randomuuid/LICENSE +3 -0
- package/vendor/dist/escape-string-regexp/LICENSE +13 -0
- package/vendor/dist/esquery/LICENSE +2 -0
- package/vendor/dist/https-proxy-agent/LICENSE +80 -1
- package/vendor/dist/istanbul-lib-coverage/LICENSE +2 -0
- package/vendor/dist/jest-docblock/LICENSE +16 -0
- package/vendor/dist/jsonpath-plus/LICENSE +13 -0
- package/vendor/dist/limiter/LICENSE +2 -0
- package/vendor/dist/lodash.sortby/LICENSE +2 -0
- package/vendor/dist/lru-cache/LICENSE +13 -0
- package/vendor/dist/meriyah/LICENSE +13 -0
- package/vendor/dist/module-details-from-path/LICENSE +2 -0
- package/vendor/dist/mutexify/promise/LICENSE +28 -0
- package/vendor/dist/pprof-format/LICENSE +13 -0
- package/vendor/dist/pprof-format/index.js +1 -1
- package/vendor/dist/protobufjs/LICENSE +219 -0
- package/vendor/dist/protobufjs/minimal/LICENSE +219 -0
- package/vendor/dist/proxy-from-env/LICENSE +13 -0
- package/vendor/dist/retry/LICENSE +2 -0
- package/vendor/dist/rfdc/LICENSE +2 -0
- package/vendor/dist/semifies/LICENSE +3 -1
- package/vendor/dist/shell-quote/LICENSE +3 -1
- package/vendor/dist/source-map/LICENSE +1 -0
- package/vendor/dist/source-map/lib/util/LICENSE +1 -0
- package/vendor/dist/tlhunter-sorted-set/LICENSE +2 -0
- package/vendor/dist/ttl-set/LICENSE +28 -0
- package/ci/diagnose.js +0 -2215
- package/ci/runbook.md +0 -299
- package/ci/test-optimization-validation/approval-artifacts.js +0 -175
- package/ci/test-optimization-validation/approval.js +0 -386
- package/ci/test-optimization-validation/artifact-id.js +0 -18
- package/ci/test-optimization-validation/blocker-category.js +0 -24
- package/ci/test-optimization-validation/bounded-json.js +0 -120
- package/ci/test-optimization-validation/ci-command-candidate.js +0 -77
- package/ci/test-optimization-validation/ci-discovery.js +0 -192
- package/ci/test-optimization-validation/ci-package-scripts.js +0 -169
- package/ci/test-optimization-validation/ci-remediation.js +0 -283
- package/ci/test-optimization-validation/cli.js +0 -954
- package/ci/test-optimization-validation/command-blocker.js +0 -377
- package/ci/test-optimization-validation/command-output-policy.js +0 -188
- package/ci/test-optimization-validation/command-runner.js +0 -649
- package/ci/test-optimization-validation/environment.js +0 -88
- package/ci/test-optimization-validation/executable-approval.js +0 -47
- package/ci/test-optimization-validation/executable.js +0 -244
- package/ci/test-optimization-validation/execution-lock.js +0 -70
- package/ci/test-optimization-validation/framework-adapters/cucumber-validation.json +0 -3
- package/ci/test-optimization-validation/framework-adapters/cucumber.js +0 -767
- package/ci/test-optimization-validation/framework-adapters/cypress.js +0 -99
- package/ci/test-optimization-validation/framework-adapters/playwright.js +0 -175
- package/ci/test-optimization-validation/framework-adapters/vitest.js +0 -513
- package/ci/test-optimization-validation/generated-file-policy.js +0 -63
- package/ci/test-optimization-validation/generated-files.js +0 -425
- package/ci/test-optimization-validation/generated-test-contract.js +0 -284
- package/ci/test-optimization-validation/generated-verifier.js +0 -235
- package/ci/test-optimization-validation/literal-environment.js +0 -56
- package/ci/test-optimization-validation/literal-glob.js +0 -52
- package/ci/test-optimization-validation/manifest-loader.js +0 -116
- package/ci/test-optimization-validation/manifest-scaffold.js +0 -1276
- package/ci/test-optimization-validation/manifest-schema.js +0 -695
- package/ci/test-optimization-validation/offline-fixtures.js +0 -335
- package/ci/test-optimization-validation/offline-output.js +0 -406
- package/ci/test-optimization-validation/package-check.js +0 -97
- package/ci/test-optimization-validation/payload-normalizer.js +0 -72
- package/ci/test-optimization-validation/plan-writer.js +0 -541
- package/ci/test-optimization-validation/preflight-runner.js +0 -186
- package/ci/test-optimization-validation/project-build-artifact.js +0 -31
- package/ci/test-optimization-validation/redaction.js +0 -319
- package/ci/test-optimization-validation/report-writer.js +0 -666
- package/ci/test-optimization-validation/result-semantics.js +0 -103
- package/ci/test-optimization-validation/runner-command.js +0 -264
- package/ci/test-optimization-validation/runner-contract.js +0 -695
- package/ci/test-optimization-validation/safe-files.js +0 -202
- package/ci/test-optimization-validation/scenarios/auto-test-retries.js +0 -171
- package/ci/test-optimization-validation/scenarios/basic-reporting.js +0 -407
- package/ci/test-optimization-validation/scenarios/ci-wiring.js +0 -666
- package/ci/test-optimization-validation/scenarios/early-flake-detection.js +0 -142
- package/ci/test-optimization-validation/scenarios/helpers.js +0 -621
- package/ci/test-optimization-validation/scenarios/test-management.js +0 -219
- package/ci/test-optimization-validation/source-text.js +0 -84
- package/ci/test-optimization-validation/static-diagnosis.js +0 -166
- package/ci/test-optimization-validation/test-output.js +0 -120
- package/ci/test-optimization-validation/validation-blocker.js +0 -21
- package/ci/validate-test-optimization.js +0 -3
- package/packages/datadog-esbuild/src/resolver.js +0 -284
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/index.js +0 -156
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/msgpack-to-json.js +0 -287
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/payload-projection.js +0 -84
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/sink.js +0 -368
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/writer.js +0 -59
|
@@ -99,6 +99,8 @@ const {
|
|
|
99
99
|
const { ORIGIN_KEY, COMPONENT } = require('../../dd-trace/src/constants')
|
|
100
100
|
const { RESOURCE_NAME } = require('../../../ext/tags')
|
|
101
101
|
const getConfig = require('../../dd-trace/src/config')
|
|
102
|
+
const { getRepositoryRoot } = require('../../dd-trace/src/plugins/util/git')
|
|
103
|
+
const { getUserProviderGitMetadata } = require('../../dd-trace/src/plugins/util/user-provided-git')
|
|
102
104
|
const { getValueFromEnvSources } = require('../../dd-trace/src/config/helper')
|
|
103
105
|
const {
|
|
104
106
|
SCREENSHOT_UPLOAD_RESULT_ERROR,
|
|
@@ -134,7 +136,8 @@ const {
|
|
|
134
136
|
GIT_COMMIT_SHA,
|
|
135
137
|
GIT_BRANCH,
|
|
136
138
|
CI_PROVIDER_NAME,
|
|
137
|
-
|
|
139
|
+
GIT_CHECKOUT_ROOT,
|
|
140
|
+
GIT_CHECKOUT_IS_CUSTOM,
|
|
138
141
|
GIT_COMMIT_MESSAGE,
|
|
139
142
|
GIT_TAG,
|
|
140
143
|
GIT_PULL_REQUEST_BASE_BRANCH_SHA,
|
|
@@ -361,17 +364,20 @@ function getTestManagementTests (tracer, testConfiguration) {
|
|
|
361
364
|
})
|
|
362
365
|
}
|
|
363
366
|
|
|
364
|
-
function getModifiedFiles (testEnvironmentMetadata) {
|
|
367
|
+
function getModifiedFiles (testEnvironmentMetadata, gitRoot) {
|
|
368
|
+
const isCustomCheckout = testEnvironmentMetadata[GIT_CHECKOUT_IS_CUSTOM] === 'true'
|
|
369
|
+
const diffMetadata = isCustomCheckout ? getUserProviderGitMetadata() : testEnvironmentMetadata
|
|
365
370
|
const {
|
|
366
371
|
[GIT_PULL_REQUEST_BASE_BRANCH]: pullRequestBaseBranch,
|
|
367
372
|
[GIT_PULL_REQUEST_BASE_BRANCH_SHA]: pullRequestBaseBranchSha,
|
|
368
373
|
[GIT_COMMIT_HEAD_SHA]: commitHeadSha,
|
|
369
|
-
} =
|
|
374
|
+
} = diffMetadata
|
|
375
|
+
const targetCommit = commitHeadSha || (isCustomCheckout ? testEnvironmentMetadata[GIT_COMMIT_SHA] : undefined)
|
|
370
376
|
|
|
371
|
-
const baseBranchSha = pullRequestBaseBranchSha || getPullRequestBaseBranch(pullRequestBaseBranch)
|
|
377
|
+
const baseBranchSha = pullRequestBaseBranchSha || getPullRequestBaseBranch(pullRequestBaseBranch, gitRoot)
|
|
372
378
|
|
|
373
379
|
if (baseBranchSha) {
|
|
374
|
-
const diff = getPullRequestDiff(baseBranchSha,
|
|
380
|
+
const diff = getPullRequestDiff(baseBranchSha, targetCommit, gitRoot)
|
|
375
381
|
const modifiedFiles = getModifiedFilesFromDiff(diff)
|
|
376
382
|
if (modifiedFiles) {
|
|
377
383
|
return modifiedFiles
|
|
@@ -579,7 +585,8 @@ class CypressPlugin {
|
|
|
579
585
|
[RUNTIME_VERSION]: runtimeVersion,
|
|
580
586
|
[GIT_BRANCH]: branch,
|
|
581
587
|
[CI_PROVIDER_NAME]: ciProviderName,
|
|
582
|
-
[
|
|
588
|
+
[GIT_CHECKOUT_ROOT]: gitRoot,
|
|
589
|
+
[GIT_CHECKOUT_IS_CUSTOM]: isCustomCheckout,
|
|
583
590
|
[GIT_COMMIT_MESSAGE]: commitMessage,
|
|
584
591
|
[GIT_TAG]: tag,
|
|
585
592
|
[GIT_PULL_REQUEST_BASE_BRANCH_SHA]: pullRequestBaseSha,
|
|
@@ -587,13 +594,14 @@ class CypressPlugin {
|
|
|
587
594
|
[GIT_COMMIT_HEAD_MESSAGE]: commitHeadMessage,
|
|
588
595
|
} = this.testEnvironmentMetadata
|
|
589
596
|
|
|
590
|
-
this.repositoryRoot =
|
|
597
|
+
this.repositoryRoot = gitRoot || getRepositoryRoot() || process.cwd()
|
|
591
598
|
this.ciProviderName = ciProviderName
|
|
592
|
-
this.codeOwnersEntries = getCodeOwnersFileEntries(repositoryRoot)
|
|
599
|
+
this.codeOwnersEntries = getCodeOwnersFileEntries(this.repositoryRoot)
|
|
593
600
|
|
|
594
601
|
this.testConfiguration = {
|
|
595
602
|
repositoryUrl,
|
|
596
603
|
sha,
|
|
604
|
+
gitRoot: this.repositoryRoot,
|
|
597
605
|
osVersion,
|
|
598
606
|
osPlatform,
|
|
599
607
|
osArchitecture,
|
|
@@ -604,8 +612,11 @@ class CypressPlugin {
|
|
|
604
612
|
commitMessage,
|
|
605
613
|
tag,
|
|
606
614
|
pullRequestBaseSha,
|
|
607
|
-
|
|
608
|
-
|
|
615
|
+
// Only an explicit PR head can override the selected commit in a custom checkout.
|
|
616
|
+
commitHeadSha: isCustomCheckout === 'true'
|
|
617
|
+
? getUserProviderGitMetadata()[GIT_COMMIT_HEAD_SHA]
|
|
618
|
+
: commitHeadSha,
|
|
619
|
+
commitHeadMessage: isCustomCheckout === 'true' ? undefined : commitHeadMessage,
|
|
609
620
|
}
|
|
610
621
|
}
|
|
611
622
|
|
|
@@ -1439,7 +1450,7 @@ class CypressPlugin {
|
|
|
1439
1450
|
|
|
1440
1451
|
if (this.isImpactedTestsEnabled) {
|
|
1441
1452
|
try {
|
|
1442
|
-
this.modifiedFiles = getModifiedFiles(this.testEnvironmentMetadata)
|
|
1453
|
+
this.modifiedFiles = getModifiedFiles(this.testEnvironmentMetadata, this.repositoryRoot)
|
|
1443
1454
|
} catch (error) {
|
|
1444
1455
|
log.error(error)
|
|
1445
1456
|
this.isImpactedTestsEnabled = false
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { channel } = require('dc-polyfill')
|
|
4
|
+
|
|
5
|
+
const { storage } = require('../../datadog-core')
|
|
6
|
+
const ElevenLabsLLMObsPlugin = require('../../dd-trace/src/llmobs/plugins/elevenlabs')
|
|
7
|
+
const CompositePlugin = require('../../dd-trace/src/plugins/composite')
|
|
8
|
+
const TracingPlugin = require('../../dd-trace/src/plugins/tracing')
|
|
9
|
+
|
|
10
|
+
const annotate = channel('apm:elevenlabs:annotate')
|
|
11
|
+
|
|
12
|
+
/** @typedef {import('../../datadog-instrumentations/src/elevenlabs/session').Scope} Scope */
|
|
13
|
+
/** @typedef {import('../../datadog-core/src/storage').Store<unknown>} Store */
|
|
14
|
+
|
|
15
|
+
class ElevenLabsTracingPlugin extends TracingPlugin {
|
|
16
|
+
static id = 'elevenlabs'
|
|
17
|
+
static prefix = 'tracing:apm:elevenlabs:span'
|
|
18
|
+
|
|
19
|
+
constructor (...args) {
|
|
20
|
+
super(...args)
|
|
21
|
+
this.addSub('dd-trace:elevenlabs:capture-context', message => {
|
|
22
|
+
const scope = /** @type {Scope} */ (message)
|
|
23
|
+
// An absent store intentionally restores an explicit root context.
|
|
24
|
+
const store = /** @type {Store} */ (storage('legacy').getStore())
|
|
25
|
+
const previous = scope.runInContext ?? (fn => fn())
|
|
26
|
+
scope.runInContext = fn => previous(() => storage('legacy').run(store, fn))
|
|
27
|
+
})
|
|
28
|
+
this.addSub('apm:elevenlabs:finish', ctx => this.finish(ctx))
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** @param {object} ctx */
|
|
32
|
+
bindStart (ctx) {
|
|
33
|
+
this.startSpan('elevenlabs.request', {
|
|
34
|
+
service: this.config.service,
|
|
35
|
+
resource: ctx.name,
|
|
36
|
+
type: 'llm',
|
|
37
|
+
kind: 'client',
|
|
38
|
+
startTime: ctx.startTime,
|
|
39
|
+
}, ctx)
|
|
40
|
+
return ctx.currentStore
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** @param {object} ctx */
|
|
44
|
+
end (ctx) { if (!ctx.deferred) this.finish(ctx) }
|
|
45
|
+
|
|
46
|
+
/** @param {object} ctx */
|
|
47
|
+
finish (ctx) {
|
|
48
|
+
if (ctx.finished) return
|
|
49
|
+
const span = ctx.currentStore?.span
|
|
50
|
+
// Configuration changes can reorder subscribers. Keep deferred spans, speech phases, and
|
|
51
|
+
// asynchronous tools annotated before serialization through one explicit completion owner.
|
|
52
|
+
annotate.publish(ctx)
|
|
53
|
+
if (ctx.error) this.addError(ctx.error, span)
|
|
54
|
+
if (ctx.turn.failed && ['elevenlabs audio turn', 'elevenlabs response'].includes(ctx.name)) {
|
|
55
|
+
span?.setTag('error', 1)
|
|
56
|
+
}
|
|
57
|
+
span?.finish(ctx.finishTime)
|
|
58
|
+
ctx.finished = true
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
class ElevenLabsPlugin extends CompositePlugin {
|
|
63
|
+
static id = 'elevenlabs'
|
|
64
|
+
static get plugins () {
|
|
65
|
+
return { llmobs: ElevenLabsLLMObsPlugin, tracing: ElevenLabsTracingPlugin }
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
module.exports = ElevenLabsPlugin
|
|
@@ -104,9 +104,12 @@ class GoogleCloudPubsubConsumerPlugin extends ConsumerPlugin {
|
|
|
104
104
|
|
|
105
105
|
let childOf = this.tracer.extract('text_map', message.attributes)
|
|
106
106
|
|
|
107
|
+
let pubsubRequestContext
|
|
107
108
|
const isFirstMessage = batchIndex === 0
|
|
108
109
|
if (isFirstMessage && batchRequestSpanId) {
|
|
109
|
-
|
|
110
|
+
pubsubRequestContext = reconstructPubSubRequestContext(
|
|
111
|
+
message.attributes, childOf, this._tracerConfig.DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT
|
|
112
|
+
)
|
|
110
113
|
if (pubsubRequestContext) {
|
|
111
114
|
childOf = pubsubRequestContext
|
|
112
115
|
}
|
|
@@ -125,14 +128,12 @@ class GoogleCloudPubsubConsumerPlugin extends ConsumerPlugin {
|
|
|
125
128
|
'messaging.operation': 'receive',
|
|
126
129
|
}
|
|
127
130
|
|
|
131
|
+
let batchContext
|
|
128
132
|
if (batchRequestTraceId && batchRequestSpanId) {
|
|
129
133
|
meta['pubsub.batch.request_trace_id'] = batchRequestTraceId
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
span_id: batchRequestSpanId,
|
|
134
|
-
flags: 0,
|
|
135
|
-
}])
|
|
134
|
+
batchContext = pubsubRequestContext || reconstructPubSubRequestContext(
|
|
135
|
+
message.attributes, null, this._tracerConfig.DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT
|
|
136
|
+
)
|
|
136
137
|
}
|
|
137
138
|
|
|
138
139
|
const metrics = {
|
|
@@ -161,6 +162,8 @@ class GoogleCloudPubsubConsumerPlugin extends ConsumerPlugin {
|
|
|
161
162
|
metrics,
|
|
162
163
|
}, ctx)
|
|
163
164
|
|
|
165
|
+
if (batchContext) span.addLink({ context: batchContext })
|
|
166
|
+
|
|
164
167
|
if (message.publishTime) {
|
|
165
168
|
span.setTag('pubsub.publish_time', message.publishTime.toISOString())
|
|
166
169
|
}
|
|
@@ -5,12 +5,10 @@ const {
|
|
|
5
5
|
readDatadogSamplingPriority,
|
|
6
6
|
readDatadogTraceId,
|
|
7
7
|
readTraceparent,
|
|
8
|
-
writeDatadogParentId,
|
|
9
|
-
writeDatadogSamplingPriority,
|
|
10
|
-
writeDatadogTraceId,
|
|
11
8
|
} = require('../../dd-trace/src/carrier')
|
|
12
9
|
const { DsmPathwayCodec, getHeadersSize } = require('../../dd-trace/src/datastreams')
|
|
13
10
|
const id = require('../../dd-trace/src/id')
|
|
11
|
+
const SpanContext = require('../../dd-trace/src/opentracing/span_context')
|
|
14
12
|
const ProducerPlugin = require('../../dd-trace/src/plugins/producer')
|
|
15
13
|
|
|
16
14
|
class GoogleCloudPubsubProducerPlugin extends ProducerPlugin {
|
|
@@ -71,6 +69,9 @@ class GoogleCloudPubsubProducerPlugin extends ProducerPlugin {
|
|
|
71
69
|
const topic = request.topic
|
|
72
70
|
const messageCount = messages.length
|
|
73
71
|
const hasTraceContext = messages[0]?.attributes && readDatadogTraceId(messages[0].attributes)
|
|
72
|
+
const parentContext = hasTraceContext && readDatadogParentId(messages[0].attributes)
|
|
73
|
+
? this.tracer.extract('text_map', messages[0].attributes)
|
|
74
|
+
: undefined
|
|
74
75
|
|
|
75
76
|
/**
|
|
76
77
|
* Batch Publishing Strategy:
|
|
@@ -81,30 +82,18 @@ class GoogleCloudPubsubProducerPlugin extends ProducerPlugin {
|
|
|
81
82
|
* - Inject batch span context + metadata into all message attributes for downstream
|
|
82
83
|
* consumers to reconstruct the trace and understand batch relationships
|
|
83
84
|
*/
|
|
84
|
-
const
|
|
85
|
+
const spanLinks = []
|
|
85
86
|
if (hasTraceContext) {
|
|
86
87
|
for (let i = 1; i < messageCount; i++) {
|
|
87
88
|
const link = this.#extractSpanLink(messages[i].attributes)
|
|
88
|
-
if (link)
|
|
89
|
+
if (link) spanLinks.push(link)
|
|
89
90
|
}
|
|
90
91
|
}
|
|
91
92
|
|
|
92
|
-
const firstAttrs = messages[0]?.attributes
|
|
93
|
-
const traceId = firstAttrs && readDatadogTraceId(firstAttrs)
|
|
94
|
-
const spanId = firstAttrs && readDatadogParentId(firstAttrs)
|
|
95
|
-
const parentData = traceId && spanId
|
|
96
|
-
? {
|
|
97
|
-
traceId,
|
|
98
|
-
spanId,
|
|
99
|
-
traceIdUpper: firstAttrs['_dd.p.tid'],
|
|
100
|
-
samplingPriority: readDatadogSamplingPriority(firstAttrs),
|
|
101
|
-
}
|
|
102
|
-
: null
|
|
103
|
-
|
|
104
93
|
const lastSlash = topic.lastIndexOf('/')
|
|
105
94
|
const topicName = lastSlash === -1 ? topic : topic.slice(lastSlash + 1)
|
|
106
95
|
const batchSpan = this.startSpan({
|
|
107
|
-
childOf:
|
|
96
|
+
childOf: parentContext,
|
|
108
97
|
resource: `${api} to Topic ${topicName}`,
|
|
109
98
|
meta: {
|
|
110
99
|
'gcloud.project_id': projectId,
|
|
@@ -113,7 +102,7 @@ class GoogleCloudPubsubProducerPlugin extends ProducerPlugin {
|
|
|
113
102
|
'span.kind': 'producer',
|
|
114
103
|
'_dd.base_service': this.tracer._service,
|
|
115
104
|
'_dd.serviceoverride.type': 'integration',
|
|
116
|
-
'pubsub.linked_message_count':
|
|
105
|
+
'pubsub.linked_message_count': spanLinks.length || undefined,
|
|
117
106
|
operation: messageCount > 1 ? 'batched.pubsub.request' : 'pubsub.request',
|
|
118
107
|
},
|
|
119
108
|
metrics: {
|
|
@@ -130,15 +119,7 @@ class GoogleCloudPubsubProducerPlugin extends ProducerPlugin {
|
|
|
130
119
|
const batchTraceIdHex = fullTraceIdHex.slice(-16)
|
|
131
120
|
const batchTraceIdUpper = spanCtx._trace.tags['_dd.p.tid']
|
|
132
121
|
|
|
133
|
-
if (
|
|
134
|
-
batchSpan.setTag('_dd.span_links', JSON.stringify(
|
|
135
|
-
spanLinkData.map(link => ({
|
|
136
|
-
trace_id: link.traceId,
|
|
137
|
-
span_id: link.spanId,
|
|
138
|
-
flags: link.samplingPriority || 0,
|
|
139
|
-
}))
|
|
140
|
-
))
|
|
141
|
-
}
|
|
122
|
+
if (spanLinks.length) batchSpan.addLinks(spanLinks)
|
|
142
123
|
|
|
143
124
|
const messageCountStr = String(messageCount)
|
|
144
125
|
const startTimeStr = String(Math.floor(batchSpan._startTime))
|
|
@@ -189,34 +170,20 @@ class GoogleCloudPubsubProducerPlugin extends ProducerPlugin {
|
|
|
189
170
|
const spanId = readDatadogParentId(attrs)
|
|
190
171
|
if (!traceId || !spanId) return null
|
|
191
172
|
|
|
192
|
-
// Convert to hex strings
|
|
193
|
-
const lowerHex = id(traceId).toString(16)
|
|
194
|
-
const spanIdHex = id(spanId).toString(16)
|
|
195
|
-
|
|
196
|
-
// Build full 128-bit trace ID
|
|
197
|
-
const traceIdHex = attrs['_dd.p.tid']
|
|
198
|
-
? attrs['_dd.p.tid'] + lowerHex
|
|
199
|
-
: lowerHex.padStart(32, '0')
|
|
200
|
-
|
|
201
173
|
const samplingPriority = readDatadogSamplingPriority(attrs)
|
|
202
174
|
return {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
? Number.parseInt(samplingPriority, 10)
|
|
207
|
-
:
|
|
175
|
+
context: new SpanContext({
|
|
176
|
+
traceId: id(traceId, 10),
|
|
177
|
+
spanId: id(spanId, 10),
|
|
178
|
+
sampling: { priority: samplingPriority ? Number.parseInt(samplingPriority, 10) : 0 },
|
|
179
|
+
trace: {
|
|
180
|
+
started: [],
|
|
181
|
+
finished: [],
|
|
182
|
+
tags: attrs['_dd.p.tid'] ? { '_dd.p.tid': attrs['_dd.p.tid'] } : {},
|
|
183
|
+
},
|
|
184
|
+
}),
|
|
208
185
|
}
|
|
209
186
|
}
|
|
210
|
-
|
|
211
|
-
#extractParentContext (data) {
|
|
212
|
-
const carrier = /** @type {Record<string, unknown>} */ ({})
|
|
213
|
-
writeDatadogTraceId(carrier, data.traceId)
|
|
214
|
-
writeDatadogParentId(carrier, data.spanId)
|
|
215
|
-
if (data.traceIdUpper) carrier['_dd.p.tid'] = data.traceIdUpper
|
|
216
|
-
if (data.samplingPriority) writeDatadogSamplingPriority(carrier, String(data.samplingPriority))
|
|
217
|
-
|
|
218
|
-
return this.tracer.extract('text_map', carrier)
|
|
219
|
-
}
|
|
220
187
|
}
|
|
221
188
|
|
|
222
189
|
module.exports = GoogleCloudPubsubProducerPlugin
|
|
@@ -68,9 +68,11 @@ class GoogleCloudPubsubPushSubscriptionPlugin extends TracingPlugin {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
const originalContext = this.#extractContext(messageData)
|
|
71
|
-
const pubsubRequestContext = reconstructPubSubRequestContext(
|
|
71
|
+
const pubsubRequestContext = reconstructPubSubRequestContext(
|
|
72
|
+
messageData.attrs, originalContext, this._tracerConfig.DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT
|
|
73
|
+
) || originalContext
|
|
72
74
|
const isSameTrace = pubsubRequestContext &&
|
|
73
|
-
originalContext?.toTraceId() === pubsubRequestContext.toTraceId()
|
|
75
|
+
originalContext?.toTraceId(true) === pubsubRequestContext.toTraceId(true)
|
|
74
76
|
|
|
75
77
|
/**
|
|
76
78
|
* Create receive span, choosing parent context:
|
|
@@ -5,9 +5,11 @@ const id = require('../../dd-trace/src/id')
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @param {Record<string, string>} attributes
|
|
8
|
+
* @param {SpanContext | null | undefined} originalContext
|
|
9
|
+
* @param {import('../../dd-trace/src/config/config-base')['DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT']} propagationBehavior
|
|
8
10
|
* @returns {import('../../dd-trace/src/opentracing/span_context') | null}
|
|
9
11
|
*/
|
|
10
|
-
function reconstructPubSubRequestContext (attributes) {
|
|
12
|
+
function reconstructPubSubRequestContext (attributes, originalContext, propagationBehavior) {
|
|
11
13
|
const traceIdLower = attributes['_dd.pubsub_request.trace_id']
|
|
12
14
|
const spanId = attributes['_dd.pubsub_request.span_id']
|
|
13
15
|
const traceIdUpper = attributes['_dd.pubsub_request.p.tid']
|
|
@@ -15,16 +17,35 @@ function reconstructPubSubRequestContext (attributes) {
|
|
|
15
17
|
if (!traceIdLower || !spanId) return null
|
|
16
18
|
|
|
17
19
|
const traceId128 = traceIdUpper ? traceIdUpper + traceIdLower : traceIdLower.padStart(32, '0')
|
|
18
|
-
const traceId = id(traceId128, 16)
|
|
19
20
|
const parentId = id(spanId, 16)
|
|
20
21
|
|
|
22
|
+
if (originalContext?.toTraceId(true) === traceId128) {
|
|
23
|
+
if (propagationBehavior !== 'restart') {
|
|
24
|
+
originalContext._spanId = parentId
|
|
25
|
+
return originalContext
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Restart links reference the extracted context, so preserve its original span ID.
|
|
29
|
+
return new SpanContext({
|
|
30
|
+
traceId: originalContext._traceId,
|
|
31
|
+
spanId: parentId,
|
|
32
|
+
isRemote: originalContext._isRemote,
|
|
33
|
+
sampling: originalContext._sampling,
|
|
34
|
+
baggageItems: originalContext._baggageItems,
|
|
35
|
+
trace: originalContext._trace,
|
|
36
|
+
traceparent: originalContext._traceparent,
|
|
37
|
+
tracestate: originalContext._tracestate,
|
|
38
|
+
links: originalContext._links,
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
|
|
21
42
|
const tags = {}
|
|
22
43
|
if (traceIdUpper) tags['_dd.p.tid'] = traceIdUpper
|
|
23
44
|
|
|
24
45
|
return new SpanContext({
|
|
25
|
-
traceId,
|
|
46
|
+
traceId: id(traceId128, 16),
|
|
26
47
|
spanId: parentId,
|
|
27
|
-
tags,
|
|
48
|
+
trace: { started: [], finished: [], tags },
|
|
28
49
|
})
|
|
29
50
|
}
|
|
30
51
|
|
|
@@ -8,6 +8,11 @@ const tags = require('../../../ext/tags')
|
|
|
8
8
|
const formats = require('../../../ext/formats')
|
|
9
9
|
const HTTP_HEADERS = formats.HTTP_HEADERS
|
|
10
10
|
const urlFilter = require('../../dd-trace/src/plugins/util/urlfilter')
|
|
11
|
+
const {
|
|
12
|
+
HTTP_STATUS_ERROR,
|
|
13
|
+
INSTRUMENTATION_HTTP_RESOURCE,
|
|
14
|
+
otelHttpResourceName,
|
|
15
|
+
} = require('../../dd-trace/src/plugins/util/http-otel-semantics')
|
|
11
16
|
const { getClientStatusValidator } = require('../../dd-trace/src/plugins/util/status-validator')
|
|
12
17
|
const { buildClientHttpUrl } = require('../../dd-trace/src/plugins/util/url')
|
|
13
18
|
const { stripQueryAndFragment } = require('../../dd-trace/src/util')
|
|
@@ -40,21 +45,36 @@ class HttpClientPlugin extends ClientPlugin {
|
|
|
40
45
|
|
|
41
46
|
const method = (options.method || 'GET').toUpperCase()
|
|
42
47
|
const otelSemantics = this.config.DD_TRACE_OTEL_SEMANTICS_ENABLED
|
|
48
|
+
let otelUrl = uri
|
|
49
|
+
if (otelSemantics) {
|
|
50
|
+
const otelHostname = hostname.includes(':') && !hostname.startsWith('[') ? `[${hostname}]` : hostname
|
|
51
|
+
const otelHost = options.port ? `${otelHostname}:${options.port}` : otelHostname
|
|
52
|
+
const auth = typeof options.auth === 'string' && options.auth ? 'REDACTED:REDACTED@' : ''
|
|
53
|
+
const otelBase = `${protocol}//${auth}${otelHost}`
|
|
54
|
+
otelUrl = buildClientHttpUrl(this.config, otelBase, pathname, `${otelBase}${path}`)
|
|
55
|
+
}
|
|
43
56
|
const childOf = store && allowed ? store.span : null
|
|
44
57
|
// TODO delegate to super.startspan
|
|
58
|
+
const meta = {
|
|
59
|
+
[COMPONENT]: this.component,
|
|
60
|
+
'span.kind': 'client',
|
|
61
|
+
'resource.name': method,
|
|
62
|
+
'span.type': 'http',
|
|
63
|
+
'http.method': method,
|
|
64
|
+
'http.url': otelUrl,
|
|
65
|
+
'out.host': hostname,
|
|
66
|
+
}
|
|
67
|
+
if (otelSemantics) {
|
|
68
|
+
const resource = otelHttpResourceName(method)
|
|
69
|
+
meta['resource.name'] = resource
|
|
70
|
+
meta[INSTRUMENTATION_HTTP_RESOURCE] = resource
|
|
71
|
+
}
|
|
72
|
+
|
|
45
73
|
const span = this.startSpan(this.operationName(), {
|
|
46
74
|
childOf,
|
|
47
75
|
integrationName: this.component,
|
|
48
76
|
service: this.serviceName({ pluginConfig: this.config, sessionDetails: extractSessionDetails(options) }),
|
|
49
|
-
meta
|
|
50
|
-
[COMPONENT]: this.component,
|
|
51
|
-
'span.kind': 'client',
|
|
52
|
-
'resource.name': method,
|
|
53
|
-
'span.type': 'http',
|
|
54
|
-
'http.method': method,
|
|
55
|
-
'http.url': otelSemantics ? buildClientHttpUrl(this.config, base, pathname, uri) : uri,
|
|
56
|
-
'out.host': hostname,
|
|
57
|
-
},
|
|
77
|
+
meta,
|
|
58
78
|
metrics: {
|
|
59
79
|
[CLIENT_PORT_KEY]: Number.parseInt(options.port, 10),
|
|
60
80
|
},
|
|
@@ -99,6 +119,9 @@ class HttpClientPlugin extends ClientPlugin {
|
|
|
99
119
|
|
|
100
120
|
if (!this.config.validateStatus(status)) {
|
|
101
121
|
span.setTag('error', 1)
|
|
122
|
+
if (this.config.DD_TRACE_OTEL_SEMANTICS_ENABLED) {
|
|
123
|
+
span.setTag(HTTP_STATUS_ERROR, String(status))
|
|
124
|
+
}
|
|
102
125
|
}
|
|
103
126
|
|
|
104
127
|
addResponseHeaders(res, span, this.config)
|
|
@@ -9,6 +9,11 @@ const kinds = require('../../../ext/kinds')
|
|
|
9
9
|
const formats = require('../../../ext/formats')
|
|
10
10
|
const { COMPONENT, CLIENT_PORT_KEY } = require('../../dd-trace/src/constants')
|
|
11
11
|
const urlFilter = require('../../dd-trace/src/plugins/util/urlfilter')
|
|
12
|
+
const {
|
|
13
|
+
HTTP_STATUS_ERROR,
|
|
14
|
+
INSTRUMENTATION_HTTP_RESOURCE,
|
|
15
|
+
otelHttpResourceName,
|
|
16
|
+
} = require('../../dd-trace/src/plugins/util/http-otel-semantics')
|
|
12
17
|
const { getClientStatusValidator } = require('../../dd-trace/src/plugins/util/status-validator')
|
|
13
18
|
const { buildClientHttpUrl } = require('../../dd-trace/src/plugins/util/url')
|
|
14
19
|
|
|
@@ -30,30 +35,41 @@ class Http2ClientPlugin extends ClientPlugin {
|
|
|
30
35
|
|
|
31
36
|
bindStart (message) {
|
|
32
37
|
const { authority, options, headers = {} } = message
|
|
33
|
-
const
|
|
38
|
+
const otelSemantics = this.config.DD_TRACE_OTEL_SEMANTICS_ENABLED
|
|
39
|
+
const sessionDetails = extractSessionDetails(authority, options, otelSemantics)
|
|
34
40
|
const path = headers[HTTP2_HEADER_PATH] || '/'
|
|
35
41
|
const pathname = path.split(/[?#]/, 1)[0]
|
|
36
42
|
const method = headers[HTTP2_HEADER_METHOD] || HTTP2_METHOD_GET
|
|
37
43
|
const base = `${sessionDetails.protocol}//${sessionDetails.host}:${sessionDetails.port}`
|
|
38
44
|
const uri = `${base}${pathname}`
|
|
39
45
|
const allowed = this.config.filter(uri)
|
|
40
|
-
const
|
|
46
|
+
const otelBase = sessionDetails.hasAuth
|
|
47
|
+
? `${sessionDetails.protocol}//REDACTED:REDACTED@${sessionDetails.host}:${sessionDetails.port}`
|
|
48
|
+
: base
|
|
49
|
+
const otelUri = sessionDetails.hasAuth ? `${otelBase}${pathname}` : uri
|
|
41
50
|
|
|
42
51
|
const store = storage('legacy').getStore()
|
|
43
52
|
const childOf = store && allowed ? store.span : null
|
|
53
|
+
const meta = {
|
|
54
|
+
[COMPONENT]: this.constructor.id,
|
|
55
|
+
[SPAN_KIND]: CLIENT,
|
|
56
|
+
'resource.name': method,
|
|
57
|
+
'span.type': 'http',
|
|
58
|
+
'http.method': method,
|
|
59
|
+
'http.url': otelSemantics ? buildClientHttpUrl(this.config, otelBase, path, otelUri) : uri,
|
|
60
|
+
'out.host': sessionDetails.host,
|
|
61
|
+
}
|
|
62
|
+
if (otelSemantics) {
|
|
63
|
+
const resource = otelHttpResourceName(method)
|
|
64
|
+
meta['resource.name'] = resource
|
|
65
|
+
meta[INSTRUMENTATION_HTTP_RESOURCE] = resource
|
|
66
|
+
}
|
|
67
|
+
|
|
44
68
|
const span = this.startSpan(this.operationName(), {
|
|
45
69
|
childOf,
|
|
46
70
|
integrationName: this.constructor.id,
|
|
47
71
|
service: this.serviceName({ pluginConfig: this.config, sessionDetails }),
|
|
48
|
-
meta
|
|
49
|
-
[COMPONENT]: this.constructor.id,
|
|
50
|
-
[SPAN_KIND]: CLIENT,
|
|
51
|
-
'resource.name': method,
|
|
52
|
-
'span.type': 'http',
|
|
53
|
-
'http.method': method,
|
|
54
|
-
'http.url': otelSemantics ? buildClientHttpUrl(this.config, base, path, uri) : uri,
|
|
55
|
-
'out.host': sessionDetails.host,
|
|
56
|
-
},
|
|
72
|
+
meta,
|
|
57
73
|
metrics: {
|
|
58
74
|
[CLIENT_PORT_KEY]: Number.parseInt(sessionDetails.port, 10),
|
|
59
75
|
},
|
|
@@ -108,6 +124,9 @@ class Http2ClientPlugin extends ClientPlugin {
|
|
|
108
124
|
|
|
109
125
|
if (!this.config.validateStatus(status)) {
|
|
110
126
|
storage('legacy').run(store, () => this.addError())
|
|
127
|
+
if (this.config.DD_TRACE_OTEL_SEMANTICS_ENABLED) {
|
|
128
|
+
store.span.setTag(HTTP_STATUS_ERROR, String(status))
|
|
129
|
+
}
|
|
111
130
|
}
|
|
112
131
|
|
|
113
132
|
addHeaderTags(store.span, headers, HTTP_RESPONSE_HEADERS, this.config)
|
|
@@ -123,7 +142,12 @@ class Http2ClientPlugin extends ClientPlugin {
|
|
|
123
142
|
}
|
|
124
143
|
}
|
|
125
144
|
|
|
126
|
-
|
|
145
|
+
/**
|
|
146
|
+
* @param {string | URL | import('node:http2').ClientSessionOptions} authority
|
|
147
|
+
* @param {import('node:http2').SecureClientSessionOptions} options
|
|
148
|
+
* @param {boolean} otelSemantics
|
|
149
|
+
*/
|
|
150
|
+
function extractSessionDetails (authority, options, otelSemantics) {
|
|
127
151
|
if (typeof authority === 'string') {
|
|
128
152
|
authority = new URL(authority)
|
|
129
153
|
}
|
|
@@ -139,7 +163,8 @@ function extractSessionDetails (authority, options) {
|
|
|
139
163
|
host = options.host || host
|
|
140
164
|
}
|
|
141
165
|
|
|
142
|
-
|
|
166
|
+
const hasAuth = otelSemantics && Boolean(authority.username || authority.password)
|
|
167
|
+
return { protocol, port, host, hasAuth }
|
|
143
168
|
}
|
|
144
169
|
|
|
145
170
|
function hasAmazonSignature (headers, path) {
|