Skip to content

Commit

Permalink
Add java zc options to salt
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreyc-splunk committed Mar 16, 2023
1 parent 355c61d commit e766b4c
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 19 deletions.
49 changes: 33 additions & 16 deletions deployments/salt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ splunk-otel-collector:

## This Salt Formula accepts the following attributes:

### Collector

- `splunk_access_token` (**Required**): The Splunk access token to
authenticate requests.

Expand Down Expand Up @@ -109,6 +111,8 @@ splunk-otel-collector:
The variables/values will be added to the
`/etc/otel/collector/splunk-otel-collector.conf` systemd environment file.

### Fluentd

- `install_fluentd`: Whether to install/manage fluentd and dependencies for log
collection. The dependencies include [capng_c](
https://github.com/fluent-plugins-nursery/capng_c) for enabling
Expand All @@ -133,49 +137,46 @@ splunk-otel-collector:
e.g. `salt://templates/td_agent.conf` (**default:** `""` meaning
that nothing will be copied and existing `splunk_fluentd_config` will be used)

### Auto Instrumentation (Linux Only)

**Note:** The Java application(s) on the node need to be started/restarted
separately after installation/configuration in order for any changes to take
effect.

- `install_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:**
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:** `None`)
library paths, e.g. `/path/to/my.library.so`. (**default:** `None`)

- `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:**
`None`)
file on the node. (**default:** `None`)

- `auto_instrumentation_service_name`: Explicitly set the [service name](
https://github.com/signalfx/splunk-otel-collector/tree/main/instrumentation#configuration-file)
Expand All @@ -184,5 +185,21 @@ splunk-otel-collector:
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:** `None`)
node. (**default:** `None`)

- `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`: Enable or disable the preloader
from sending the `splunk.linux-autoinstr.executions` metric to the local
collector. (**default:** `False`)

- `auto_instrumentation_enable_profiler`: Enable or disable AlwaysOn CPU
Profiling. (**default**: `False`)

- `auto_instrumentation_enable_profiler_memory`: Enable or disable AlwaysOn
Memory Profiling. (**default:** `False`)

- `auto_instrumentation_enable_metrics`: Enable or disable exporting
Micrometer metrics. (**default**: `False`)
10 changes: 10 additions & 0 deletions deployments/salt/splunk-otel-collector/auto_instrumentation.sls
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
{% set auto_instrumentation_ld_so_preload = salt['pillar.get']('splunk-otel-collector:auto_instrumentation_ld_so_preload') %}
{% set auto_instrumentation_resource_attributes = salt['pillar.get']('splunk-otel-collector:auto_instrumentation_resource_attributes') %}
{% set auto_instrumentation_service_name = salt['pillar.get']('splunk-otel-collector:auto_instrumentation_service_name') %}
{% set auto_instrumentation_generate_service_name = salt['pillar.get']('splunk-otel-collector:auto_instrumentation_generate_service_name', True) | to_bool %}
{% set auto_instrumentation_disable_telemetry = salt['pillar.get']('splunk-otel-collector:auto_instrumentation_disable_telemetry', False) | to_bool %}
{% set auto_instrumentation_enable_profiler = salt['pillar.get']('splunk-otel-collector:auto_instrumentation_enable_profiler', False) | to_bool %}
{% set auto_instrumentation_enable_profiler_memory = salt['pillar.get']('splunk-otel-collector:auto_instrumentation_enable_profiler_memory', False) | to_bool %}
{% set auto_instrumentation_enable_metrics = salt['pillar.get']('splunk-otel-collector:auto_instrumentation_enable_metrics', False) | to_bool %}

Install Splunk OpenTelemetry Auto Instrumentation:
pkg.installed:
Expand Down Expand Up @@ -32,6 +37,11 @@ Install Splunk OpenTelemetry Auto Instrumentation:
{% if auto_instrumentation_service_name %}
- service_name={{ auto_instrumentation_service_name }}
{% endif %}
- generate_service_name={{ auto_instrumentation_generate_service_name | string | lower }}
- disable_telemetry={{ auto_instrumentation_disable_telemetry | string | lower }}
- enable_profiler={{ auto_instrumentation_enable_profiler | string | lower }}
- enable_profiler_memory={{ auto_instrumentation_enable_profiler_memory | string | lower }}
- enable_metrics={{ auto_instrumentation_enable_metrics | string | lower }}
- makedirs: True
- require:
- pkg: splunk-otel-auto-instrumentation
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ def test_salt_without_fluentd(distro):
auto_instrumentation_version: '$version'
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
"""
)

Expand All @@ -173,9 +178,14 @@ def verify_instrumentation_config(container):

try:
run_container_cmd(container, f"grep '^{libsplunk_path}' /etc/ld.so.preload")
run_container_cmd(container, f"grep '^java_agent_jar={java_agent_path}' {config_path}")
run_container_cmd(container, f"grep '^resource_attributes=deployment.environment=test' {config_path}")
run_container_cmd(container, f"grep '^service_name=test' {config_path}")
run_container_cmd(container, f"grep '^java_agent_jar={java_agent_path}$' {config_path}")
run_container_cmd(container, f"grep '^resource_attributes=deployment.environment=test$' {config_path}")
run_container_cmd(container, f"grep '^service_name=test$' {config_path}")
run_container_cmd(container, f"grep '^generate_service_name=false$' {config_path}")
run_container_cmd(container, f"grep '^disable_telemetry=true$' {config_path}")
run_container_cmd(container, f"grep '^enable_profiler=true$' {config_path}")
run_container_cmd(container, f"grep '^enable_profiler_memory=true$' {config_path}")
run_container_cmd(container, f"grep '^enable_metrics=true$' {config_path}")
finally:
run_container_cmd(container, "cat /etc/ld.so.preload")
run_container_cmd(container, f"cat {config_path}")
Expand Down

0 comments on commit e766b4c

Please sign in to comment.