Skip to content

Commit 3d4ac00

Browse files
wantsuimabdinur
andauthored
enable process tags to true by default (#5432)
* Set the default of DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED to true and adjust tests * Remove the process tags from the remote client payload since it is not needed for the test * Adjust DBM tests for the new default true setting * Adjust telemetry payload in tests due to the new default * Fix another dbm test for the true default for process tag * Add the process tags payload to the remote config payload in tests since it defaults to true now * Change supported-configurations.json from A to B * Remove fallback for runtime metrics and update runtime metrics tests to match * Simplify the settings_spec test per review * Bring back tags and process_tags when testing remote client_spec * Adjust telemetry tests to start off with the assumption that process tags are disabled to avoid mixing testing concerns * Update spec/datadog/core/workers/runtime_metrics_spec.rb Co-authored-by: Munir Abdinur <munir.abdinur@datadoghq.com> * Refactor runtime_metrics_spec.rb to use receive syntax * Add an internal alias for propagate_process_tags_enabled that doesn't include experimental and adjust specs to match * Add missing test * Add back the experimental designation so it can be deleted later --------- Co-authored-by: Munir Abdinur <munir.abdinur@datadoghq.com>
1 parent 6f300a1 commit 3d4ac00

16 files changed

Lines changed: 127 additions & 92 deletions

File tree

‎lib/datadog/core/configuration/settings.rb‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,13 +1057,13 @@ def initialize(*_)
10571057
end
10581058
end
10591059

1060-
# Enable experimental process tags propagation such that payloads like spans contain the process tag.
1060+
# Enable process tags propagation such that payloads like spans contain the process tag.
10611061
#
1062-
# @default `DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED` environment variable, otherwise `false`
1062+
# @default `DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED` environment variable, otherwise `true`
10631063
# @return [Boolean]
10641064
option :experimental_propagate_process_tags_enabled do |o|
10651065
o.env 'DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED'
1066-
o.default false
1066+
o.default true
10671067
o.type :bool
10681068
end
10691069

‎lib/datadog/core/runtime/metrics.rb‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ def initialize(telemetry:, **options)
2626
# Initialize the collection of runtime-id
2727
@runtime_id_enabled = options.fetch(:experimental_runtime_id_enabled, false)
2828

29-
# Initialized process tags support
30-
@process_tags_enabled = options.fetch(:experimental_propagate_process_tags_enabled, false)
29+
@process_tags_enabled = options.fetch(:experimental_propagate_process_tags_enabled)
3130
end
3231

3332
# Associate service with runtime metrics

‎lib/datadog/core/workers/runtime_metrics.rb‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,15 @@ class RuntimeMetrics < Worker
2121
:metrics
2222

2323
def initialize(telemetry:, **options)
24-
@metrics = options.fetch(:metrics) { Core::Runtime::Metrics.new(logger: options[:logger], telemetry: telemetry) }
24+
@metrics = options.fetch(:metrics) do
25+
Core::Runtime::Metrics.new(
26+
logger: options[:logger],
27+
telemetry: telemetry,
28+
experimental_propagate_process_tags_enabled: options.fetch(:propagate_process_tags_enabled) do
29+
options.fetch(:experimental_propagate_process_tags_enabled)
30+
end
31+
)
32+
end
2533

2634
# Workers::Async::Thread settings
2735
self.fork_policy = options.fetch(:fork_policy, Workers::Async::Thread::FORK_POLICY_STOP)

‎spec/datadog/core/configuration/settings_spec.rb‎

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,39 +1407,17 @@
14071407
describe '#experimental_propagate_process_tags_enabled' do
14081408
subject(:experimental_propagate_process_tags_enabled) { settings.experimental_propagate_process_tags_enabled }
14091409

1410-
context "when #{Datadog::Core::Environment::Ext::ENV_VERSION}" do
1411-
around do |example|
1412-
ClimateControl.modify('DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED' => environment) do
1413-
example.run
1414-
end
1415-
end
1416-
1417-
context 'by default' do
1418-
let(:environment) { nil }
1419-
1420-
it { is_expected.to be false }
1421-
end
1422-
1423-
context 'when set to true' do
1424-
let(:environment) { 'true' }
1425-
1426-
it { is_expected.to be true }
1427-
end
1428-
1429-
context 'when set to false' do
1430-
let(:environment) { 'false' }
1431-
1432-
it { is_expected.to be false }
1433-
end
1434-
end
1410+
it_behaves_like 'a binary setting with',
1411+
env_variable: 'DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED',
1412+
default: true
14351413
end
14361414

14371415
describe '#experimental_propagate_process_tags_enabled=' do
14381416
it 'updates the #experimental_propagate_process_tags_enabled setting' do
1439-
expect { settings.experimental_propagate_process_tags_enabled = true }
1417+
expect { settings.experimental_propagate_process_tags_enabled = false }
14401418
.to change { settings.experimental_propagate_process_tags_enabled }
1441-
.from(false)
1442-
.to(true)
1419+
.from(true)
1420+
.to(false)
14431421
end
14441422
end
14451423

‎spec/datadog/core/crashtracking/tag_builder_spec.rb‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@
127127
end
128128

129129
context 'when process tags propagation is not enabled' do
130+
before do
131+
settings.experimental_propagate_process_tags_enabled = false
132+
end
133+
130134
it 'does not include process tags in the crash tracking payload' do
131135
expect(call.keys).to_not include('process_tags')
132136
end

‎spec/datadog/core/remote/client_spec.rb‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@
640640
env: settings.env,
641641
}
642642

643-
expect(client_payload[:client_tracer].tap { |h| h.delete(:tags) }).to eq(expected_client_tracer)
643+
expect(client_payload[:client_tracer]).to include(expected_client_tracer)
644644
end
645645
end
646646

@@ -657,7 +657,7 @@
657657
app_version: settings.version,
658658
}
659659

660-
expect(client_payload[:client_tracer].tap { |h| h.delete(:tags) }).to eq(expected_client_tracer)
660+
expect(client_payload[:client_tracer]).to include(expected_client_tracer)
661661
end
662662
end
663663

@@ -673,7 +673,7 @@
673673
env: settings.env,
674674
}
675675

676-
expect(client_payload[:client_tracer].tap { |h| h.delete(:tags) }).to eq(expected_client_tracer)
676+
expect(client_payload[:client_tracer]).to include(expected_client_tracer)
677677
end
678678
end
679679
end
@@ -699,7 +699,11 @@
699699
end
700700

701701
context 'when process tags propagation is not enabled' do
702-
# Currently false by default
702+
before do
703+
# Explicitly disable because the global default is now true.
704+
allow(settings).to receive(:experimental_propagate_process_tags_enabled).and_return(false)
705+
end
706+
703707
it 'does not have process tags in the payload' do
704708
expect(client_payload[:client_tracer]).not_to have_key(:process_tags)
705709
end

‎spec/datadog/core/runtime/metrics_spec.rb‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
RSpec.describe Datadog::Core::Runtime::Metrics do
77
let(:logger) { logger_allowing_debug }
88
let(:telemetry) { double(Datadog::Core::Telemetry::Component) }
9-
let(:options) { {} }
9+
let(:options) { {experimental_propagate_process_tags_enabled: true} }
1010
subject(:runtime_metrics) { described_class.new(logger: logger, telemetry: telemetry, **options) }
1111

1212
describe '::new' do
@@ -325,6 +325,18 @@
325325
describe ':tags' do
326326
subject(:default_tags) { default_metric_options[:tags] }
327327

328+
context 'when :experimental_propagate_process_tags_enabled is true' do
329+
before do
330+
allow(Datadog::Core::Environment::Process).to receive(:tags)
331+
.and_return(['entrypoint.workdir:test', 'entrypoint.name:test_script'])
332+
end
333+
334+
it 'includes process tags by default' do
335+
is_expected.to include('entrypoint.workdir:test')
336+
is_expected.to include('entrypoint.name:test_script')
337+
end
338+
end
339+
328340
context 'given :experimental_runtime_id_enabled' do
329341
let(:options) { super().merge(experimental_runtime_id_enabled: runtime_id_enabled) }
330342
let(:runtime_id_enabled) { true }

‎spec/datadog/core/telemetry/integration/telemetry_spec.rb‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
'env' => nil,
5858
'language_name' => 'ruby',
5959
'language_version' => String,
60+
'process_tags' => String,
6061
'runtime_name' => /\Aj?ruby\z/i,
6162
'runtime_version' => String,
6263
'service_name' => String,

‎spec/datadog/core/telemetry/request_spec.rb‎

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
let(:service_name) { 'service' }
3838
let(:service_version) { 'version' }
3939
let(:tracer_version) { Datadog::Core::Environment::Identity.gem_datadog_version_semver2 }
40+
let(:process_tags_enabled) { false }
4041

4142
let(:host) do
4243
{
@@ -59,21 +60,47 @@
5960
c.env = env
6061
c.service = service_name
6162
c.version = service_version
63+
c.experimental_propagate_process_tags_enabled = process_tags_enabled
6264
end
6365
end
6466

65-
it do
66-
is_expected.to match(
67-
api_version: api_version,
68-
application: application,
69-
debug: debug,
70-
host: host,
71-
payload: payload,
72-
request_type: request_type,
73-
runtime_id: runtime_id,
74-
seq_id: seq_id,
75-
tracer_time: be_between(before_time, after_time),
76-
)
67+
context 'when process tags propagation is disabled' do
68+
it do
69+
is_expected.to match(
70+
api_version: api_version,
71+
application: application,
72+
debug: debug,
73+
host: host,
74+
payload: payload,
75+
request_type: request_type,
76+
runtime_id: runtime_id,
77+
seq_id: seq_id,
78+
tracer_time: be_between(before_time, after_time),
79+
)
80+
end
81+
end
82+
83+
context 'when process tags propagation is enabled' do
84+
let(:process_tags_enabled) { true }
85+
let(:process_tags) { 'entrypoint.workdir:test,entrypoint.name:test_script' }
86+
87+
before do
88+
allow(Datadog::Core::Environment::Process).to receive(:serialized).and_return(process_tags)
89+
end
90+
91+
it do
92+
is_expected.to match(
93+
api_version: api_version,
94+
application: application.merge(process_tags: process_tags),
95+
debug: debug,
96+
host: host,
97+
payload: payload,
98+
request_type: request_type,
99+
runtime_id: runtime_id,
100+
seq_id: seq_id,
101+
tracer_time: be_between(before_time, after_time),
102+
)
103+
end
77104
end
78105

79106
context 'when Datadog::CI is loaded and ci mode is enabled' do

‎spec/datadog/core/workers/runtime_metrics_spec.rb‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,27 @@
2020
it { expect(worker).to be_a_kind_of(Datadog::Core::Workers::Polling) }
2121

2222
context 'by default' do
23-
subject(:worker) { described_class.new(logger: logger, telemetry: telemetry) }
23+
subject(:worker) do
24+
described_class.new(
25+
logger: logger,
26+
telemetry: telemetry,
27+
experimental_propagate_process_tags_enabled: true
28+
)
29+
end
2430

2531
it { expect(worker.enabled?).to be false }
2632
it { expect(worker.loop_base_interval).to eq 10 }
2733
it { expect(worker.loop_back_off_ratio).to eq 1.2 }
2834
it { expect(worker.loop_back_off_max).to eq 30 }
35+
it 'builds runtime metrics with process tags propagation setting' do
36+
expect(Datadog::Core::Runtime::Metrics).to receive(:new).with(
37+
logger: logger,
38+
telemetry: telemetry,
39+
experimental_propagate_process_tags_enabled: true,
40+
).and_call_original
41+
42+
worker
43+
end
2944
end
3045

3146
context 'when :enabled is given' do

0 commit comments

Comments
 (0)