Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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: 3 additions & 3 deletions lib/datadog/core/configuration/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1057,13 +1057,13 @@ def initialize(*_)
end
end

# Enable experimental process tags propagation such that payloads like spans contain the process tag.
# Enable process tags propagation such that payloads like spans contain the process tag.
#
# @default `DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED` environment variable, otherwise `false`
# @default `DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED` environment variable, otherwise `true`
# @return [Boolean]
option :experimental_propagate_process_tags_enabled do |o|
Comment thread
wantsui marked this conversation as resolved.
o.env 'DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED'
o.default false
o.default true
o.type :bool
end

Expand Down
3 changes: 1 addition & 2 deletions lib/datadog/core/runtime/metrics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ def initialize(telemetry:, **options)
# Initialize the collection of runtime-id
@runtime_id_enabled = options.fetch(:experimental_runtime_id_enabled, false)

# Initialized process tags support
@process_tags_enabled = options.fetch(:experimental_propagate_process_tags_enabled, false)
@process_tags_enabled = options.fetch(:experimental_propagate_process_tags_enabled)
end

# Associate service with runtime metrics
Expand Down
10 changes: 9 additions & 1 deletion lib/datadog/core/workers/runtime_metrics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@ class RuntimeMetrics < Worker
:metrics

def initialize(telemetry:, **options)
@metrics = options.fetch(:metrics) { Core::Runtime::Metrics.new(logger: options[:logger], telemetry: telemetry) }
@metrics = options.fetch(:metrics) do
Core::Runtime::Metrics.new(
logger: options[:logger],
telemetry: telemetry,
experimental_propagate_process_tags_enabled: options.fetch(:propagate_process_tags_enabled) do
options.fetch(:experimental_propagate_process_tags_enabled)
end
)
Comment thread
wantsui marked this conversation as resolved.
end
Comment thread
ivoanjo marked this conversation as resolved.

# Workers::Async::Thread settings
self.fork_policy = options.fetch(:fork_policy, Workers::Async::Thread::FORK_POLICY_STOP)
Expand Down
34 changes: 6 additions & 28 deletions spec/datadog/core/configuration/settings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1407,39 +1407,17 @@
describe '#experimental_propagate_process_tags_enabled' do
subject(:experimental_propagate_process_tags_enabled) { settings.experimental_propagate_process_tags_enabled }

context "when #{Datadog::Core::Environment::Ext::ENV_VERSION}" do
around do |example|
ClimateControl.modify('DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED' => environment) do
example.run
end
end

context 'by default' do
let(:environment) { nil }

it { is_expected.to be false }
end

context 'when set to true' do
let(:environment) { 'true' }

it { is_expected.to be true }
end

context 'when set to false' do
let(:environment) { 'false' }

it { is_expected.to be false }
end
end
it_behaves_like 'a binary setting with',
env_variable: 'DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED',
default: true
end

describe '#experimental_propagate_process_tags_enabled=' do
it 'updates the #experimental_propagate_process_tags_enabled setting' do
expect { settings.experimental_propagate_process_tags_enabled = true }
expect { settings.experimental_propagate_process_tags_enabled = false }
.to change { settings.experimental_propagate_process_tags_enabled }
.from(false)
.to(true)
.from(true)
.to(false)
end
end

Expand Down
4 changes: 4 additions & 0 deletions spec/datadog/core/crashtracking/tag_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@
end

context 'when process tags propagation is not enabled' do
before do
settings.experimental_propagate_process_tags_enabled = false
end

it 'does not include process tags in the crash tracking payload' do
expect(call.keys).to_not include('process_tags')
end
Expand Down
12 changes: 8 additions & 4 deletions spec/datadog/core/remote/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@
env: settings.env,
}

expect(client_payload[:client_tracer].tap { |h| h.delete(:tags) }).to eq(expected_client_tracer)
expect(client_payload[:client_tracer]).to include(expected_client_tracer)
end
end

Expand All @@ -657,7 +657,7 @@
app_version: settings.version,
}

expect(client_payload[:client_tracer].tap { |h| h.delete(:tags) }).to eq(expected_client_tracer)
expect(client_payload[:client_tracer]).to include(expected_client_tracer)
end
end

Expand All @@ -673,7 +673,7 @@
env: settings.env,
}

expect(client_payload[:client_tracer].tap { |h| h.delete(:tags) }).to eq(expected_client_tracer)
expect(client_payload[:client_tracer]).to include(expected_client_tracer)
end
end
end
Expand All @@ -699,7 +699,11 @@
end

context 'when process tags propagation is not enabled' do
# Currently false by default
before do
# Explicitly disable because the global default is now true.
allow(settings).to receive(:experimental_propagate_process_tags_enabled).and_return(false)
end

it 'does not have process tags in the payload' do
expect(client_payload[:client_tracer]).not_to have_key(:process_tags)
end
Expand Down
14 changes: 13 additions & 1 deletion spec/datadog/core/runtime/metrics_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
RSpec.describe Datadog::Core::Runtime::Metrics do
let(:logger) { logger_allowing_debug }
let(:telemetry) { double(Datadog::Core::Telemetry::Component) }
let(:options) { {} }
let(:options) { {experimental_propagate_process_tags_enabled: true} }
subject(:runtime_metrics) { described_class.new(logger: logger, telemetry: telemetry, **options) }

describe '::new' do
Expand Down Expand Up @@ -325,6 +325,18 @@
describe ':tags' do
subject(:default_tags) { default_metric_options[:tags] }

context 'when :experimental_propagate_process_tags_enabled is true' do
before do
allow(Datadog::Core::Environment::Process).to receive(:tags)
.and_return(['entrypoint.workdir:test', 'entrypoint.name:test_script'])
end

it 'includes process tags by default' do
is_expected.to include('entrypoint.workdir:test')
is_expected.to include('entrypoint.name:test_script')
end
end

context 'given :experimental_runtime_id_enabled' do
let(:options) { super().merge(experimental_runtime_id_enabled: runtime_id_enabled) }
let(:runtime_id_enabled) { true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
'env' => nil,
'language_name' => 'ruby',
'language_version' => String,
'process_tags' => String,
'runtime_name' => /\Aj?ruby\z/i,
'runtime_version' => String,
'service_name' => String,
Expand Down
51 changes: 39 additions & 12 deletions spec/datadog/core/telemetry/request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
let(:service_name) { 'service' }
let(:service_version) { 'version' }
let(:tracer_version) { Datadog::Core::Environment::Identity.gem_datadog_version_semver2 }
let(:process_tags_enabled) { false }

let(:host) do
{
Expand All @@ -59,21 +60,47 @@
c.env = env
c.service = service_name
c.version = service_version
c.experimental_propagate_process_tags_enabled = process_tags_enabled
end
end

it do
is_expected.to match(
api_version: api_version,
application: application,
debug: debug,
host: host,
payload: payload,
request_type: request_type,
runtime_id: runtime_id,
seq_id: seq_id,
tracer_time: be_between(before_time, after_time),
)
context 'when process tags propagation is disabled' do
it do
is_expected.to match(
api_version: api_version,
application: application,
debug: debug,
host: host,
payload: payload,
request_type: request_type,
runtime_id: runtime_id,
seq_id: seq_id,
tracer_time: be_between(before_time, after_time),
)
end
end

context 'when process tags propagation is enabled' do
let(:process_tags_enabled) { true }
let(:process_tags) { 'entrypoint.workdir:test,entrypoint.name:test_script' }

before do
allow(Datadog::Core::Environment::Process).to receive(:serialized).and_return(process_tags)
end

it do
is_expected.to match(
api_version: api_version,
application: application.merge(process_tags: process_tags),
debug: debug,
host: host,
payload: payload,
request_type: request_type,
runtime_id: runtime_id,
seq_id: seq_id,
tracer_time: be_between(before_time, after_time),
)
end
Comment thread
ivoanjo marked this conversation as resolved.
end

context 'when Datadog::CI is loaded and ci mode is enabled' do
Expand Down
17 changes: 16 additions & 1 deletion spec/datadog/core/workers/runtime_metrics_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,27 @@
it { expect(worker).to be_a_kind_of(Datadog::Core::Workers::Polling) }

context 'by default' do
subject(:worker) { described_class.new(logger: logger, telemetry: telemetry) }
subject(:worker) do
described_class.new(
logger: logger,
telemetry: telemetry,
experimental_propagate_process_tags_enabled: true
)
end

it { expect(worker.enabled?).to be false }
it { expect(worker.loop_base_interval).to eq 10 }
it { expect(worker.loop_back_off_ratio).to eq 1.2 }
it { expect(worker.loop_back_off_max).to eq 30 }
it 'builds runtime metrics with process tags propagation setting' do
expect(Datadog::Core::Runtime::Metrics).to receive(:new).with(
logger: logger,
telemetry: telemetry,
experimental_propagate_process_tags_enabled: true,
).and_call_original

worker
end
end

context 'when :enabled is given' do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ def target_method
version: 2,
},
message: nil,
process_tags: String,
service: 'rspec',
timestamp: Integer,
}
Expand Down Expand Up @@ -480,6 +481,7 @@ def assert_received_and_errored
# false is the result of first expression evaluation
# second expression fails evaluation
message: 'hello false[evaluation error]',
process_tags: String,
service: 'rspec',
timestamp: Integer,
}
Expand Down Expand Up @@ -656,6 +658,7 @@ def assert_received_and_errored
},
# No message since we stopped execution at condition evaluation.
message: nil,
process_tags: String,
service: 'rspec',
timestamp: Integer,
}
Expand Down Expand Up @@ -740,6 +743,7 @@ def assert_received_and_errored
version: 2,
},
message: nil,
process_tags: String,
service: 'rspec',
timestamp: Integer,
}
Expand Down
4 changes: 4 additions & 0 deletions spec/datadog/di/probe_notification_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,10 @@
end

context 'when process tags propagation is not enabled' do
before do
allow(settings).to receive(:experimental_propagate_process_tags_enabled).and_return(false)
end

it 'excludes process tags in the payload' do
payload = builder.build_executed(context)
expect(payload).not_to include(:process_tags)
Expand Down
17 changes: 3 additions & 14 deletions spec/datadog/tracing/contrib/propagation/sql_comment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,7 @@

context 'and DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED=true' do
before do
Datadog.configure do |c|
c.experimental_propagate_process_tags_enabled = true
end
end

after do
without_warnings { Datadog.configuration.reset! }
allow(Datadog.configuration).to receive(:experimental_propagate_process_tags_enabled).and_return(true)
end

it 'sets the propagated hash (_dd.propagated_hash) on the span tag' do
Expand All @@ -72,13 +66,8 @@
end

context 'and DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED=false' do
around do |example|
without_warnings { Datadog.configuration.reset! }
Datadog.configure do |c|
c.experimental_propagate_process_tags_enabled = false
end
example.run
without_warnings { Datadog.configuration.reset! }
before do
allow(Datadog.configuration).to receive(:experimental_propagate_process_tags_enabled).and_return(false)
end

it 'does not set the propagated hash (_dd.propagated_hash) span tag' do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,7 @@

context 'when inject_sql_basehash is enabled and experimental_propagate_process_tags_enabled is true' do
before do
Datadog.configure do |c|
c.experimental_propagate_process_tags_enabled = true
end
end

after do
without_warnings { Datadog.configuration.reset! }
allow(Datadog.configuration).to receive(:experimental_propagate_process_tags_enabled).and_return(true)
end

let(:configuration_options) do
Expand All @@ -155,13 +149,8 @@
end

context 'when inject_sql_basehash is enabled but experimental_propagate_process_tags_enabled is false' do
around do |example|
without_warnings { Datadog.configuration.reset! }
Datadog.configure do |c|
c.experimental_propagate_process_tags_enabled = false
end
example.run
without_warnings { Datadog.configuration.reset! }
before do
allow(Datadog.configuration).to receive(:experimental_propagate_process_tags_enabled).and_return(false)
end

let(:configuration_options) do
Expand All @@ -178,13 +167,8 @@
end

context 'when inject_sql_basehash is disabled but experimental_propagate_process_tags_enabled is true' do
around do |example|
without_warnings { Datadog.configuration.reset! }
Datadog.configure do |c|
c.experimental_propagate_process_tags_enabled = true
end
example.run
without_warnings { Datadog.configuration.reset! }
before do
allow(Datadog.configuration).to receive(:experimental_propagate_process_tags_enabled).and_return(true)
end

let(:configuration_options) do
Expand Down
Loading
Loading