From d7e1b110fa56ad3745c81893023767d6fa59a058 Mon Sep 17 00:00:00 2001 From: Andrey Date: Mon, 13 May 2024 15:27:52 +0200 Subject: [PATCH] log an error message if tracing is disabled but test visibility is enabled --- lib/datadog/ci/configuration/components.rb | 10 ++++++++++ spec/datadog/ci/configuration/components_spec.rb | 12 ++++++++++++ 2 files changed, 22 insertions(+) diff --git a/lib/datadog/ci/configuration/components.rb b/lib/datadog/ci/configuration/components.rb index a729fc39..18008c1c 100644 --- a/lib/datadog/ci/configuration/components.rb +++ b/lib/datadog/ci/configuration/components.rb @@ -43,6 +43,16 @@ def shutdown!(replacement = nil) end def activate_ci!(settings) + unless settings.tracing.enabled + Datadog.logger.error( + "CI visibility requires tracing to be enabled. Disabling CI visibility. " \ + "NOTE: if you didn't disable tracing intentionally, add `c.tracing enabled = true` to " \ + "your Datadog.configure block." + ) + settings.ci.enabled = false + return + end + # Configure ddtrace library for CI visibility mode # Deactivate telemetry settings.telemetry.enabled = false diff --git a/spec/datadog/ci/configuration/components_spec.rb b/spec/datadog/ci/configuration/components_spec.rb index 3f8ec57e..ff9e2e36 100644 --- a/spec/datadog/ci/configuration/components_spec.rb +++ b/spec/datadog/ci/configuration/components_spec.rb @@ -36,6 +36,7 @@ context "when #ci" do before do # Configure CI mode + settings.tracing.enabled = tracing_enabled settings.ci.enabled = enabled settings.ci.agentless_mode_enabled = agentless_enabled @@ -95,6 +96,7 @@ let(:evp_proxy_v2_supported) { false } let(:evp_proxy_v4_supported) { false } let(:itr_enabled) { false } + let(:tracing_enabled) { true } context "is enabled" do let(:enabled) { true } @@ -103,6 +105,16 @@ expect(Datadog::CI::Ext::Environment).to have_received(:tags).with(ENV) end + context "when tracing is disabled" do + let(:tracing_enabled) { false } + + it "logs an error message and disables CI visibility" do + expect(Datadog.logger).to have_received(:error) + + expect(settings.ci.enabled).to eq(false) + end + end + context "when #force_test_level_visibility" do let(:evp_proxy_v2_supported) { true }