Skip to content

Commit

Permalink
Remove ci.enabled from telemetry additional payload
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyCTHsu committed Nov 29, 2023
1 parent ef1693d commit 20f3360
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/datadog/core/telemetry/collector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ def tracer_time
private

TARGET_OPTIONS = [
'ci.enabled',
'logger.level',
'profiling.advanced.code_provenance_enabled',
'profiling.advanced.endpoint.collection.enabled',
Expand Down Expand Up @@ -145,6 +144,7 @@ def additional_payload_variables
format_configuration_value(configuration.tracing.writer_options[:flush_interval])
options['logger.instance'] = configuration.logger.instance.class.to_s
options['appsec.enabled'] = configuration.dig('appsec', 'enabled') if configuration.respond_to?('appsec')
options['ci.enabled'] = configuration.dig('ci', 'enabled') if configuration.respond_to?('ci')
options['tracing.opentelemetry.enabled'] = !defined?(Datadog::OpenTelemetry::LOADED).nil?
options['tracing.opentracing.enabled'] = !defined?(Datadog::OpenTracer::LOADED).nil?
options.compact!
Expand Down
32 changes: 32 additions & 0 deletions spec/datadog/core/telemetry/collector_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,38 @@
it { is_expected.to include('appsec.enabled' => true) }
end

context 'when ci is not loaded' do
it { is_expected.not_to include('ci.enabled') }
end

context 'when ci is enabled' do
around do |example|
Datadog.configuration.define_singleton_method(:ci) do
OpenStruct.new(enabled: true)
end
example.run
class << Datadog.configuration
remove_method(:ci)
end
end

it { is_expected.to include('ci.enabled' => true) }
end

context 'when ci is not enabled' do
around do |example|
Datadog.configuration.define_singleton_method(:ci) do
OpenStruct.new(enabled: false)
end
example.run
class << Datadog.configuration
remove_method(:ci)
end
end

it { is_expected.to include('ci.enabled' => false) }
end

context 'when OpenTelemetry is enabled' do
before do
stub_const('Datadog::OpenTelemetry::LOADED', true)
Expand Down

0 comments on commit 20f3360

Please sign in to comment.