dd-trace 6.7.0 → 6.9.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/diagnose.js +27 -25
- package/ci/init.js +6 -6
- package/ci/runbook.md +114 -20
- package/ci/test-optimization-validation/approval-artifacts.js +36 -3
- package/ci/test-optimization-validation/approval.js +78 -22
- package/ci/test-optimization-validation/blocker-category.js +24 -0
- package/ci/test-optimization-validation/ci-discovery.js +23 -17
- package/ci/test-optimization-validation/ci-package-scripts.js +34 -6
- package/ci/test-optimization-validation/ci-remediation.js +1 -1
- package/ci/test-optimization-validation/cli.js +280 -52
- package/ci/test-optimization-validation/command-blocker.js +159 -20
- package/ci/test-optimization-validation/command-output-policy.js +14 -8
- package/ci/test-optimization-validation/command-runner.js +9 -7
- package/ci/test-optimization-validation/environment.js +4 -2
- package/ci/test-optimization-validation/executable.js +15 -13
- package/ci/test-optimization-validation/execution-lock.js +70 -0
- package/ci/test-optimization-validation/framework-adapters/cucumber-validation.json +3 -0
- package/ci/test-optimization-validation/framework-adapters/cucumber.js +657 -5
- package/ci/test-optimization-validation/framework-adapters/playwright.js +5 -5
- package/ci/test-optimization-validation/framework-adapters/vitest.js +517 -0
- package/ci/test-optimization-validation/generated-files.js +47 -37
- package/ci/test-optimization-validation/generated-test-contract.js +9 -7
- package/ci/test-optimization-validation/generated-verifier.js +24 -17
- package/ci/test-optimization-validation/literal-glob.js +52 -0
- package/ci/test-optimization-validation/manifest-loader.js +3 -0
- package/ci/test-optimization-validation/manifest-scaffold.js +301 -52
- package/ci/test-optimization-validation/manifest-schema.js +80 -17
- package/ci/test-optimization-validation/offline-fixtures.js +13 -4
- package/ci/test-optimization-validation/offline-output.js +6 -6
- package/ci/test-optimization-validation/package-check.js +94 -0
- package/ci/test-optimization-validation/plan-writer.js +183 -10
- package/ci/test-optimization-validation/preflight-runner.js +110 -31
- package/ci/test-optimization-validation/project-build-artifact.js +31 -0
- package/ci/test-optimization-validation/redaction.js +18 -27
- package/ci/test-optimization-validation/report-writer.js +182 -48
- package/ci/test-optimization-validation/result-semantics.js +20 -3
- package/ci/test-optimization-validation/runner-command.js +41 -21
- package/ci/test-optimization-validation/runner-contract.js +79 -43
- package/ci/test-optimization-validation/safe-files.js +4 -4
- package/ci/test-optimization-validation/scenarios/basic-reporting.js +60 -6
- package/ci/test-optimization-validation/scenarios/ci-wiring.js +141 -35
- package/ci/test-optimization-validation/scenarios/helpers.js +30 -6
- package/ci/test-optimization-validation/scenarios/test-management.js +2 -2
- package/ci/test-optimization-validation/static-diagnosis.js +10 -3
- package/ci/test-optimization-validation/test-output.js +2 -1
- package/ci/test-optimization-validation/validation-blocker.js +21 -0
- package/ci/vitest-no-worker-init-setup.mjs +377 -84
- package/index.d.ts +175 -14
- package/init.js +1 -17
- package/initialize.mjs +11 -0
- package/loader-hook.mjs +6 -4
- package/package.json +12 -4
- package/packages/datadog-core/src/utils/src/kebabcase.js +8 -2
- package/packages/datadog-core/src/utils/src/parse-tags.js +0 -1
- package/packages/datadog-esbuild/index.js +4 -2
- package/packages/datadog-esbuild/src/utils.js +17 -2
- package/packages/datadog-instrumentations/src/ai.js +61 -34
- package/packages/datadog-instrumentations/src/bluebird.js +6 -6
- package/packages/datadog-instrumentations/src/claude-agent-sdk.js +85 -9
- package/packages/datadog-instrumentations/src/cucumber.js +131 -51
- package/packages/datadog-instrumentations/src/dns.js +21 -2
- package/packages/datadog-instrumentations/src/electron.js +1 -0
- package/packages/datadog-instrumentations/src/fastify.js +3 -1
- package/packages/datadog-instrumentations/src/grpc/client.js +4 -2
- package/packages/datadog-instrumentations/src/helpers/callback-instrumentor.js +3 -1
- package/packages/datadog-instrumentations/src/helpers/extract-package-and-module-path.js +10 -0
- package/packages/datadog-instrumentations/src/helpers/hook.js +19 -2
- package/packages/datadog-instrumentations/src/helpers/hooks.js +4 -0
- package/packages/datadog-instrumentations/src/helpers/register.js +9 -3
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +34 -9
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/index.js +1 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/webdriverio.js +175 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/loader.mjs +20 -2
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.js +32 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +61 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +50 -18
- package/packages/datadog-instrumentations/src/helpers/router-helper.js +38 -7
- package/packages/datadog-instrumentations/src/helpers/shared-utils.js +39 -0
- package/packages/datadog-instrumentations/src/http/client.js +1 -3
- package/packages/datadog-instrumentations/src/jest/coverage-backfill.js +1 -1
- package/packages/datadog-instrumentations/src/jest.js +986 -246
- package/packages/datadog-instrumentations/src/mocha/common.js +1 -3
- package/packages/datadog-instrumentations/src/mocha/main.js +109 -51
- package/packages/datadog-instrumentations/src/mocha/utils.js +120 -32
- package/packages/datadog-instrumentations/src/mocha/webdriverio-protocol.js +44 -0
- package/packages/datadog-instrumentations/src/mocha/worker.js +441 -43
- package/packages/datadog-instrumentations/src/moleculer/client.js +1 -1
- package/packages/datadog-instrumentations/src/mysql.js +1 -1
- package/packages/datadog-instrumentations/src/next.js +155 -23
- package/packages/datadog-instrumentations/src/openai.js +14 -0
- package/packages/datadog-instrumentations/src/pg.js +180 -6
- package/packages/datadog-instrumentations/src/playwright.js +176 -81
- package/packages/datadog-instrumentations/src/promise-js.js +4 -4
- package/packages/datadog-instrumentations/src/promise.js +3 -3
- package/packages/datadog-instrumentations/src/rhea.js +1 -1
- package/packages/datadog-instrumentations/src/router.js +195 -19
- package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +567 -65
- package/packages/datadog-instrumentations/src/vitest-main.js +438 -54
- package/packages/datadog-instrumentations/src/vitest-util.js +42 -7
- package/packages/datadog-instrumentations/src/vitest-worker.js +234 -17
- package/packages/datadog-instrumentations/src/webdriverio.js +1090 -0
- package/packages/datadog-instrumentations/src/when.js +3 -3
- package/packages/datadog-instrumentations/src/ws.js +5 -1
- package/packages/datadog-plugin-aerospike/src/index.js +1 -3
- package/packages/datadog-plugin-amqplib/src/client.js +1 -1
- package/packages/datadog-plugin-amqplib/src/producer.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/utils.js +59 -48
- package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +2 -2
- package/packages/datadog-plugin-aws-sdk/src/services/stepfunctions.js +2 -2
- package/packages/datadog-plugin-azure-event-hubs/src/producer.js +1 -3
- package/packages/datadog-plugin-azure-service-bus/src/producer.js +5 -3
- package/packages/datadog-plugin-bullmq/src/producer.js +3 -3
- package/packages/datadog-plugin-child_process/src/index.js +3 -3
- package/packages/datadog-plugin-child_process/src/scrub-cmd-params.js +6 -11
- package/packages/datadog-plugin-cucumber/src/index.js +5 -1
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +50 -46
- package/packages/datadog-plugin-cypress/src/source-map-utils.js +1 -1
- package/packages/datadog-plugin-cypress/src/support.js +7 -4
- package/packages/datadog-plugin-electron/src/net.js +10 -4
- package/packages/datadog-plugin-fastify/src/tracing.js +1 -1
- package/packages/datadog-plugin-fs/src/index.js +0 -4
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +14 -7
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +19 -10
- package/packages/datadog-plugin-graphql/src/execute.js +1 -0
- package/packages/datadog-plugin-graphql/src/tools/signature.js +1 -1
- package/packages/datadog-plugin-http/src/client.js +3 -2
- package/packages/datadog-plugin-http2/src/client.js +1 -1
- package/packages/datadog-plugin-jest/src/index.js +3 -21
- package/packages/datadog-plugin-jest/src/util.js +4 -1
- package/packages/datadog-plugin-kafkajs/src/producer.js +2 -1
- package/packages/datadog-plugin-langchain/src/tokens.js +2 -2
- package/packages/datadog-plugin-mocha/src/index.js +342 -6
- package/packages/datadog-plugin-next/src/index.js +57 -9
- package/packages/datadog-plugin-openai/src/tracing.js +4 -0
- package/packages/datadog-plugin-pg/src/index.js +65 -1
- package/packages/datadog-plugin-playwright/src/index.js +1 -1
- package/packages/datadog-plugin-prisma/src/index.js +5 -1
- package/packages/datadog-plugin-rhea/src/consumer.js +16 -13
- package/packages/datadog-plugin-rhea/src/producer.js +1 -1
- package/packages/datadog-plugin-undici/src/index.js +2 -1
- package/packages/datadog-plugin-vitest/src/index.js +179 -18
- package/packages/datadog-shimmer/src/shimmer.js +6 -2
- package/packages/datadog-webpack/index.js +2 -2
- package/packages/dd-trace/src/aiguard/sdk.js +3 -0
- package/packages/dd-trace/src/appsec/{blocking.js → blocking/index.js} +26 -6
- package/packages/dd-trace/src/appsec/downstream_requests.js +1 -1
- package/packages/dd-trace/src/appsec/handlers/auth.js +62 -0
- package/packages/dd-trace/src/appsec/handlers/http-request.js +215 -0
- package/packages/dd-trace/src/appsec/handlers/http-response.js +78 -0
- package/packages/dd-trace/src/appsec/handlers/http-shared.js +24 -0
- package/packages/dd-trace/src/appsec/handlers/payments.js +104 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-base-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-password-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hsts-header-missing-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/sql-injection-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +1 -3
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/utils.js +2 -2
- package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +2 -2
- package/packages/dd-trace/src/appsec/index.js +48 -476
- package/packages/dd-trace/src/appsec/sdk/track_event.js +10 -1
- package/packages/dd-trace/src/appsec/waf/waf_manager.js +1 -1
- package/packages/dd-trace/src/ci-visibility/coverage-report-discovery.js +46 -14
- package/packages/dd-trace/src/ci-visibility/efd-retry-policy.js +89 -0
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/sink.js +7 -6
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +29 -15
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +19 -1
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/index.js +25 -1
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/webdriverio.js +26 -0
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/writer.js +9 -1
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +22 -7
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +9 -14
- package/packages/dd-trace/src/ci-visibility/requests/request.js +3 -3
- package/packages/dd-trace/src/ci-visibility/requests/upload-coverage-report.js +21 -5
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache-schema.js +2 -2
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache.js +5 -1
- package/packages/dd-trace/src/config/defaults.js +14 -6
- package/packages/dd-trace/src/config/generated-config-types.d.ts +4 -2
- package/packages/dd-trace/src/config/helper.js +2 -0
- package/packages/dd-trace/src/config/index.js +31 -5
- package/packages/dd-trace/src/config/parsers.js +19 -1
- package/packages/dd-trace/src/config/remote_config.js +1 -1
- package/packages/dd-trace/src/config/supported-configurations.json +13 -6
- package/packages/dd-trace/src/datastreams/encoding.js +3 -4
- package/packages/dd-trace/src/debugger/devtools_client/log.js +2 -1
- package/packages/dd-trace/src/debugger/devtools_client/probe_sampler.js +1 -4
- package/packages/dd-trace/src/debugger/devtools_client/send.js +1 -2
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/index.js +2 -2
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/redaction.js +16 -2
- package/packages/dd-trace/src/debugger/devtools_client/status.js +1 -1
- package/packages/dd-trace/src/encode/coverage-ci-visibility.js +0 -1
- package/packages/dd-trace/src/encode/tags-processors.js +2 -2
- package/packages/dd-trace/src/exporters/common/url.js +3 -5
- package/packages/dd-trace/src/exporters/electron/index.js +4 -1
- package/packages/dd-trace/src/external-logger/src/index.js +1 -2
- package/packages/dd-trace/src/flare/index.js +2 -2
- package/packages/dd-trace/src/guardrails/apply-pm2-env.js +16 -0
- package/packages/dd-trace/src/guardrails/log.js +1 -10
- package/packages/dd-trace/src/id.js +1 -1
- package/packages/dd-trace/src/llmobs/constants/tags.js +1 -1
- package/packages/dd-trace/src/llmobs/eval-metric.js +249 -0
- package/packages/dd-trace/src/llmobs/experiments/client.js +4 -2
- package/packages/dd-trace/src/llmobs/experiments/dataset.js +66 -14
- package/packages/dd-trace/src/llmobs/experiments/experiment.js +289 -95
- package/packages/dd-trace/src/llmobs/experiments/index.js +66 -19
- package/packages/dd-trace/src/llmobs/experiments/noop.js +95 -10
- package/packages/dd-trace/src/llmobs/experiments/result.js +13 -2
- package/packages/dd-trace/src/llmobs/experiments/util.js +220 -0
- package/packages/dd-trace/src/llmobs/noop.js +2 -0
- package/packages/dd-trace/src/llmobs/plugins/ai/ddTelemetry.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/ai/util.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/anthropic/index.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/bedrockruntime.js +5 -5
- package/packages/dd-trace/src/llmobs/plugins/claude-agent-sdk/index.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/genai/index.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/index.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/langchain/index.js +1 -1
- package/packages/dd-trace/src/llmobs/sdk.js +152 -78
- package/packages/dd-trace/src/llmobs/span_processor.js +9 -7
- package/packages/dd-trace/src/llmobs/tagger.js +1 -2
- package/packages/dd-trace/src/llmobs/telemetry.js +18 -0
- package/packages/dd-trace/src/llmobs/writers/base.js +3 -0
- package/packages/dd-trace/src/llmobs/writers/spans.js +12 -6
- package/packages/dd-trace/src/llmobs/writers/util.js +2 -0
- package/packages/dd-trace/src/log/channels.js +1 -9
- package/packages/dd-trace/src/log/levels.js +12 -0
- package/packages/dd-trace/src/noop/proxy.js +2 -2
- package/packages/dd-trace/src/openfeature/writers/exposures.js +1 -1
- package/packages/dd-trace/src/openfeature/writers/util.js +1 -1
- package/packages/dd-trace/src/opentelemetry/logs/batch_log_processor.js +1 -1
- package/packages/dd-trace/src/opentelemetry/metrics/meter.js +8 -4
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_transformer.js +1 -1
- package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +3 -2
- package/packages/dd-trace/src/opentelemetry/span.js +4 -0
- package/packages/dd-trace/src/opentracing/span.js +1 -1
- package/packages/dd-trace/src/opentracing/span_context.js +1 -1
- package/packages/dd-trace/src/plugins/ci_plugin.js +124 -23
- package/packages/dd-trace/src/plugins/index.js +2 -0
- package/packages/dd-trace/src/plugins/plugin.js +1 -1
- package/packages/dd-trace/src/plugins/tracing.js +1 -0
- package/packages/dd-trace/src/plugins/util/ci.js +13 -6
- package/packages/dd-trace/src/plugins/util/git.js +7 -5
- package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +3 -3
- package/packages/dd-trace/src/plugins/util/ip_extractor.js +1 -1
- package/packages/dd-trace/src/plugins/util/llm.js +2 -2
- package/packages/dd-trace/src/plugins/util/stacktrace.js +3 -0
- package/packages/dd-trace/src/plugins/util/tags.js +2 -0
- package/packages/dd-trace/src/plugins/util/test.js +356 -86
- package/packages/dd-trace/src/plugins/util/url.js +5 -5
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +1 -1
- package/packages/dd-trace/src/plugins/util/web.js +24 -2
- package/packages/dd-trace/src/priority_sampler.js +6 -3
- package/packages/dd-trace/src/profiler.js +1 -1
- package/packages/dd-trace/src/profiling/exporters/event_serializer.js +1 -1
- package/packages/dd-trace/src/profiling/profilers/events.js +2 -2
- package/packages/dd-trace/src/profiling/profilers/poisson.js +1 -1
- package/packages/dd-trace/src/profiling/profilers/shared.js +2 -2
- package/packages/dd-trace/src/proxy.js +1 -0
- package/packages/dd-trace/src/ritm.js +10 -20
- package/packages/dd-trace/src/runtime_metrics/runtime_metrics.js +4 -2
- package/packages/dd-trace/src/sampling_rule.js +4 -2
- package/packages/dd-trace/src/service-naming/schemas/v0/storage.js +1 -1
- package/packages/dd-trace/src/service-naming/schemas/v1/storage.js +1 -1
- package/packages/dd-trace/src/startup-log.js +3 -0
- package/packages/dd-trace/src/telemetry/logs/index.js +3 -0
- package/packages/dd-trace/src/telemetry/logs/log-collector.js +3 -1
- package/packages/dd-trace/src/telemetry/telemetry.js +1 -1
- package/packages/dd-trace/src/util.js +16 -0
- package/vendor/dist/@apm-js-collab/code-transformer/index.js +12 -12
- package/vendor/dist/pprof-format/index.js +1 -1
- package/vendor/dist/source-map/index.js +1 -1
- package/version.js +10 -8
- /package/packages/dd-trace/src/appsec/{blocked_templates.js → blocking/templates.js} +0 -0
|
@@ -48,12 +48,16 @@ const {
|
|
|
48
48
|
CI_APP_ORIGIN,
|
|
49
49
|
getTestSessionCommonTags,
|
|
50
50
|
getTestModuleCommonTags,
|
|
51
|
+
TEST_FRAMEWORK,
|
|
52
|
+
TEST_FRAMEWORK_ADAPTER,
|
|
53
|
+
TEST_FRAMEWORK_VERSION,
|
|
51
54
|
TEST_SUITE_ID,
|
|
52
55
|
TEST_MODULE_ID,
|
|
53
56
|
TEST_SESSION_ID,
|
|
54
57
|
TEST_COMMAND,
|
|
55
58
|
TEST_LEVELS_METADATA,
|
|
56
59
|
TEST_MODULE,
|
|
60
|
+
TEST_TYPE,
|
|
57
61
|
TEST_SESSION_NAME,
|
|
58
62
|
getTestSuiteCommonTags,
|
|
59
63
|
TEST_STATUS,
|
|
@@ -62,6 +66,8 @@ const {
|
|
|
62
66
|
ITR_CORRELATION_ID,
|
|
63
67
|
TEST_SOURCE_FILE,
|
|
64
68
|
TEST_SUITE,
|
|
69
|
+
TEST_SUITE_EXECUTION_ID,
|
|
70
|
+
getTestSuiteExecutionKey,
|
|
65
71
|
getFileAndLineNumberFromError,
|
|
66
72
|
DI_ERROR_DEBUG_INFO_CAPTURED,
|
|
67
73
|
DI_DEBUG_ERROR_PREFIX,
|
|
@@ -101,6 +107,7 @@ const FRAMEWORK_TO_TRIMMED_COMMAND = {
|
|
|
101
107
|
cucumber: 'cucumber-js',
|
|
102
108
|
playwright: 'playwright test',
|
|
103
109
|
jest: 'jest',
|
|
110
|
+
webdriverio: 'wdio',
|
|
104
111
|
}
|
|
105
112
|
|
|
106
113
|
const WORKER_EXPORTER_TO_TEST_FRAMEWORK = {
|
|
@@ -131,7 +138,8 @@ function withTimeout (promise, timeoutMs) {
|
|
|
131
138
|
}
|
|
132
139
|
|
|
133
140
|
function setItrSkippingEnabledTagFromLibraryConfig (plugin, frameworkVersion) {
|
|
134
|
-
const
|
|
141
|
+
const testFramework = plugin.testFramework || plugin.constructor.id
|
|
142
|
+
const libraryCapabilitiesTags = getDefaultLibraryCapabilitiesTags(testFramework, frameworkVersion)
|
|
135
143
|
|
|
136
144
|
if (!libraryCapabilitiesTags[DD_CAPABILITIES_TEST_IMPACT_ANALYSIS] ||
|
|
137
145
|
!plugin.libraryConfig ||
|
|
@@ -160,6 +168,21 @@ function getTestSuiteLevelVisibilityTags (testSuiteSpan, testFramework) {
|
|
|
160
168
|
return suiteTags
|
|
161
169
|
}
|
|
162
170
|
|
|
171
|
+
/**
|
|
172
|
+
* Keeps non-TIA settings while disabling suite skipping and per-suite coverage collection.
|
|
173
|
+
*
|
|
174
|
+
* @param {object} libraryConfig
|
|
175
|
+
* @returns {object}
|
|
176
|
+
*/
|
|
177
|
+
function disableTestImpactAnalysis (libraryConfig) {
|
|
178
|
+
return Object.freeze({
|
|
179
|
+
...libraryConfig,
|
|
180
|
+
isCodeCoverageEnabled: false,
|
|
181
|
+
isItrEnabled: false,
|
|
182
|
+
isSuitesSkippingEnabled: false,
|
|
183
|
+
})
|
|
184
|
+
}
|
|
185
|
+
|
|
163
186
|
module.exports = class CiPlugin extends Plugin {
|
|
164
187
|
constructor (...args) {
|
|
165
188
|
super(...args)
|
|
@@ -170,16 +193,32 @@ module.exports = class CiPlugin extends Plugin {
|
|
|
170
193
|
this.rootDir = process.cwd() // fallback in case :session:start events are not emitted
|
|
171
194
|
this._testSuiteSpansByTestSuite = new Map()
|
|
172
195
|
this._pendingWorkerTracesByTestSuite = new Map()
|
|
196
|
+
this._workerTraceExecutionIds = new WeakMap()
|
|
173
197
|
this._pendingRequestErrorTags = []
|
|
174
198
|
|
|
175
199
|
this.addSub(`ci:${this.constructor.id}:library-configuration`, (ctx) => {
|
|
176
|
-
const {
|
|
200
|
+
const {
|
|
201
|
+
basicReportingOnly,
|
|
202
|
+
disableTestImpactAnalysis: shouldDisableTestImpactAnalysis,
|
|
203
|
+
onDone,
|
|
204
|
+
frameworkVersion,
|
|
205
|
+
} = ctx
|
|
177
206
|
ctx.currentStore = legacyStorage.getStore()
|
|
178
207
|
|
|
179
208
|
if (!this.tracer._exporter || !this.tracer._exporter.getLibraryConfiguration) {
|
|
180
209
|
return onDone({ err: new Error('Test optimization was not initialized correctly') })
|
|
181
210
|
}
|
|
182
211
|
this.tracer._exporter.getLibraryConfiguration(this.testConfiguration, (err, libraryConfig) => {
|
|
212
|
+
let effectiveLibraryConfig
|
|
213
|
+
if (!err) {
|
|
214
|
+
if (basicReportingOnly) {
|
|
215
|
+
effectiveLibraryConfig = {}
|
|
216
|
+
} else if (shouldDisableTestImpactAnalysis) {
|
|
217
|
+
effectiveLibraryConfig = disableTestImpactAnalysis(libraryConfig)
|
|
218
|
+
} else {
|
|
219
|
+
effectiveLibraryConfig = libraryConfig
|
|
220
|
+
}
|
|
221
|
+
}
|
|
183
222
|
if (err) {
|
|
184
223
|
this.libraryConfig = undefined
|
|
185
224
|
this.itrCorrelationId = undefined
|
|
@@ -187,7 +226,7 @@ module.exports = class CiPlugin extends Plugin {
|
|
|
187
226
|
log.error('Library configuration could not be fetched. %s', err.message)
|
|
188
227
|
this._addRequestErrorTag(DD_CI_LIBRARY_CONFIGURATION_ERROR_SETTINGS, err)
|
|
189
228
|
} else {
|
|
190
|
-
this.libraryConfig =
|
|
229
|
+
this.libraryConfig = effectiveLibraryConfig
|
|
191
230
|
setItrSkippingEnabledTagFromLibraryConfig(this, frameworkVersion)
|
|
192
231
|
}
|
|
193
232
|
|
|
@@ -201,7 +240,7 @@ module.exports = class CiPlugin extends Plugin {
|
|
|
201
240
|
onDone({
|
|
202
241
|
err,
|
|
203
242
|
isTestDynamicInstrumentationEnabled: this.config.isTestDynamicInstrumentationEnabled,
|
|
204
|
-
libraryConfig,
|
|
243
|
+
libraryConfig: effectiveLibraryConfig,
|
|
205
244
|
repositoryRoot: this.repositoryRoot,
|
|
206
245
|
requestErrorTags: this._getCurrentRequestErrorTags(),
|
|
207
246
|
})
|
|
@@ -220,6 +259,7 @@ module.exports = class CiPlugin extends Plugin {
|
|
|
220
259
|
{
|
|
221
260
|
...this.testConfiguration,
|
|
222
261
|
isCoverageReportUploadEnabled: this.libraryConfig?.isCoverageReportUploadEnabled,
|
|
262
|
+
isLineCoverageSupported: this.constructor.id !== 'vitest',
|
|
223
263
|
},
|
|
224
264
|
(err, skippableSuites, itrCorrelationId, skippableSuitesCoverage) => {
|
|
225
265
|
if (err) {
|
|
@@ -234,19 +274,28 @@ module.exports = class CiPlugin extends Plugin {
|
|
|
234
274
|
)
|
|
235
275
|
})
|
|
236
276
|
|
|
237
|
-
this.addSub(`ci:${this.constructor.id}:session:start`, ({
|
|
277
|
+
this.addSub(`ci:${this.constructor.id}:session:start`, ({
|
|
278
|
+
command,
|
|
279
|
+
frameworkVersion,
|
|
280
|
+
rootDir,
|
|
281
|
+
testFramework,
|
|
282
|
+
testFrameworkAdapter,
|
|
283
|
+
}) => {
|
|
284
|
+
const effectiveTestFramework = testFramework || this.constructor.id
|
|
238
285
|
const childOf = getTestParentSpan(this.tracer)
|
|
239
|
-
const testSessionSpanMetadata = getTestSessionCommonTags(command, frameworkVersion,
|
|
240
|
-
const testModuleSpanMetadata = getTestModuleCommonTags(command, frameworkVersion,
|
|
286
|
+
const testSessionSpanMetadata = getTestSessionCommonTags(command, frameworkVersion, effectiveTestFramework)
|
|
287
|
+
const testModuleSpanMetadata = getTestModuleCommonTags(command, frameworkVersion, effectiveTestFramework)
|
|
241
288
|
|
|
242
289
|
this.command = command
|
|
243
290
|
this.frameworkVersion = frameworkVersion
|
|
291
|
+
this.testFramework = effectiveTestFramework
|
|
292
|
+
this.testFrameworkAdapter = testFrameworkAdapter
|
|
244
293
|
// only for playwright
|
|
245
294
|
this.rootDir = rootDir
|
|
246
295
|
|
|
247
296
|
const testSessionName = getTestSessionName(
|
|
248
297
|
this.config,
|
|
249
|
-
DD_MAJOR < 6 ? this.command : FRAMEWORK_TO_TRIMMED_COMMAND[
|
|
298
|
+
DD_MAJOR < 6 ? this.command : FRAMEWORK_TO_TRIMMED_COMMAND[effectiveTestFramework],
|
|
250
299
|
this.testEnvironmentMetadata
|
|
251
300
|
)
|
|
252
301
|
|
|
@@ -296,7 +345,7 @@ module.exports = class CiPlugin extends Plugin {
|
|
|
296
345
|
const testCommand = this.command
|
|
297
346
|
for (const testSuite of skippedSuites) {
|
|
298
347
|
const testSuiteMetadata = {
|
|
299
|
-
...getTestSuiteCommonTags(testCommand, frameworkVersion, testSuite, this.
|
|
348
|
+
...getTestSuiteCommonTags(testCommand, frameworkVersion, testSuite, this.testFramework),
|
|
300
349
|
...getSessionRequestErrorTags(this.testSessionSpan),
|
|
301
350
|
...getSessionItrSkippingEnabledTags(this.testSessionSpan),
|
|
302
351
|
}
|
|
@@ -392,10 +441,16 @@ module.exports = class CiPlugin extends Plugin {
|
|
|
392
441
|
return onDone({ err: new Error('No modified tests could have been retrieved') })
|
|
393
442
|
})
|
|
394
443
|
|
|
395
|
-
this.addSub(`ci:${this.constructor.id}:worker-report:trace`,
|
|
444
|
+
this.addSub(`ci:${this.constructor.id}:worker-report:trace`, payload => {
|
|
445
|
+
const { traces, [TEST_SUITE_EXECUTION_ID]: testSuiteExecutionId } = typeof payload === 'string'
|
|
446
|
+
? { traces: payload }
|
|
447
|
+
: payload
|
|
396
448
|
const formattedTraces = JSON.parse(traces)
|
|
397
449
|
|
|
398
450
|
for (const trace of formattedTraces) {
|
|
451
|
+
if (testSuiteExecutionId) {
|
|
452
|
+
this._workerTraceExecutionIds.set(trace, testSuiteExecutionId)
|
|
453
|
+
}
|
|
399
454
|
this._prepareWorkerTrace(trace)
|
|
400
455
|
this._exportWorkerTraceOrBuffer(trace)
|
|
401
456
|
}
|
|
@@ -406,12 +461,28 @@ module.exports = class CiPlugin extends Plugin {
|
|
|
406
461
|
this.tracer._exporter.exportDiLogs(this.testEnvironmentMetadata, logMessage)
|
|
407
462
|
}
|
|
408
463
|
})
|
|
464
|
+
|
|
465
|
+
this.addSub(`ci:${this.constructor.id}:worker-report:telemetry`, data => {
|
|
466
|
+
const telemetryEvents = JSON.parse(data)
|
|
467
|
+
for (const event of telemetryEvents) {
|
|
468
|
+
if (event.type === 'ciVisEvent') {
|
|
469
|
+
this.telemetry.ciVisEvent(event.name, event.testLevel, {
|
|
470
|
+
...event.tags,
|
|
471
|
+
testFramework: event.testFramework,
|
|
472
|
+
isUnsupportedCIProvider: event.isUnsupportedCIProvider,
|
|
473
|
+
})
|
|
474
|
+
} else if (event.type === 'count') {
|
|
475
|
+
this.telemetry.count(event.name, event.tags, event.value)
|
|
476
|
+
} else if (event.type === 'distribution') {
|
|
477
|
+
this.telemetry.distribution(event.name, event.tags, event.measure)
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
})
|
|
409
481
|
}
|
|
410
482
|
|
|
411
483
|
get telemetry () {
|
|
412
|
-
const testFramework = this.constructor.id
|
|
484
|
+
const testFramework = this.testFramework || this.constructor.id
|
|
413
485
|
const exporter = this.tracer?._exporter
|
|
414
|
-
// TODO: only jest worker supported yet
|
|
415
486
|
const isSupportedWorker = exporter && typeof exporter.exportTelemetry === 'function'
|
|
416
487
|
const ciProviderName = this.ciProviderName
|
|
417
488
|
|
|
@@ -469,10 +540,19 @@ module.exports = class CiPlugin extends Plugin {
|
|
|
469
540
|
/**
|
|
470
541
|
* Returns library capability metadata tags for this test framework.
|
|
471
542
|
* @param {string} frameworkVersion - The test framework version.
|
|
543
|
+
* @param {object} [ctx] - Diagnostic channel context.
|
|
544
|
+
* @param {boolean} [ctx.basicReportingOnly] - Whether advanced capabilities must be omitted.
|
|
545
|
+
* @param {string} [ctx.testFramework] - Effective framework when one framework is hosted by another.
|
|
472
546
|
* @returns {Record<string, string|undefined>}
|
|
473
547
|
*/
|
|
474
|
-
getLibraryCapabilitiesTags (frameworkVersion) {
|
|
475
|
-
|
|
548
|
+
getLibraryCapabilitiesTags (frameworkVersion, ctx = {}) {
|
|
549
|
+
if (ctx.basicReportingOnly) {
|
|
550
|
+
return {}
|
|
551
|
+
}
|
|
552
|
+
return getDefaultLibraryCapabilitiesTags(
|
|
553
|
+
ctx.testFramework || this.testFramework || this.constructor.id,
|
|
554
|
+
frameworkVersion
|
|
555
|
+
)
|
|
476
556
|
}
|
|
477
557
|
|
|
478
558
|
/**
|
|
@@ -592,17 +672,34 @@ module.exports = class CiPlugin extends Plugin {
|
|
|
592
672
|
// test session, test module and test suite ids. We have to update them in the main process.
|
|
593
673
|
if (span.name !== 'cucumber.test' && span.name !== 'mocha.test') continue
|
|
594
674
|
|
|
675
|
+
const testFramework = this.testFramework || this.constructor.id
|
|
676
|
+
span.meta[TEST_FRAMEWORK] = testFramework
|
|
677
|
+
span.meta[TEST_MODULE] = testFramework
|
|
678
|
+
const testType = this.testSessionSpan?.context().getTag(TEST_TYPE)
|
|
679
|
+
if (testType) {
|
|
680
|
+
span.meta[TEST_TYPE] = testType
|
|
681
|
+
}
|
|
682
|
+
if (this.frameworkVersion) {
|
|
683
|
+
span.meta[TEST_FRAMEWORK_VERSION] = this.frameworkVersion
|
|
684
|
+
}
|
|
685
|
+
if (this.testFrameworkAdapter) {
|
|
686
|
+
span.meta[TEST_FRAMEWORK_ADAPTER] = this.testFrameworkAdapter
|
|
687
|
+
}
|
|
688
|
+
|
|
595
689
|
const testSuite = span.meta[TEST_SUITE]
|
|
596
|
-
const
|
|
597
|
-
|
|
690
|
+
const testSuiteExecutionId = this._workerTraceExecutionIds.get(trace)
|
|
691
|
+
const testSuiteKey = getTestSuiteExecutionKey(testSuite, testSuiteExecutionId)
|
|
692
|
+
const testSuiteSpan = this._testSuiteSpansByTestSuite.get(testSuiteKey)
|
|
693
|
+
if (!testSuiteSpan) return testSuiteKey
|
|
598
694
|
|
|
599
|
-
const testSuiteTags = getTestSuiteLevelVisibilityTags(testSuiteSpan,
|
|
695
|
+
const testSuiteTags = getTestSuiteLevelVisibilityTags(testSuiteSpan, testFramework)
|
|
600
696
|
span.meta = {
|
|
601
697
|
...span.meta,
|
|
602
698
|
...testSuiteTags,
|
|
603
699
|
...getSessionRequestErrorTags(this.testSessionSpan),
|
|
604
700
|
}
|
|
605
701
|
}
|
|
702
|
+
this._workerTraceExecutionIds.delete(trace)
|
|
606
703
|
}
|
|
607
704
|
|
|
608
705
|
/**
|
|
@@ -761,19 +858,22 @@ module.exports = class CiPlugin extends Plugin {
|
|
|
761
858
|
return codeOwners
|
|
762
859
|
}
|
|
763
860
|
|
|
764
|
-
startTestSpan (testName, testSuite, testSuiteSpan, extraTags = {}) {
|
|
765
|
-
const childOf = getTestParentSpan(this.tracer)
|
|
861
|
+
startTestSpan (testName, testSuite, testSuiteSpan, extraTags = {}, testExecutionId, startTime) {
|
|
862
|
+
const childOf = getTestParentSpan(this.tracer, testExecutionId)
|
|
766
863
|
|
|
767
864
|
let testTags = {
|
|
768
865
|
...getTestCommonTags(
|
|
769
866
|
testName,
|
|
770
867
|
testSuite,
|
|
771
868
|
this.frameworkVersion,
|
|
772
|
-
this.constructor.id
|
|
869
|
+
this.testFramework || this.constructor.id
|
|
773
870
|
),
|
|
774
871
|
[COMPONENT]: this.constructor.id,
|
|
775
872
|
...extraTags,
|
|
776
873
|
}
|
|
874
|
+
if (this.testFrameworkAdapter) {
|
|
875
|
+
testTags[TEST_FRAMEWORK_ADAPTER] = this.testFrameworkAdapter
|
|
876
|
+
}
|
|
777
877
|
|
|
778
878
|
const codeOwners = this.getCodeOwners(testTags)
|
|
779
879
|
if (codeOwners) {
|
|
@@ -790,7 +890,7 @@ module.exports = class CiPlugin extends Plugin {
|
|
|
790
890
|
[TEST_SUITE_ID]: testSuiteSpan.context().toSpanId(),
|
|
791
891
|
[TEST_SESSION_ID]: testSuiteSpan.context().toTraceId(),
|
|
792
892
|
[TEST_COMMAND]: testSuiteSpan.context().getTag(TEST_COMMAND),
|
|
793
|
-
[TEST_MODULE]: this.constructor.id,
|
|
893
|
+
[TEST_MODULE]: this.testFramework || this.constructor.id,
|
|
794
894
|
...getSessionRequestErrorTags(this.testSessionSpan),
|
|
795
895
|
}
|
|
796
896
|
if (testSuiteSpan.context()._parentId) {
|
|
@@ -810,6 +910,7 @@ module.exports = class CiPlugin extends Plugin {
|
|
|
810
910
|
const testSpan = this.tracer
|
|
811
911
|
.startSpan(`${this.constructor.id}.test`, {
|
|
812
912
|
childOf,
|
|
913
|
+
startTime,
|
|
813
914
|
tags: {
|
|
814
915
|
...this.testEnvironmentMetadata,
|
|
815
916
|
...testTags,
|
|
@@ -1072,11 +1173,11 @@ module.exports = class CiPlugin extends Plugin {
|
|
|
1072
1173
|
return
|
|
1073
1174
|
}
|
|
1074
1175
|
|
|
1075
|
-
const { filePath, format } = coverageReports[reportIndex]
|
|
1176
|
+
const { filePath, fileDevice, fileInode, format } = coverageReports[reportIndex]
|
|
1076
1177
|
reportIndex++
|
|
1077
1178
|
|
|
1078
1179
|
this.tracer._exporter.uploadCoverageReport(
|
|
1079
|
-
{ filePath, format, testEnvironmentMetadata: this.testEnvironmentMetadata },
|
|
1180
|
+
{ filePath, fileDevice, fileInode, format, testEnvironmentMetadata: this.testEnvironmentMetadata },
|
|
1080
1181
|
(err) => {
|
|
1081
1182
|
if (err) {
|
|
1082
1183
|
failedCount++
|
|
@@ -36,6 +36,8 @@ const plugins = {
|
|
|
36
36
|
get '@smithy/core' () { return require('../../../datadog-plugin-aws-sdk/src') },
|
|
37
37
|
get '@smithy/smithy-client' () { return require('../../../datadog-plugin-aws-sdk/src') },
|
|
38
38
|
get '@vitest/runner' () { return require('../../../datadog-plugin-vitest/src') },
|
|
39
|
+
get '@wdio/jasmine-framework' () { return require('../../../datadog-plugin-mocha/src') },
|
|
40
|
+
get '@wdio/local-runner' () { return require('../../../datadog-plugin-mocha/src') },
|
|
39
41
|
get '@langchain/langgraph' () { return require('../../../datadog-plugin-langgraph/src') },
|
|
40
42
|
get '@openai/agents' () { return require('../../../datadog-plugin-openai-agents/src') },
|
|
41
43
|
get aerospike () { return require('../../../datadog-plugin-aerospike/src') },
|
|
@@ -265,6 +265,7 @@ class TracingPlugin extends Plugin {
|
|
|
265
265
|
analyticsSampler.sample(span, config.measured)
|
|
266
266
|
|
|
267
267
|
// TODO: Remove this after migration to TracingChannel is done.
|
|
268
|
+
// eslint-disable-next-line unicorn/no-unnecessary-boolean-comparison -- Context objects use the other branch.
|
|
268
269
|
if (enterOrCtx === true) {
|
|
269
270
|
legacyStorage.enterWith({ ...store, span })
|
|
270
271
|
} else if (enterOrCtx) {
|
|
@@ -18,6 +18,7 @@ const {
|
|
|
18
18
|
GIT_REPOSITORY_URL,
|
|
19
19
|
CI_PIPELINE_ID,
|
|
20
20
|
CI_PIPELINE_NAME,
|
|
21
|
+
CI_PIPELINE_DISPLAY_NAME,
|
|
21
22
|
CI_PIPELINE_NUMBER,
|
|
22
23
|
CI_PIPELINE_URL,
|
|
23
24
|
CI_PROVIDER_NAME,
|
|
@@ -75,7 +76,7 @@ function normalizeRef (ref) {
|
|
|
75
76
|
if (!ref) {
|
|
76
77
|
return ref
|
|
77
78
|
}
|
|
78
|
-
return ref.replaceAll(/origin\/|refs\/heads\/|tags\//
|
|
79
|
+
return ref.replaceAll(/origin\/|refs\/heads\/|tags\//g, '')
|
|
79
80
|
}
|
|
80
81
|
|
|
81
82
|
function resolveTilde (filePath) {
|
|
@@ -113,6 +114,9 @@ const uniq = (items) => [...new Set(items)]
|
|
|
113
114
|
*
|
|
114
115
|
* This is much more robust than relying on hardcoded paths, especially on self-hosted runners
|
|
115
116
|
* and GHES environments where the runner may be installed under arbitrary directories/users.
|
|
117
|
+
*
|
|
118
|
+
* @param {string | undefined} runnerTemp value of the `RUNNER_TEMP` environment variable
|
|
119
|
+
* @returns {string[]}
|
|
116
120
|
*/
|
|
117
121
|
function getGithubDiagnosticDirsFromEnv (runnerTemp) {
|
|
118
122
|
const dirs = []
|
|
@@ -181,6 +185,9 @@ function expandGlobPattern (pattern) {
|
|
|
181
185
|
/**
|
|
182
186
|
* Expands a mixed list of literal directories and glob patterns into concrete
|
|
183
187
|
* directories. Literals pass through unchanged (existence is checked later).
|
|
188
|
+
*
|
|
189
|
+
* @param {string[]} candidates
|
|
190
|
+
* @returns {string[]}
|
|
184
191
|
*/
|
|
185
192
|
function expandDiagnosticDirCandidates (candidates) {
|
|
186
193
|
const expanded = []
|
|
@@ -215,7 +222,7 @@ const githubWellKnownDiagnosticDirPatternsUnix = [
|
|
|
215
222
|
]
|
|
216
223
|
const githubWellKnownDiagnosticDirPatternsWin = ['C:/actions-runner/*/_diag', 'C:/actions-runner/*/*/_diag']
|
|
217
224
|
|
|
218
|
-
const githubJobIDRegex = /"job":\s
|
|
225
|
+
const githubJobIDRegex = /"job":\s*\{[\s\S]*?"v"\s*:\s*(\d+)(?:\.0)?/
|
|
219
226
|
|
|
220
227
|
function getJobIDFromDiagFile () {
|
|
221
228
|
const runnerTemp = getEnvironmentVariable('RUNNER_TEMP')
|
|
@@ -316,10 +323,8 @@ module.exports = {
|
|
|
316
323
|
}
|
|
317
324
|
|
|
318
325
|
if (NODE_LABELS) {
|
|
319
|
-
let nodeLabels
|
|
320
326
|
try {
|
|
321
|
-
|
|
322
|
-
tags[CI_NODE_LABELS] = nodeLabels
|
|
327
|
+
tags[CI_NODE_LABELS] = JSON.stringify(NODE_LABELS.split(' '))
|
|
323
328
|
} catch {
|
|
324
329
|
// ignore errors
|
|
325
330
|
}
|
|
@@ -651,7 +656,7 @@ module.exports = {
|
|
|
651
656
|
[GIT_TAG]: BITBUCKET_TAG,
|
|
652
657
|
[GIT_REPOSITORY_URL]: BITBUCKET_GIT_SSH_ORIGIN || BITBUCKET_GIT_HTTP_ORIGIN,
|
|
653
658
|
[CI_WORKSPACE_PATH]: BITBUCKET_CLONE_DIR,
|
|
654
|
-
[CI_PIPELINE_ID]: BITBUCKET_PIPELINE_UUID && BITBUCKET_PIPELINE_UUID.replaceAll(/[{}]/
|
|
659
|
+
[CI_PIPELINE_ID]: BITBUCKET_PIPELINE_UUID && BITBUCKET_PIPELINE_UUID.replaceAll(/[{}]/g, ''),
|
|
655
660
|
[GIT_PULL_REQUEST_BASE_BRANCH]: BITBUCKET_PR_DESTINATION_BRANCH,
|
|
656
661
|
[PR_NUMBER]: BITBUCKET_PR_ID,
|
|
657
662
|
}
|
|
@@ -699,6 +704,7 @@ module.exports = {
|
|
|
699
704
|
BUILDKITE_TAG,
|
|
700
705
|
BUILDKITE_BUILD_ID,
|
|
701
706
|
BUILDKITE_PIPELINE_SLUG,
|
|
707
|
+
BUILDKITE_PIPELINE_NAME,
|
|
702
708
|
BUILDKITE_BUILD_NUMBER,
|
|
703
709
|
BUILDKITE_BUILD_URL,
|
|
704
710
|
BUILDKITE_JOB_ID,
|
|
@@ -722,6 +728,7 @@ module.exports = {
|
|
|
722
728
|
[CI_PROVIDER_NAME]: 'buildkite',
|
|
723
729
|
[CI_PIPELINE_ID]: BUILDKITE_BUILD_ID,
|
|
724
730
|
[CI_PIPELINE_NAME]: BUILDKITE_PIPELINE_SLUG,
|
|
731
|
+
[CI_PIPELINE_DISPLAY_NAME]: BUILDKITE_PIPELINE_NAME,
|
|
725
732
|
[CI_PIPELINE_NUMBER]: BUILDKITE_BUILD_NUMBER,
|
|
726
733
|
[CI_PIPELINE_URL]: BUILDKITE_BUILD_URL,
|
|
727
734
|
[CI_JOB_URL]: `${BUILDKITE_BUILD_URL}#${BUILDKITE_JOB_ID}`,
|
|
@@ -38,6 +38,8 @@ const {
|
|
|
38
38
|
const { filterSensitiveInfoFromRepository } = require('./url')
|
|
39
39
|
const { cachedExec } = require('./git-cache')
|
|
40
40
|
|
|
41
|
+
/** @typedef {NonNullable<ReturnType<string['match']>>} RegExpMatch */
|
|
42
|
+
|
|
41
43
|
const legacyStorage = storage('legacy')
|
|
42
44
|
|
|
43
45
|
const GIT_REV_LIST_MAX_BUFFER = 12 * 1024 * 1024 // 12MB
|
|
@@ -62,7 +64,7 @@ function sanitizedExec (
|
|
|
62
64
|
let result = cachedExec(cmd, flags, { stdio: 'pipe' }).toString()
|
|
63
65
|
|
|
64
66
|
if (shouldTrim) {
|
|
65
|
-
result = result.replaceAll(/(\r\n|\n|\r)/
|
|
67
|
+
result = result.replaceAll(/(\r\n|\n|\r)/g, '')
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
if (durationMetric) {
|
|
@@ -116,12 +118,12 @@ function isShallowRepository () {
|
|
|
116
118
|
|
|
117
119
|
function getGitVersion () {
|
|
118
120
|
const gitVersionString = sanitizedExec('git', ['version'])
|
|
119
|
-
const gitVersionMatches = /** @type {
|
|
121
|
+
const gitVersionMatches = /** @type {RegExpMatch} */ (gitVersionString.match(/git version (\d+)\.(\d+)\.(\d+)/))
|
|
120
122
|
try {
|
|
121
123
|
return {
|
|
122
|
-
major: Number.parseInt(gitVersionMatches[1]),
|
|
123
|
-
minor: Number.parseInt(gitVersionMatches[2]),
|
|
124
|
-
patch: Number.parseInt(gitVersionMatches[3]),
|
|
124
|
+
major: Number.parseInt(gitVersionMatches[1], 10),
|
|
125
|
+
minor: Number.parseInt(gitVersionMatches[2], 10),
|
|
126
|
+
patch: Number.parseInt(gitVersionMatches[3], 10),
|
|
125
127
|
}
|
|
126
128
|
} catch {
|
|
127
129
|
return null
|
|
@@ -71,7 +71,7 @@ function decomposeServerUrl (rawUrl, obfuscatedUrl) {
|
|
|
71
71
|
address = stripIpv6Brackets(hostname)
|
|
72
72
|
}
|
|
73
73
|
if (parsed.port) {
|
|
74
|
-
const parsedPort = Number.parseInt(parsed.port)
|
|
74
|
+
const parsedPort = Number.parseInt(parsed.port, 10)
|
|
75
75
|
if (parsedPort > 0) port = parsedPort
|
|
76
76
|
}
|
|
77
77
|
path = parsed.pathname || '/'
|
|
@@ -210,7 +210,7 @@ function applyHttpOtelSemantics (formattedSpan) {
|
|
|
210
210
|
// metric (the OTLP exporter serializes meta as stringValue but metrics as
|
|
211
211
|
// intValue) — mirroring how server.port is handled below. Guard against a
|
|
212
212
|
// non-numeric status, which would otherwise write a NaN metric.
|
|
213
|
-
statusCode = Number.parseInt(status)
|
|
213
|
+
statusCode = Number.parseInt(status, 10)
|
|
214
214
|
if (Number.isFinite(statusCode)) newMetrics[HTTP_RESPONSE_STATUS_CODE] = statusCode
|
|
215
215
|
}
|
|
216
216
|
|
|
@@ -258,7 +258,7 @@ function applyHttpOtelSemantics (formattedSpan) {
|
|
|
258
258
|
// type): server spans are errors on 5xx only (4xx MUST be left unset per the
|
|
259
259
|
// spec); client spans on any status >= 400.
|
|
260
260
|
if (status !== undefined && newMeta[ERROR_TYPE] === undefined) {
|
|
261
|
-
const isError = kind === 'server' ?
|
|
261
|
+
const isError = statusCode >= (kind === 'server' ? 500 : 400)
|
|
262
262
|
if (isError) {
|
|
263
263
|
newMeta[ERROR_TYPE] = status
|
|
264
264
|
formattedSpan.error = 1
|
|
@@ -36,7 +36,7 @@ const privateIPMatcher = new net.BlockList()
|
|
|
36
36
|
for (const cidr of privateCIDRs) {
|
|
37
37
|
const [address, prefix] = cidr.split('/')
|
|
38
38
|
|
|
39
|
-
privateIPMatcher.addSubnet(address, Number.parseInt(prefix), net.isIPv6(address) ? 'ipv6' : 'ipv4')
|
|
39
|
+
privateIPMatcher.addSubnet(address, Number.parseInt(prefix, 10), net.isIPv6(address) ? 'ipv6' : 'ipv4')
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
function extractIp (config, req) {
|
|
@@ -28,7 +28,7 @@ function normalize (text, limit = 128) {
|
|
|
28
28
|
* Determines whether a prompt completion should be sampled based on the configured sampling rate.
|
|
29
29
|
*
|
|
30
30
|
* @param {Sampler} sampler
|
|
31
|
-
* @param {import('
|
|
31
|
+
* @param {import('../../../../..').Span|import('../../../../..').SpanContext} span
|
|
32
32
|
* @returns {boolean} `true` if the prompt completion should be sampled, otherwise `false`.
|
|
33
33
|
*/
|
|
34
34
|
function isPromptCompletionSampled (sampler, span) {
|
|
@@ -51,7 +51,7 @@ module.exports = function makeUtilities (integrationName, tracerConfig) {
|
|
|
51
51
|
/**
|
|
52
52
|
* Determines whether a prompt completion should be sampled based on the configured sampling rate.
|
|
53
53
|
*
|
|
54
|
-
* @param {import('
|
|
54
|
+
* @param {import('../../../../..').Span|import('../../../../..').SpanContext} span
|
|
55
55
|
* @returns {boolean} `true` if the prompt completion should be sampled, otherwise `false`.
|
|
56
56
|
*/
|
|
57
57
|
isPromptCompletionSampled: (span) => isPromptCompletionSampled(sampler, span),
|
|
@@ -184,6 +184,9 @@ function isDDInstrumentationFile (fileName) {
|
|
|
184
184
|
* This function extracts the `myscript.js:10:3` part, passes it, returns the file name, line number, and column
|
|
185
185
|
* number and sets the `index` to the start of the whole location string.
|
|
186
186
|
*
|
|
187
|
+
* @param {string} stack the stack trace, or the nested location string when recursing
|
|
188
|
+
* @param {number} start index of the first character of the frame in `stack`
|
|
189
|
+
* @param {number} index index to start parsing backwards from
|
|
187
190
|
* @returns {[string, string, string, number]|undefined}
|
|
188
191
|
*/
|
|
189
192
|
function parseLocation (stack, start, index) {
|
|
@@ -26,6 +26,7 @@ const GIT_PULL_REQUEST_BASE_BRANCH = 'git.pull_request.base_branch'
|
|
|
26
26
|
|
|
27
27
|
const CI_PIPELINE_ID = 'ci.pipeline.id'
|
|
28
28
|
const CI_PIPELINE_NAME = 'ci.pipeline.name'
|
|
29
|
+
const CI_PIPELINE_DISPLAY_NAME = 'ci.pipeline.display_name'
|
|
29
30
|
const CI_PIPELINE_NUMBER = 'ci.pipeline.number'
|
|
30
31
|
const CI_PIPELINE_URL = 'ci.pipeline.url'
|
|
31
32
|
const CI_PROVIDER_NAME = 'ci.provider.name'
|
|
@@ -66,6 +67,7 @@ module.exports = {
|
|
|
66
67
|
GIT_PULL_REQUEST_BASE_BRANCH,
|
|
67
68
|
CI_PIPELINE_ID,
|
|
68
69
|
CI_PIPELINE_NAME,
|
|
70
|
+
CI_PIPELINE_DISPLAY_NAME,
|
|
69
71
|
CI_PIPELINE_NUMBER,
|
|
70
72
|
CI_PIPELINE_URL,
|
|
71
73
|
CI_PROVIDER_NAME,
|