Skip to content

Commit e737652

Browse files
Jamie van Brunschotalbertvaka
authored andcommitted
Add automatic scrubbing for tracing
1 parent ab8fa3f commit e737652

3 files changed

Lines changed: 80 additions & 1 deletion

File tree

manifests/init.pp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@
175175
# $apm_analyzed_spans
176176
# Hash defining the APM spans to analyze and their rates.
177177
# Optional Hash. Default: undef.
178+
# $apm_obfuscation
179+
# Hash defining obfuscation rules for sensitive data.
180+
# Optional Hash. Default: undef
178181
# $process_enabled
179182
# String to enable the process/container agent
180183
# Boolean. Default: false
@@ -300,6 +303,7 @@
300303
String $apm_env = 'none',
301304
Boolean $apm_non_local_traffic = false,
302305
Optional[Hash[String, Float[0, 1]]] $apm_analyzed_spans = undef,
306+
Optional[Hash[String, Data]] $apm_obfuscation = undef,
303307
Boolean $process_enabled = $datadog_agent::params::process_default_enabled,
304308
Boolean $scrub_args = $datadog_agent::params::process_default_scrub_args,
305309
Array $custom_sensitive_words = $datadog_agent::params::process_default_custom_words,
@@ -527,7 +531,7 @@
527531
}
528532
}
529533

530-
if ($apm_enabled == true) and ($apm_env != 'none') or $apm_analyzed_spans {
534+
if ($apm_enabled == true) and (($apm_env != 'none') or $apm_analyzed_spans or $apm_obfuscation) {
531535
concat::fragment{ 'datadog apm footer':
532536
target => '/etc/dd-agent/datadog.conf',
533537
content => template('datadog_agent/datadog_apm_footer.conf.erb'),
@@ -606,6 +610,16 @@
606610
$apm_analyzed_span_config = {}
607611
}
608612

613+
if $apm_obfuscation {
614+
$apm_obfuscation_config = {
615+
'apm_config' => {
616+
'obfuscation' => $apm_obfuscation
617+
}
618+
}
619+
} else {
620+
$apm_obfuscation_config = {}
621+
}
622+
609623
if $statsd_forward_host != '' {
610624
if $_statsd_forward_port != '' {
611625
$statsd_forward_config = {
@@ -634,6 +648,7 @@
634648
$logs_base_config,
635649
$agent_extra_options,
636650
$apm_analyzed_span_config,
651+
$apm_obfuscation_config,
637652
$statsd_forward_config,
638653
$host_config,
639654
$additional_checksd_config)

spec/classes/datadog_agent_spec.rb

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1909,6 +1909,62 @@
19091909
)
19101910
}
19111911
end
1912+
1913+
context 'with apm_enabled set to true and apm_obfuscation specified' do
1914+
let(:params) do
1915+
{
1916+
apm_enabled: true,
1917+
apm_obfuscation: {
1918+
elasticsearch: {
1919+
enable: true,
1920+
keep_values: [
1921+
'user_id',
1922+
'category_id',
1923+
],
1924+
},
1925+
redis: {
1926+
enable: true,
1927+
},
1928+
memcached: {
1929+
enable: true,
1930+
},
1931+
http: {
1932+
remove_query_string: true,
1933+
remove_paths_with_digits: true,
1934+
},
1935+
mongodb: {
1936+
enable: true,
1937+
keep_values: [
1938+
'uid',
1939+
'cat_id',
1940+
],
1941+
},
1942+
},
1943+
}
1944+
end
1945+
1946+
it {
1947+
is_expected.to contain_file('/etc/datadog-agent/datadog.yaml').with(
1948+
'content' => %r{^apm_config:\n},
1949+
)
1950+
}
1951+
it {
1952+
is_expected.to contain_file('/etc/datadog-agent/datadog.yaml').with(
1953+
'content' => %r{^apm_config:\n\ \ enabled: true\n},
1954+
)
1955+
}
1956+
it {
1957+
is_expected.to contain_file('/etc/datadog-agent/datadog.yaml').with(
1958+
'content' => %r{^\ \ obfuscation:\n},
1959+
)
1960+
}
1961+
it {
1962+
is_expected.to contain_file('/etc/datadog-agent/datadog.yaml').with(
1963+
'content' => %r{elasticsearch},
1964+
)
1965+
}
1966+
end
1967+
19121968
context 'with extra_options and Process enabled' do
19131969
let(:params) do
19141970
{

templates/datadog_apm_footer.conf.erb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,11 @@ env: <%= @apm_env %>
99
<%= span %>: <%= value %>
1010
<% end %>
1111
<% end -%>
12+
13+
<% if @apm_obfuscation -%>
14+
[trace.obfuscation]
15+
<% @apm_obfuscation.each do |service, data| -%>
16+
<%= service %>:
17+
<%= data %>
18+
<% end %>
19+
<% end -%>

0 commit comments

Comments
 (0)