Skip to content

Commit

Permalink
puppet: Support new zero config (#3922)
Browse files Browse the repository at this point in the history
* puppet: Support new zero config

* update readme

* feedback updates
  • Loading branch information
jeffreyc-splunk authored Nov 14, 2023
1 parent 9db038d commit 137c9d2
Show file tree
Hide file tree
Showing 10 changed files with 328 additions and 170 deletions.
19 changes: 15 additions & 4 deletions .github/workflows/puppet-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ jobs:
exit 1
fi
distro=$(for d in $dockerfiles; do echo -n "\"$d\","; done)
matrix="{\"DISTRO\": [${distro%,}], \"PUPPET_RELEASE\": [\"6\",\"7\"]}"
puppet_release='"6","7"'
with_instrumentation='"true","false"'
matrix="{\"DISTRO\": [${distro%,}], \"PUPPET_RELEASE\": [${puppet_release}], \"WITH_INSTRUMENTATION\": [${with_instrumentation}]}"
echo "$matrix" | jq
echo "matrix=${matrix}" >> $GITHUB_OUTPUT
outputs:
Expand Down Expand Up @@ -111,7 +113,12 @@ jobs:
# workaround for pytest substring matching
distro="amazonlinux-2 and not amazonlinux-2023"
fi
python3 -u -m pytest -s --verbose -k "$distro" \
if [[ "${{ matrix.WITH_INSTRUMENTATION }}" = "true" ]]; then
tests="$distro and instrumentation"
else
tests="$distro and not instrumentation"
fi
python3 -u -m pytest -s --verbose -k "$tests" \
internal/buildscripts/packaging/tests/deployments/puppet/puppet_test.py
env:
PUPPET_RELEASE: "${{ matrix.PUPPET_RELEASE }}"
Expand All @@ -125,10 +132,14 @@ jobs:
# workaround for pytest substring matching
distro="amazonlinux-2 and not amazonlinux-2023"
fi
python3 -u -m pytest -s --verbose -k "$distro" \
if [[ "${{ matrix.WITH_INSTRUMENTATION }}" = "true" ]]; then
tests="$distro and instrumentation"
else
tests="$distro and not instrumentation"
fi
python3 -u -m pytest -s --verbose -k "$tests" \
--last-failed \
internal/buildscripts/packaging/tests/deployments/puppet/puppet_test.py
exit 1
env:
PUPPET_RELEASE: "${{ matrix.PUPPET_RELEASE }}"

Expand Down
10 changes: 10 additions & 0 deletions deployments/puppet/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

## Unreleased

## puppet-v0.12.0

- **Deprecations**: The `auto_instrumentation_generate_service_name` and `auto_instrumentation_disable_telemetry`
options are deprecated and only applicable if the `auto_instrumentation_version` option is < `0.87.0`.
- Support Splunk OpenTelemetry Auto Instrumentation for Linux [v0.87.0](
https://github.com/signalfx/splunk-otel-collector/releases/tag/v0.87.0) and newer (Java only).
- Support activation and configuration of auto instrumentation for only `systemd` services.
- Support setting the OTLP exporter endpoint for auto instrumentation (default: `http://127.0.0.1:4317`). Only
applicable if the `auto_instrumentation_version` option is `latest` or >= `0.87.0`.

## puppet-v0.11.0

- Add support for `splunk_listen_interface` used by default configurations as `SPLUNK_LISTEN_INTERFACE` environment variable (only populated if set).
Expand Down
85 changes: 51 additions & 34 deletions deployments/puppet/README.md

Large diffs are not rendered by default.

36 changes: 32 additions & 4 deletions deployments/puppet/manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
$manage_repo = true, # linux only
$with_auto_instrumentation = false, # linux only
$auto_instrumentation_version = $splunk_otel_collector::params::auto_instrumentation_version, # linux only
$auto_instrumentation_systemd = false, # linux only
$auto_instrumentation_ld_so_preload = '', # linux only
$auto_instrumentation_java_agent_jar = $splunk_otel_collector::params::auto_instrumentation_java_agent_jar, # linux only
$auto_instrumentation_resource_attributes = '', # linux only
Expand All @@ -44,6 +45,7 @@
$auto_instrumentation_enable_profiler = false, # linux only
$auto_instrumentation_enable_profiler_memory = false, # linux only
$auto_instrumentation_enable_metrics = false, # linux only
$auto_instrumentation_otlp_endpoint = 'http://127.0.0.1:4317', # linux only
$collector_additional_env_vars = {}
) inherits splunk_otel_collector::params {

Expand Down Expand Up @@ -363,7 +365,10 @@
if $with_auto_instrumentation {
$auto_instrumentation_package_name = 'splunk-otel-auto-instrumentation'
$ld_so_preload_path = '/etc/ld.so.preload'
$libsplunk_path = '/usr/lib/splunk-instrumentation/libsplunk.so'
$instrumentation_config_path = '/usr/lib/splunk-instrumentation/instrumentation.conf'
$zeroconfig_java_config_path = '/etc/splunk/zeroconfig/java.conf'
$zeroconfig_systemd_config_path = '/usr/lib/systemd/system.conf.d/00-splunk-otel-auto-instrumentation.conf'

if $::osfamily == 'debian' {
package { $auto_instrumentation_package_name:
Expand All @@ -385,10 +390,33 @@
require => Package[$auto_instrumentation_package_name],
}

file { $instrumentation_config_path:
ensure => file,
content => template('splunk_otel_collector/instrumentation.conf.erb'),
require => Package[$auto_instrumentation_package_name],
if $auto_instrumentation_systemd {
file { ['/usr/lib/systemd', '/usr/lib/systemd/system.conf.d']:
ensure => directory,
}
-> file { $zeroconfig_systemd_config_path:
ensure => file,
content => template('splunk_otel_collector/00-splunk-otel-auto-instrumentation.conf.erb'),
require => Package[$auto_instrumentation_package_name],
notify => Exec['systemctl daemon-reload'],
}
} else {
file { $zeroconfig_systemd_config_path:
ensure => absent,
}
if $auto_instrumentation_version == 'latest' or versioncmp($auto_instrumentation_version, '0.87.0') >= 0 {
file { $zeroconfig_java_config_path:
ensure => file,
content => template('splunk_otel_collector/java.conf.erb'),
require => Package[$auto_instrumentation_package_name],
}
} else {
file { $instrumentation_config_path:
ensure => file,
content => template('splunk_otel_collector/instrumentation.conf.erb'),
require => Package[$auto_instrumentation_package_name],
}
}
}
}
}
2 changes: 1 addition & 1 deletion deployments/puppet/metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "signalfx-splunk_otel_collector",
"version": "0.11.0",
"version": "0.12.0",
"author": "Splunk, Inc.",
"summary": "This module installs the Splunk OpenTelemetry Collector via distro packages and configures it.",
"license": "Apache-2.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Manager]
DefaultEnvironment="JAVA_TOOL_OPTIONS=-javaagent:<%= @auto_instrumentation_java_agent_jar %>"
<% if defined?(@auto_instrumentation_resource_attributes) && @auto_instrumentation_resource_attributes != "" -%>
DefaultEnvironment="OTEL_RESOURCE_ATTRIBUTES=splunk.zc.method=splunk-otel-auto-instrumentation-<%= @auto_instrumentation_version %>-systemd,<%= @auto_instrumentation_resource_attributes %>"
<% else -%>
DefaultEnvironment="OTEL_RESOURCE_ATTRIBUTES=splunk.zc.method=splunk-otel-auto-instrumentation-<%= @auto_instrumentation_version %>-systemd"
<% end -%>
<% if defined?(@auto_instrumentation_service_name) && @auto_instrumentation_service_name != "" -%>
DefaultEnvironment="OTEL_SERVICE_NAME=<%= @auto_instrumentation_service_name %>"
<% end -%>
DefaultEnvironment="SPLUNK_PROFILER_ENABLED=<%= @auto_instrumentation_enable_profiler.to_s.downcase %>"
DefaultEnvironment="SPLUNK_PROFILER_MEMORY_ENABLED=<%= @auto_instrumentation_enable_profiler_memory.to_s.downcase %>"
DefaultEnvironment="SPLUNK_METRICS_ENABLED=<%= @auto_instrumentation_enable_metrics.to_s.downcase %>"
DefaultEnvironment="OTEL_EXPORTER_OTLP_ENDPOINT=<%= @auto_instrumentation_otlp_endpoint %>"
4 changes: 3 additions & 1 deletion deployments/puppet/templates/instrumentation.conf.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
java_agent_jar=<%= @auto_instrumentation_java_agent_jar %>
<% if defined?(@auto_instrumentation_resource_attributes) && @auto_instrumentation_resource_attributes != "" -%>
resource_attributes=<%= @auto_instrumentation_resource_attributes %>
resource_attributes=splunk.zc.method=splunk-otel-auto-instrumentation-<%= @auto_instrumentation_version %>,<%= @auto_instrumentation_resource_attributes %>
<% else -%>
resource_attributes=splunk.zc.method=splunk-otel-auto-instrumentation-<%= @auto_instrumentation_version %>
<% end -%>
<% if defined?(@auto_instrumentation_service_name) && @auto_instrumentation_service_name != "" -%>
service_name=<%= @auto_instrumentation_service_name %>
Expand Down
13 changes: 13 additions & 0 deletions deployments/puppet/templates/java.conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
JAVA_TOOL_OPTIONS=-javaagent:<%= @auto_instrumentation_java_agent_jar %>
<% if defined?(@auto_instrumentation_resource_attributes) && @auto_instrumentation_resource_attributes != "" -%>
OTEL_RESOURCE_ATTRIBUTES=splunk.zc.method=splunk-otel-auto-instrumentation-<%= @auto_instrumentation_version %>,<%= @auto_instrumentation_resource_attributes %>
<% else -%>
OTEL_RESOURCE_ATTRIBUTES=splunk.zc.method=splunk-otel-auto-instrumentation-<%= @auto_instrumentation_version %>
<% end -%>
<% if defined?(@auto_instrumentation_service_name) && @auto_instrumentation_service_name != "" -%>
OTEL_SERVICE_NAME=<%= @auto_instrumentation_service_name %>
<% end -%>
SPLUNK_PROFILER_ENABLED=<%= @auto_instrumentation_enable_profiler.to_s.downcase %>
SPLUNK_PROFILER_MEMORY_ENABLED=<%= @auto_instrumentation_enable_profiler_memory.to_s.downcase %>
SPLUNK_METRICS_ENABLED=<%= @auto_instrumentation_enable_metrics.to_s.downcase %>
OTEL_EXPORTER_OTLP_ENDPOINT=<%= @auto_instrumentation_otlp_endpoint %>
2 changes: 2 additions & 0 deletions deployments/puppet/templates/ld.so.preload.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<% if defined?(@auto_instrumentation_systemd) && @auto_instrumentation_systemd.to_s.downcase == "false" -%>
/usr/lib/splunk-instrumentation/libsplunk.so
<% end -%>
<% if defined?(@auto_instrumentation_ld_so_preload) && @auto_instrumentation_ld_so_preload != "" -%>
<%= @auto_instrumentation_ld_so_preload %>
<% end -%>
Loading

0 comments on commit 137c9d2

Please sign in to comment.