Skip to content

Commit

Permalink
Add java zc options to chef (#2733)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreyc-splunk committed Mar 16, 2023
1 parent 1617da5 commit 355c61d
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 48 deletions.
4 changes: 4 additions & 0 deletions deployments/chef/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## chef-v0.5.0

- Add support for additional options for Splunk OpenTelemetry Auto Instrumentation for Java (Linux only)

## chef-v0.4.0

- Add `collector_additional_env_vars` option to allow passing additional environment variables to the collector service
Expand Down
110 changes: 63 additions & 47 deletions deployments/chef/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ required `splunk_access_token` attribute and some optional attributes:

# This cookbook accepts the following attributes

### Collector

- `splunk_access_token` (**Required**): The [Splunk access token](
https://docs.splunk.com/Observability/admin/authentication-tokens/org-tokens.html)
to authenticate requests.
Expand Down Expand Up @@ -109,6 +111,41 @@ required `splunk_access_token` attribute and some optional attributes:
- `package_stage`: The Collector package repository stage to use. Can be
`release`, `beta`, or `test`. (**default:** `release`)

- `splunk_bundle_dir`: The path to the [Smart Agent bundle directory](
https://github.com/signalfx/splunk-otel-collector/blob/main/pkg/extension/smartagentextension/README.md).
The default path is provided by the Collector package. If the specified path
is changed from the default value, the path should be an existing directory
on the node. The `SPLUNK_BUNDLE_DIR` environment variable will be set to
this value for the Collector service. (**default:**
`/usr/lib/splunk-otel-collector/agent-bundle` on Linux,
`%ProgramFiles%\Splunk\OpenTelemetry Collector\agent-bundle` on Windows)

- `splunk_collectd_dir`: The path to the collectd config directory for the
Smart Agent bundle. The default path is provided by the Collector package.
If the specified path is changed from the default value, the path should be
an existing directory on the node. The `SPLUNK_COLLECTD_DIR` environment
variable will be set to this value for the Collector service.
(**default:** `/usr/lib/splunk-otel-collector/agent-bundle` on Linux,
`%ProgramFiles%\Splunk\OpenTelemetry Collector\agent-bundle\run\collectd`
on Windows)

- `collector_additional_env_vars`: Hash of additional environment variables
from the collector configuration file for the collector service
(**default:** `{}`).
For example, if the collector configuration file includes references to
`${MY_CUSTOM_VAR1}` and `${MY_CUSTOM_VAR2}`, specify the following to allow
the collector service to expand these variables:
```ruby
collector_additional_env_vars: {'MY_CUSTOM_VAR1' => 'value1', 'MY_CUSTOM_VAR2' => 'value2'}
```
On Linux, the variables/values will be added to the
`/etc/otel/collector/splunk-otel-collector.conf` systemd environment file.
On Windows, the variables/values will be added to the
`HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment`
registry key.

### Fluentd

- `with_fluentd`: Whether to install/manage Fluentd and dependencies for log
collection. On Linux, the dependencies include [capng_c](
https://github.com/fluent-plugins-nursery/capng_c) for enabling
Expand Down Expand Up @@ -137,67 +174,45 @@ required `splunk_access_token` attribute and some optional attributes:
`%SYSTEMDRIVE%\opt\td-agent\etc\td-agent\td-agent.conf`. (**default:**
`/etc/otel/collector/fluentd/fluent.conf`)

- `splunk_bundle_dir`: The path to the [Smart Agent bundle directory](
https://github.com/signalfx/splunk-otel-collector/blob/main/pkg/extension/smartagentextension/README.md).
The default path is provided by the Collector package. If the specified path
is changed from the default value, the path should be an existing directory
on the node. The `SPLUNK_BUNDLE_DIR` environment variable will be set to
this value for the Collector service. (**default:**
`/usr/lib/splunk-otel-collector/agent-bundle` on Linux,
`%ProgramFiles%\Splunk\OpenTelemetry Collector\agent-bundle` on Windows)
### Auto Instrumentation

- `splunk_collectd_dir`: The path to the collectd config directory for the
Smart Agent bundle. The default path is provided by the Collector package.
If the specified path is changed from the default value, the path should be
an existing directory on the node. The `SPLUNK_COLLECTD_DIR` environment
variable will be set to this value for the Collector service.
(**default:** `/usr/lib/splunk-otel-collector/agent-bundle` on Linux,
`%ProgramFiles%\Splunk\OpenTelemetry Collector\agent-bundle\run\collectd`
on Windows)
**Note:** The Java application(s) on the node need to be restarted separately
after installation/configuration in order for any change to take effect.

- `with_auto_instrumentation`: Whether to install/manage [Splunk OpenTelemetry
Auto Instrumentation for Java](
https://github.com/signalfx/splunk-otel-collector/tree/main/instrumentation).
When set to `true`, the `splunk-otel-auto-instrumentation` deb/rpm package
will be downloaded and installed from the Collector repository. **Note:** The
Java application on the node needs to be started/restarted separately after
installation in order for auto instrumentation to take effect. (**default:**
`false`)
will be downloaded and installed from the Collector repository.
(**default:** `false`)

- `auto_instrumentation_version`: Version of the
`splunk-otel-auto-instrumentation` package to install, e.g. `0.50.0`. The
minimum supported version is `0.48.0`. **Note:** The Java application on the
node needs to be restarted separately in order for any change to take effect.
(**default:** `latest`)
minimum supported version is `0.48.0`. (**default:** `latest`)

- `auto_instrumentation_ld_so_preload`: By default, the `/etc/ld.so.preload`
file on the node will be configured for the
`/usr/lib/splunk-instrumentation/libsplunk.so` [shared object library](
https://github.com/signalfx/splunk-otel-collector/tree/main/instrumentation#operation)
provided by the `splunk-otel-auto-instrumentation` package and is required
for auto instrumentation. Configure this variable to include additional
library paths, e.g. `/path/to/my.library.so`. **Note:** The Java application
on the node needs to be restarted separately in order for any change to take
effect. (**default:** `''`)
library paths, e.g. `/path/to/my.library.so`. (**default:** `''`)

- `auto_instrumentation_java_agent_path`: Path to the [Splunk OpenTelemetry
Java agent](https://github.com/signalfx/splunk-otel-java). The default path
is provided by the `splunk-otel-auto-instrumentation` package. If the path is
changed from the default value, the path should be an existing file on the
node. The specified path will be added to the
`/usr/lib/splunk-instrumentation/instrumentation.conf` config file on the
node. **Note:** The Java application on the node needs to be restarted
separately in order for any change to take effect. (**default:**
node. (**default:**
`/usr/lib/splunk-instrumentation/splunk-otel-javaagent.jar`)

- `auto_instrumentation_resource_attributes`: Configure the OpenTelemetry
instrumentation [resource attributes](
https://github.com/signalfx/splunk-otel-collector/tree/main/instrumentation#configuration-file),
e.g. `deployment.environment=prod`. The specified resource attribute(s) will
be added to the `/usr/lib/splunk-instrumentation/instrumentation.conf` config
file on the node. **Note:** The Java application on the node needs to be
restarted separately in order for any change to take effect. (**default:**
`''`)
file on the node. (**default:** `''`)

- `auto_instrumentation_service_name`: Explicitly set the [service name](
https://github.com/signalfx/splunk-otel-collector/tree/main/instrumentation#configuration-file)
Expand All @@ -206,20 +221,21 @@ required `splunk_access_token` attribute and some optional attributes:
executable on the node. However, if this variable is set to a non-empty
value, the value will override the derived service name and be added to the
`/usr/lib/splunk-instrumentation/instrumentation.conf` config file on the
node. **Note:** The Java application on the node needs to be restarted
separately in order for any change to take effect. (**default:** `''`)
node. (**default:** `''`)

- `collector_additional_env_vars`: Hash of additional environment variables
from the collector configuration file for the collector service
(**default:** `{}`).
For example, if the collector configuration file includes references to
`${MY_CUSTOM_VAR1}` and `${MY_CUSTOM_VAR2}`, specify the following to allow
the collector service to expand these variables:
```ruby
collector_additional_env_vars: {'MY_CUSTOM_VAR1' => 'value1', 'MY_CUSTOM_VAR2' => 'value2'}
```
On Linux, the variables/values will be added to the
`/etc/otel/collector/splunk-otel-collector.conf` systemd environment file.
On Windows, the variables/values will be added to the
`HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment`
registry key.
- `auto_instrumentation_generate_service_name`: Set this option to `false` to
prevent the preloader from setting the `OTEL_SERVICE_NAME` environment
variable. (**default:** `true`)

- `auto_instrumentation_disable_telemetry` (Linux only): Enable or disable the
preloader from sending the `splunk.linux-autoinstr.executions` metric to the
local collector. (**default:** `false`)

- `auto_instrumentation_enable_profiler` (Linux only): Enable or disable
AlwaysOn CPU Profiling. (**default**: `false`)

- `auto_instrumentation_enable_profiler_memory` (Linux only): Enable or disable
AlwaysOn Memory Profiling. (**default:** `false`)

- `auto_instrumentation_enable_metrics` (Linux only): Enable or disable
exporting Micrometer metrics. (**default**: `false`)
5 changes: 5 additions & 0 deletions deployments/chef/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,9 @@
default['splunk_otel_collector']['auto_instrumentation_java_agent_jar'] = '/usr/lib/splunk-instrumentation/splunk-otel-javaagent.jar'
default['splunk_otel_collector']['auto_instrumentation_resource_attributes'] = ''
default['splunk_otel_collector']['auto_instrumentation_service_name'] = ''
default['splunk_otel_collector']['auto_instrumentation_generate_service_name'] = true
default['splunk_otel_collector']['auto_instrumentation_disable_telemetry'] = false
default['splunk_otel_collector']['auto_instrumentation_enable_profiler'] = false
default['splunk_otel_collector']['auto_instrumentation_enable_profiler_memory'] = false
default['splunk_otel_collector']['auto_instrumentation_enable_metrics'] = false
end
5 changes: 5 additions & 0 deletions deployments/chef/kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,8 @@ suites:
with_auto_instrumentation: true
auto_instrumentation_resource_attributes: deployment.environment=test
auto_instrumentation_service_name: test
auto_instrumentation_generate_service_name: false
auto_instrumentation_disable_telemetry: true
auto_instrumentation_enable_profiler: true
auto_instrumentation_enable_profiler_memory: true
auto_instrumentation_enable_metrics: true
2 changes: 1 addition & 1 deletion deployments/chef/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
maintainer_email 'signalfx-support@splunk.com'
license 'Apache-2.0'
description 'Install/Configure the Splunk OpenTelemetry Collector'
version '0.4.0'
version '0.5.0'
chef_version '>= 16.0'

supports 'amazon'
Expand Down
5 changes: 5 additions & 0 deletions deployments/chef/templates/instrumentation.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ resource_attributes=<%= node['splunk_otel_collector']['auto_instrumentation_reso
<% if defined?(node['splunk_otel_collector']['auto_instrumentation_service_name']) && node['splunk_otel_collector']['auto_instrumentation_service_name'] != "" -%>
service_name=<%= node['splunk_otel_collector']['auto_instrumentation_service_name'] %>
<% end -%>
generate_service_name=<%= node['splunk_otel_collector']['auto_instrumentation_generate_service_name'].to_s.downcase %>
disable_telemetry=<%= node['splunk_otel_collector']['auto_instrumentation_disable_telemetry'].to_s.downcase %>
enable_profiler=<%= node['splunk_otel_collector']['auto_instrumentation_enable_profiler'].to_s.downcase %>
enable_profiler_memory=<%= node['splunk_otel_collector']['auto_instrumentation_enable_profiler_memory'].to_s.downcase %>
enable_metrics=<%= node['splunk_otel_collector']['auto_instrumentation_enable_metrics'].to_s.downcase %>
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
its('content') { should match /^java_agent_jar=#{java_agent_path}$/ }
its('content') { should match /^resource_attributes=#{resource_attribute}$/ }
its('content') { should match /^service_name=#{service_name}$/ }
its('content') { should match /^generate_service_name=false$/ }
its('content') { should match /^disable_telemetry=true$/ }
its('content') { should match /^enable_profiler=true$/ }
its('content') { should match /^enable_profiler_memory=true$/ }
its('content') { should match /^enable_metrics=true$/ }
end

describe service('splunk-otel-collector') do
Expand Down

0 comments on commit 355c61d

Please sign in to comment.