Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDTEST-635] Enable agentless telemetry when library is running in agentless mode #221

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/datadog/ci/configuration/components.rb
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,13 @@ def configure_telemetry(settings)
# for test visibility we want to enable it by default unless explicitly disabled
# NOTE: before agentless mode is released, we only enable telemetry when running with Datadog Agent
env_telemetry_enabled = ENV[Core::Telemetry::Ext::ENV_ENABLED]
settings.telemetry.enabled = !settings.ci.agentless_mode_enabled &&
(env_telemetry_enabled.nil? || Utils::Parsing.convert_to_bool(env_telemetry_enabled))
settings.telemetry.enabled = env_telemetry_enabled.nil? || Utils::Parsing.convert_to_bool(env_telemetry_enabled)

return unless settings.telemetry.enabled

settings.telemetry.agentless_enabled = true if settings.ci.agentless_mode_enabled
settings.telemetry.shutdown_timeout_seconds = 60.0

begin
require "datadog/core/environment/identity"
require "datadog/core/telemetry/http/adapters/net"
Expand Down
13 changes: 11 additions & 2 deletions spec/datadog/ci/configuration/components_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@

negotiation = double(:negotiation)

telemetry_double = instance_double(
Datadog::Core::Telemetry::Component,
emit_closing!: nil,
stop!: nil
)
allow(Datadog::Core::Telemetry::Component).to receive(:build).and_return(telemetry_double)

allow(Datadog::Core::Remote::Negotiation)
.to receive(:new)
.and_return(negotiation)
Expand All @@ -76,6 +83,7 @@
.to receive(:async=).and_call_original

allow(settings.telemetry).to receive(:enabled=).and_call_original
allow(settings.telemetry).to receive(:agentless_enabled=).and_call_original

allow(Datadog::CI::Ext::Environment)
.to receive(:tags).and_return({})
Expand Down Expand Up @@ -246,8 +254,9 @@
context "when api key is set" do
let(:api_key) { "api_key" }

it "disables telemetry" do
expect(settings.telemetry).to have_received(:enabled=).with(false)
it "enables telemetry by default" do
expect(settings.telemetry).to have_received(:enabled=).with(true)
expect(settings.telemetry).to have_received(:agentless_enabled=).with(true)
end

it "sets async for test mode and constructs transport with CI intake API" do
Expand Down
Loading