Skip to content

Commit

Permalink
[apm] trace search (DataDog#485)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
lowkeyshift authored and truthbk committed Jan 22, 2019
1 parent 945fe5f commit d41cfd2
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Releases

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.

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

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.

Expand Down Expand Up @@ -300,6 +300,7 @@ These variables can be set in the `datadog_agent` class to control settings in t
| `non_local_traffic` | Set this to allow other nodes to relay their traffic through this one. |
| `agent5_enable` | A boolean to install Agent v5 and override the Agent v6 default. |
| `apm_enabled` | A boolean to enable the APM Agent (defaults to false). |
| `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 }` |
| `process_enabled` | A boolean to enable the process agent (defaults to false). |
| `scrub_args` | A boolean to enable the process cmdline scrubbing (defaults to true). |
| `custom_sensitive_words` | An array to add more words beyond the default ones used by the scrubbing feature (defaults to []). |
Expand Down
25 changes: 23 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@
# String. Default: non
# $apm_non_local_traffic
# Accept non local apm traffic. Defaults to false.
# Boolean. Default: false
# $apm_analyzed_spans
# Hash defining the APM spans to analyze and their rates.
# Optional Hash. Default: undef.
# $process_enabled
# String to enable the process/container agent
# Boolean. Default: false
Expand Down Expand Up @@ -297,6 +301,7 @@
$apm_enabled = $datadog_agent::params::apm_default_enabled,
$apm_env = 'none',
$apm_non_local_traffic = false,
Optional[Hash[String, Float[0, 1]]] $apm_analyzed_spans = undef,
$process_enabled = $datadog_agent::params::process_default_enabled,
$scrub_args = $datadog_agent::params::process_default_scrub_args,
$custom_sensitive_words = $datadog_agent::params::process_default_custom_words,
Expand Down Expand Up @@ -491,6 +496,7 @@
}

if $agent5_enable {

file { '/etc/dd-agent':
ensure => directory,
owner => $dd_user,
Expand Down Expand Up @@ -553,7 +559,7 @@
}
}

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

if $apm_analyzed_spans {
$apm_analyzed_span_config = {
'apm_config' => {
'apm_analyzed_spans' => $apm_analyzed_spans
}
}
} else {
$apm_analyzed_span_config = {}
}

if $statsd_forward_host != '' {
if $_statsd_forward_port != '' {
$statsd_forward_config = {
Expand All @@ -625,7 +641,12 @@
} else {
$statsd_forward_config = {}
}
$extra_config = deep_merge($base_extra_config, $agent6_extra_options, $statsd_forward_config, $host_config)
$extra_config = deep_merge(
$base_extra_config,
$agent6_extra_options,
$apm_analyzed_span_config,
$statsd_forward_config,
$host_config)

file { $conf6_dir:
ensure => directory,
Expand Down
40 changes: 40 additions & 0 deletions spec/classes/datadog_agent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,27 @@
'order' => '07',
)}
end
context 'with apm_enabled and apm_analyzed_spans set' do
let(:params) {{ :apm_enabled => true,
:agent5_enable => true,
:apm_analyzed_spans => {
'foo|bar' => 0.5,
'haz|qux' => 0.1
},
}}
it { should contain_concat__fragment('datadog footer').with(
'content' => /^apm_enabled: true\n/,
)}
it { should contain_concat__fragment('datadog apm footer').with(
'content' => /^\[trace.analyzed_spans\]\n/,
)}
it { should contain_concat__fragment('datadog apm footer').with(
'content' => /^\[trace.analyzed_spans\]\nfoo|bar: 0.5\nhaz|qux: 0.1/,
)}
it { should contain_concat__fragment('datadog apm footer').with(
'order' => '07',
)}
end
context 'with service_discovery enabled' do
let(:params) {{ :service_discovery_backend => 'docker',
:sd_config_backend => 'etcd',
Expand Down Expand Up @@ -1067,6 +1088,25 @@
'content' => /^\ \ apm_non_local_traffic: true\n/,
)}
end

context 'with apm_enabled set to true and apm_analyzed_spans specified' do
let(:params) {{
:apm_enabled => true,
:apm_analyzed_spans => {
'foo|bar' => 0.5,
'haz|qux' => 0.1
},
}}
it { should contain_file('/etc/datadog-agent/datadog.yaml').with(
'content' => /^apm_config:\n/,
)}
it { should contain_file('/etc/datadog-agent/datadog.yaml').with(
'content' => /^apm_config:\n\ \ enabled: true\n/,
)}
it { should contain_file('/etc/datadog-agent/datadog.yaml').with(
'content' => /^\ \ apm_analyzed_spans:\n\ \ \ \ foo|bar: 0.5\n\ \ \ \ haz|qux: 0.1\n/,
)}
end
context 'with extra_options and Process enabled' do
let(:params) {{
:apm_enabled => false,
Expand Down
7 changes: 7 additions & 0 deletions templates/datadog_apm_footer.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@
[trace.agent]
env: <%= @apm_env %>
<% end -%>

<% if @apm_analyzed_spans -%>
[trace.analyzed_spans]
<% @apm_analyzed_spans.each do |span, value| -%>
<%= span %>: <%= value %>
<% end %>
<% end -%>
1 change: 0 additions & 1 deletion templates/datadog_footer.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,6 @@ process_agent_enabled: <%= @process_enabled %>
# Enable the trace agent.
apm_enabled: <%= @apm_enabled %>


<% if not @extra_template.empty? -%>
# ========================================================================== #
# Custom Templates from Puppet #
Expand Down

0 comments on commit d41cfd2

Please sign in to comment.