Skip to content

Commit

Permalink
chef: Support Node.js zero config
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreyc-splunk committed Dec 12, 2023
1 parent ed7a8b2 commit 8513b56
Show file tree
Hide file tree
Showing 30 changed files with 909 additions and 56 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/chef-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,7 @@ jobs:
echo "Failed to get platforms from kitchen.yml!" >&2
exit 1
fi
suites=$(yq '[.suites[] | "\"" + (.name | sub("_", "-") | sub("\.", "")) + "\""] | join(", ")' kitchen.yml)
if [ -z "$suites" ]; then
echo "Failed to get suites from kitchen.yml!" >&2
exit 1
fi
echo "matrix={'DISTRO': [${distros}], 'SUITE': [${suites}]}" >> $GITHUB_OUTPUT
echo "matrix={'DISTRO': [${distros}]}" >> $GITHUB_OUTPUT
- name: Get windows distros and suites
id: get-win-matrix
Expand Down Expand Up @@ -94,12 +89,12 @@ jobs:
with:
version: 21.12.720

- run: kitchen test ${{ matrix.SUITE }}-${{ matrix.DISTRO }}
- run: kitchen test ${{ matrix.DISTRO }}

- uses: actions/upload-artifact@v3
if: always()
with:
name: ${{ matrix.SUITE }}-${{ matrix.DISTRO }}
name: ${{ matrix.DISTRO }}
path: deployments/chef/.kitchen/logs/*

chef-kitchen-windows:
Expand Down
2 changes: 2 additions & 0 deletions deployments/chef/Berksfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
source 'https://supermarket.chef.io'

metadata

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

## unreleased

## chef-v0.10.0

- Initial support for [Splunk OpenTelemetry for Node.js](https://github.com/signalfx/splunk-otel-js) Auto
Instrumentation on Linux:
- The Node.js SDK is installed and activated by default if the `with_auto_instrumentation` option is set to `true`
and `npm` is found on the node with the `bash -c 'command -v npm'` shell command.
- Set the `with_auto_instrumentation_sdks` option to only `%w(java)` to skip Node.js auto instrumentation.
- Use the `auto_instrumentation_npm_path` option to specify a custom path for `npm`.
- **Note:** This recipe does not manage the installation/configuration of Node.js, `npm`, or Node.js applications.

## chef-v0.9.0

- **Deprecations**: The `auto_instrumentation_generate_service_name` and `auto_instrumentation_disable_telemetry`
Expand Down
40 changes: 31 additions & 9 deletions deployments/chef/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,21 +177,33 @@ 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`)

### Auto Instrumentation for Java on Linux
### Auto Instrumentation on Linux

**Note:** The Java application(s) on the node need to be restarted separately
**Note:** The 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.
(**default:** `false`)
- `with_auto_instrumentation`: Whether to install/manage Splunk OpenTelemetry
Auto Instrumentation. When set to `true`, the
`splunk-otel-auto-instrumentation` deb/rpm package will be downloaded and
installed from the Collector repository. (**default:** `false`)

- `with_auto_instrumentation_sdks`: List of Splunk OpenTelemetry Auto
Instrumentation SDKs to install, configure, and activate. (**default:**
`%w(java nodejs)`)

Currently, the following values are supported:
- `java`: [Splunk OpenTelemetry for Java](https://github.com/signalfx/splunk-otel-java)
- `nodejs`: [Splunk OpenTelemetry for Node.js](https://github.com/signalfx/splunk-otel-js)

**Note:** This recipe does not manage the installation/configuration of
Node.js, `npm`, or Node.js applications. If `nodejs` is included in this
option, Node.js and `npm` are required to be pre-installed on the node in
order to install and activate the Node.js SDK.

- `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`. (**default:** `latest`)
minimum supported version is `0.48.0`. The minimum supported version for
Node.js auto instrumentation is `0.87.0`. (**default:** `latest`)

- `auto_instrumentation_systemd` (Linux only): By default, the
`/etc/ld.so.preload` file on the node will be configured for the
Expand All @@ -218,6 +230,16 @@ after installation/configuration in order for any change to take effect.
changed from the default value, the path should be an existing file on the
node. (**default:** `/usr/lib/splunk-instrumentation/splunk-otel-javaagent.jar`)

- `auto_instrumentation_npm_path`: If the `with_auto_instrumentation_sdks`
option includes `nodejs`, the Splunk OpenTelemetry for Node.js SDK will be
installed only if `npm` is found on the node with the
`bash -c 'command -v npm'` shell command. Use this option to specify a
custom path on the node for `npm`, for example `/my/custom/path/to/npm`.
(**default:** `npm`)

**Note:** This recipe does not manage the installation/configuration of
Node.js or `npm`.

- `auto_instrumentation_resource_attributes`: Configure the OpenTelemetry auto
instrumentation resource attributes, e.g.
`deployment.environment=prod,my.key=value` (comma-separated `key=value` pairs.).
Expand Down
2 changes: 2 additions & 0 deletions deployments/chef/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,6 @@
default['splunk_otel_collector']['auto_instrumentation_enable_profiler_memory'] = false
default['splunk_otel_collector']['auto_instrumentation_enable_metrics'] = false
default['splunk_otel_collector']['auto_instrumentation_otlp_endpoint'] = 'http://127.0.0.1:4317'
default['splunk_otel_collector']['with_auto_instrumentation_sdks'] = %w(java nodejs)
default['splunk_otel_collector']['auto_instrumentation_npm_path'] = 'npm'
end
8 changes: 4 additions & 4 deletions deployments/chef/kitchen.windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ suites:
verifier:
name: shell
remote_exec: true
command: inspec exec default/inspec/default_spec.rb
command: inspec exec default/test.rb

- name: custom_vars
run_list:
Expand All @@ -63,7 +63,7 @@ suites:
verifier:
name: shell
remote_exec: true
command: inspec exec custom_vars/inspec/custom_vars_spec.rb
command: inspec exec custom_vars/test.rb

- name: with_default_dotnet_instrumentation
run_list:
Expand All @@ -76,7 +76,7 @@ suites:
verifier:
name: shell
remote_exec: true
command: inspec exec with_default_dotnet_instrumentation/inspec/with_default_dotnet_instrumentation_spec.rb
command: inspec exec with_default_dotnet_instrumentation/test.rb

- name: with_custom_dotnet_instrumentation
run_list:
Expand All @@ -99,4 +99,4 @@ suites:
verifier:
name: shell
remote_exec: true
command: inspec exec with_custom_dotnet_instrumentation/inspec/with_custom_dotnet_instrumentation_spec.rb
command: inspec exec with_custom_dotnet_instrumentation/test.rb
171 changes: 166 additions & 5 deletions deployments/chef/kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,35 +163,46 @@ suites:

- name: with_default_preload_instrumentation
run_list:
- recipe[nodejs]
- recipe[splunk_otel_collector]
attributes:
nodejs: &nodejs_options
install_method: binary
version: 16.20.2
binary:
append_env_path: false # required for idempotence
checksum: c9193e6c414891694759febe846f4f023bf48410a6924a8b1520c46565859665
splunk_otel_collector:
splunk_access_token: testing123
splunk_realm: test
with_auto_instrumentation: true

- name: with_custom_preload_instrumentation
run_list:
- recipe[nodejs]
- recipe[splunk_otel_collector]
attributes:
nodejs:
*nodejs_options
splunk_otel_collector:
splunk_access_token: testing123
splunk_realm: test
with_auto_instrumentation: true
auto_instrumentation_ld_so_preload: "# my extra library"
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
auto_instrumentation_otlp_endpoint: http://0.0.0.0:4317

- name: with_default_systemd_instrumentation
run_list:
- recipe[nodejs]
- recipe[splunk_otel_collector]
attributes:
nodejs:
*nodejs_options
splunk_otel_collector:
splunk_access_token: testing123
splunk_realm: test
Expand All @@ -200,19 +211,169 @@ suites:

- name: with_custom_systemd_instrumentation
run_list:
- recipe[nodejs]
- recipe[splunk_otel_collector]
attributes:
nodejs:
*nodejs_options
splunk_otel_collector:
splunk_access_token: testing123
splunk_realm: test
with_auto_instrumentation: true
auto_instrumentation_ld_so_preload: "# this should not be added"
auto_instrumentation_systemd: true
auto_instrumentation_ld_so_preload: "# my extra library"
auto_instrumentation_resource_attributes: deployment.environment=test
auto_instrumentation_service_name: test
auto_instrumentation_enable_profiler: true
auto_instrumentation_enable_profiler_memory: true
auto_instrumentation_enable_metrics: true
auto_instrumentation_otlp_endpoint: http://0.0.0.0:4317

- name: with_default_preload_java_instrumentation
run_list:
- recipe[splunk_otel_collector]
attributes:
splunk_otel_collector:
splunk_access_token: testing123
splunk_realm: test
with_auto_instrumentation: true
with_auto_instrumentation_sdks:
- java

- name: with_custom_preload_java_instrumentation
run_list:
- recipe[splunk_otel_collector]
attributes:
splunk_otel_collector:
splunk_access_token: testing123
splunk_realm: test
with_auto_instrumentation: true
with_auto_instrumentation_sdks:
- java
auto_instrumentation_ld_so_preload: "# my extra library"
auto_instrumentation_resource_attributes: deployment.environment=test
auto_instrumentation_service_name: test
auto_instrumentation_enable_profiler: true
auto_instrumentation_enable_profiler_memory: true
auto_instrumentation_enable_metrics: true
auto_instrumentation_otlp_endpoint: http://0.0.0.0:4317

- name: with_default_systemd_java_instrumentation
run_list:
- recipe[splunk_otel_collector]
attributes:
splunk_otel_collector:
splunk_access_token: testing123
splunk_realm: test
with_auto_instrumentation: true
with_auto_instrumentation_sdks:
- java
auto_instrumentation_systemd: true

- name: with_custom_systemd_java_instrumentation
run_list:
- recipe[splunk_otel_collector]
attributes:
splunk_otel_collector:
splunk_access_token: testing123
splunk_realm: test
with_auto_instrumentation: true
with_auto_instrumentation_sdks:
- java
auto_instrumentation_systemd: true
auto_instrumentation_resource_attributes: deployment.environment=test
auto_instrumentation_service_name: test
auto_instrumentation_enable_profiler: true
auto_instrumentation_enable_profiler_memory: true
auto_instrumentation_enable_metrics: true
auto_instrumentation_otlp_endpoint: http://0.0.0.0:4317

- name: with_default_preload_node_instrumentation
run_list:
- recipe[nodejs]
- recipe[splunk_otel_collector]
attributes:
nodejs:
*nodejs_options
splunk_otel_collector:
splunk_access_token: testing123
splunk_realm: test
with_auto_instrumentation: true
with_auto_instrumentation_sdks:
- nodejs

- name: with_custom_preload_node_instrumentation
run_list:
- recipe[nodejs]
- recipe[splunk_otel_collector]
attributes:
nodejs:
*nodejs_options
splunk_otel_collector:
splunk_access_token: testing123
splunk_realm: test
with_auto_instrumentation: true
with_auto_instrumentation_sdks:
- nodejs
auto_instrumentation_ld_so_preload: "# my extra library"
auto_instrumentation_resource_attributes: deployment.environment=test
auto_instrumentation_service_name: test
auto_instrumentation_enable_profiler: true
auto_instrumentation_enable_profiler_memory: true
auto_instrumentation_enable_metrics: true
auto_instrumentation_otlp_endpoint: http://0.0.0.0:4317

- name: with_default_systemd_node_instrumentation
run_list:
- recipe[nodejs]
- recipe[splunk_otel_collector]
attributes:
nodejs:
*nodejs_options
splunk_otel_collector:
splunk_access_token: testing123
splunk_realm: test
with_auto_instrumentation: true
with_auto_instrumentation_sdks:
- nodejs
auto_instrumentation_systemd: true

- name: with_custom_systemd_node_instrumentation
run_list:
- recipe[nodejs]
- recipe[splunk_otel_collector]
attributes:
nodejs:
*nodejs_options
splunk_otel_collector:
splunk_access_token: testing123
splunk_realm: test
with_auto_instrumentation: true
with_auto_instrumentation_sdks:
- nodejs
auto_instrumentation_systemd: 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
auto_instrumentation_otlp_endpoint: http://0.0.0.0:4317

- name: with_default_preload_instrumentation_without_npm
run_list:
- recipe[splunk_otel_collector]
attributes:
splunk_otel_collector:
splunk_access_token: testing123
splunk_realm: test
with_auto_instrumentation: true

- name: with_default_systemd_instrumentation_without_npm
run_list:
- recipe[splunk_otel_collector]
attributes:
splunk_otel_collector:
splunk_access_token: testing123
splunk_realm: test
with_auto_instrumentation: true
auto_instrumentation_systemd: 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.9.0'
version '0.10.0'
chef_version '>= 16.0'

supports 'amazon'
Expand Down
Loading

0 comments on commit 8513b56

Please sign in to comment.