Skip to content

Commit

Permalink
log an error message if tracing is disabled but test visibility is en…
Browse files Browse the repository at this point in the history
…abled
  • Loading branch information
anmarchenko committed May 13, 2024
1 parent 0c97a8c commit d7e1b11
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/datadog/ci/configuration/components.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions spec/datadog/ci/configuration/components_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 }
Expand All @@ -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 }

Expand Down

0 comments on commit d7e1b11

Please sign in to comment.