Skip to content

Commit 6b7f5c8

Browse files
lowkeyshifttruthbk
authored andcommitted
[apm] trace search (#485)
* Added the ability to apm events for trace search * [apm] adding apm_analyzed_spans for A6 * [apm] adding support for APM analyze spans in A5 + changing argument to hash * [readme] docs + broken table + init description
1 parent abfa576 commit 6b7f5c8

File tree

5 files changed

+72
-4
lines changed

5 files changed

+72
-4
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Releases
1616

1717
There are currently two actively maintained versions for the Puppet module. For users on Puppet >= 4.6.x, and possibly some older 4.x puppets, it is recommended to use version 2.0+ of the module.
1818

19-
For users running on older versions of Puppet the legacy module, series 1.x, should support most use-cases.
19+
For users running on older versions of Puppet the legacy module, series 1.x, should support most use-cases.
2020

2121
The majority of users should be able to use the newer module as many of the Puppet versions supported in the 1.x series of the module have been EOL'd.
2222

@@ -300,6 +300,7 @@ These variables can be set in the `datadog_agent` class to control settings in t
300300
| `non_local_traffic` | Set this to allow other nodes to relay their traffic through this one. |
301301
| `agent5_enable` | A boolean to install Agent v5 and override the Agent v6 default. |
302302
| `apm_enabled` | A boolean to enable the APM Agent (defaults to false). |
303+
| `apm_analyzed_spans` | A hash to add APM events for the Trace Search & Analytics tool. (defaults to undef). For example: `{ 'app\|rails.request' => 1, 'service-name\|operation-name' => 0.8 }` |
303304
| `process_enabled` | A boolean to enable the process agent (defaults to false). |
304305
| `scrub_args` | A boolean to enable the process cmdline scrubbing (defaults to true). |
305306
| `custom_sensitive_words` | An array to add more words beyond the default ones used by the scrubbing feature (defaults to []). |

manifests/init.pp

+23-2
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@
179179
# String. Default: non
180180
# $apm_non_local_traffic
181181
# Accept non local apm traffic. Defaults to false.
182+
# Boolean. Default: false
183+
# $apm_analyzed_spans
184+
# Hash defining the APM spans to analyze and their rates.
185+
# Optional Hash. Default: undef.
182186
# $process_enabled
183187
# String to enable the process/container agent
184188
# Boolean. Default: false
@@ -297,6 +301,7 @@
297301
$apm_enabled = $datadog_agent::params::apm_default_enabled,
298302
$apm_env = 'none',
299303
$apm_non_local_traffic = false,
304+
Optional[Hash[String, Float[0, 1]]] $apm_analyzed_spans = undef,
300305
$process_enabled = $datadog_agent::params::process_default_enabled,
301306
$scrub_args = $datadog_agent::params::process_default_scrub_args,
302307
$custom_sensitive_words = $datadog_agent::params::process_default_custom_words,
@@ -491,6 +496,7 @@
491496
}
492497

493498
if $agent5_enable {
499+
494500
file { '/etc/dd-agent':
495501
ensure => directory,
496502
owner => $dd_user,
@@ -553,7 +559,7 @@
553559
}
554560
}
555561

556-
if ($apm_enabled == true) and ($apm_env != 'none') {
562+
if ($apm_enabled == true) and ($apm_env != 'none') or $apm_analyzed_spans {
557563
concat::fragment{ 'datadog apm footer':
558564
target => '/etc/dd-agent/datadog.conf',
559565
content => template('datadog_agent/datadog_apm_footer.conf.erb'),
@@ -611,6 +617,16 @@
611617
$host_config = {}
612618
}
613619

620+
if $apm_analyzed_spans {
621+
$apm_analyzed_span_config = {
622+
'apm_config' => {
623+
'apm_analyzed_spans' => $apm_analyzed_spans
624+
}
625+
}
626+
} else {
627+
$apm_analyzed_span_config = {}
628+
}
629+
614630
if $statsd_forward_host != '' {
615631
if $_statsd_forward_port != '' {
616632
$statsd_forward_config = {
@@ -625,7 +641,12 @@
625641
} else {
626642
$statsd_forward_config = {}
627643
}
628-
$extra_config = deep_merge($base_extra_config, $agent6_extra_options, $statsd_forward_config, $host_config)
644+
$extra_config = deep_merge(
645+
$base_extra_config,
646+
$agent6_extra_options,
647+
$apm_analyzed_span_config,
648+
$statsd_forward_config,
649+
$host_config)
629650

630651
file { $conf6_dir:
631652
ensure => directory,

spec/classes/datadog_agent_spec.rb

+40
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,27 @@
690690
'order' => '07',
691691
)}
692692
end
693+
context 'with apm_enabled and apm_analyzed_spans set' do
694+
let(:params) {{ :apm_enabled => true,
695+
:agent5_enable => true,
696+
:apm_analyzed_spans => {
697+
'foo|bar' => 0.5,
698+
'haz|qux' => 0.1
699+
},
700+
}}
701+
it { should contain_concat__fragment('datadog footer').with(
702+
'content' => /^apm_enabled: true\n/,
703+
)}
704+
it { should contain_concat__fragment('datadog apm footer').with(
705+
'content' => /^\[trace.analyzed_spans\]\n/,
706+
)}
707+
it { should contain_concat__fragment('datadog apm footer').with(
708+
'content' => /^\[trace.analyzed_spans\]\nfoo|bar: 0.5\nhaz|qux: 0.1/,
709+
)}
710+
it { should contain_concat__fragment('datadog apm footer').with(
711+
'order' => '07',
712+
)}
713+
end
693714
context 'with service_discovery enabled' do
694715
let(:params) {{ :service_discovery_backend => 'docker',
695716
:sd_config_backend => 'etcd',
@@ -1067,6 +1088,25 @@
10671088
'content' => /^\ \ apm_non_local_traffic: true\n/,
10681089
)}
10691090
end
1091+
1092+
context 'with apm_enabled set to true and apm_analyzed_spans specified' do
1093+
let(:params) {{
1094+
:apm_enabled => true,
1095+
:apm_analyzed_spans => {
1096+
'foo|bar' => 0.5,
1097+
'haz|qux' => 0.1
1098+
},
1099+
}}
1100+
it { should contain_file('/etc/datadog-agent/datadog.yaml').with(
1101+
'content' => /^apm_config:\n/,
1102+
)}
1103+
it { should contain_file('/etc/datadog-agent/datadog.yaml').with(
1104+
'content' => /^apm_config:\n\ \ enabled: true\n/,
1105+
)}
1106+
it { should contain_file('/etc/datadog-agent/datadog.yaml').with(
1107+
'content' => /^\ \ apm_analyzed_spans:\n\ \ \ \ foo|bar: 0.5\n\ \ \ \ haz|qux: 0.1\n/,
1108+
)}
1109+
end
10701110
context 'with extra_options and Process enabled' do
10711111
let(:params) {{
10721112
:apm_enabled => false,

templates/datadog_apm_footer.conf.erb

+7
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,10 @@
22
[trace.agent]
33
env: <%= @apm_env %>
44
<% end -%>
5+
6+
<% if @apm_analyzed_spans -%>
7+
[trace.analyzed_spans]
8+
<% @apm_analyzed_spans.each do |span, value| -%>
9+
<%= span %>: <%= value %>
10+
<% end %>
11+
<% end -%>

templates/datadog_footer.conf.erb

-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,6 @@ process_agent_enabled: <%= @process_enabled %>
347347
# Enable the trace agent.
348348
apm_enabled: <%= @apm_enabled %>
349349

350-
351350
<% if not @extra_template.empty? -%>
352351
# ========================================================================== #
353352
# Custom Templates from Puppet #

0 commit comments

Comments
 (0)