Skip to content

Commit 410fca2

Browse files
authored
[apm] adding env tag to configuration. (#311)
* [apm] adding env tag to configuration. * [apm] fix typo in template.
1 parent 97128c6 commit 410fca2

3 files changed

Lines changed: 25 additions & 0 deletions

File tree

manifests/init.pp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@
154154
# $apm_enabled
155155
# Boolean to enable or disable the trace agent
156156
# Boolean. Default: false
157+
# $apm_env
158+
# String defining the environment for the APM traces
159+
# String. Default: empty
157160
#
158161
# Actions:
159162
#
@@ -241,6 +244,7 @@
241244
$dd_user = $datadog_agent::params::dd_user,
242245
$dd_group = $datadog_agent::params::dd_group,
243246
$apm_enabled = false,
247+
$apm_env = '',
244248
) inherits datadog_agent::params {
245249

246250
validate_string($dd_url)
@@ -302,6 +306,7 @@
302306
validate_bool($sd_jmx_enable)
303307
validate_string($consul_token)
304308
validate_bool($apm_enabled)
309+
validate_string($apm_env)
305310

306311
if $hiera_tags {
307312
$local_tags = hiera_array('datadog_agent::tags')

spec/classes/datadog_agent_spec.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,21 @@
512512
'content' => /^apm_enabled: true\n/,
513513
)}
514514
end
515+
context 'with apm_enabled set to true and env specified' do
516+
let(:params) {
517+
{:apm_enabled => true,
518+
:apm_env => 'foo',
519+
}}
520+
it { should contain_file('/etc/dd-agent/datadog.conf').with(
521+
'content' => /^apm_enabled: true\n/,
522+
)}
523+
it { should contain_file('/etc/dd-agent/datadog.conf').with(
524+
'content' => /^\[trace.agent\]\n/,
525+
)}
526+
it { should contain_file('/etc/dd-agent/datadog.conf').with(
527+
'content' => /^env: foo\n/,
528+
)}
529+
end
515530
context 'with service_discovery enabled' do
516531
let(:params) {
517532
{:service_discovery_backend => 'docker',

templates/datadog.conf.erb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,3 +414,8 @@ apm_enabled: <%= @apm_enabled %>
414414
# ========================================================================== #
415415

416416
<% end -%>
417+
418+
<% if not @apm_env.empty? -%>
419+
[trace.agent]
420+
env: <%= @apm_env %>
421+
<% end -%>

0 commit comments

Comments
 (0)