diff --git a/.github/workflows/auto-instrumentation.yml b/.github/workflows/auto-instrumentation.yml index 356ae96588..c7704f1226 100644 --- a/.github/workflows/auto-instrumentation.yml +++ b/.github/workflows/auto-instrumentation.yml @@ -4,7 +4,6 @@ on: push: branches: - main - - zero-config-dev pull_request: paths: - '.github/workflows/auto-instrumentation.yml' @@ -22,7 +21,7 @@ env: PYTHON_VERSION: '3.11' PIP_VERSION: '22.0.4' REQUIREMENTS_PATH: "internal/buildscripts/packaging/tests/requirements.txt" - GO_VERSION: 1.20.6 + GO_VERSION: 1.20.10 jobs: cross-compile: diff --git a/docs/getting-started/linux-manual.md b/docs/getting-started/linux-manual.md index 1b03d4e6a9..2a26121e54 100644 --- a/docs/getting-started/linux-manual.md +++ b/docs/getting-started/linux-manual.md @@ -69,7 +69,7 @@ installed on x86_64/amd64 platforms. apt-get update apt-get install -y splunk-otel-collector - # Optional: install Splunk OpenTelemetry Auto Instrumentation for Java + # Optional: install Splunk OpenTelemetry Auto Instrumentation apt-get install -y splunk-otel-auto-instrumentation ``` - RPM with `yum`: @@ -87,7 +87,7 @@ installed on x86_64/amd64 platforms. yum install -y splunk-otel-collector - # Optional: install Splunk OpenTelemetry Auto Instrumentation for Java + # Optional: install Splunk OpenTelemetry Auto Instrumentation yum install -y splunk-otel-auto-instrumentation ``` - RPM with `dnf`: @@ -105,7 +105,7 @@ installed on x86_64/amd64 platforms. dnf install -y splunk-otel-collector - # Optional: install Splunk OpenTelemetry Auto Instrumentation for Java + # Optional: install Splunk OpenTelemetry Auto Instrumentation dnf install -y splunk-otel-auto-instrumentation ``` - RPM with `zypper`: @@ -123,14 +123,14 @@ installed on x86_64/amd64 platforms. zypper install -y splunk-otel-collector - # Optional: install Splunk OpenTelemetry Auto Instrumentation for Java + # Optional: install Splunk OpenTelemetry Auto Instrumentation zypper install -y splunk-otel-auto-instrumentation ``` 1. See the [Collector Debian/RPM Post-Install Configuration](#collector-debianrpm-post-install-configuration) section. -1. If the optional Splunk OpenTelemetry Auto Instrumentation for Java package - was installed, see the [Auto Instrumentation Post-Install - Configuration](#auto-instrumentation-post-install-configuration) section. +1. If the optional Splunk OpenTelemetry Auto Instrumentation package was + installed, see the [Auto Instrumentation Post-Install Configuration]( + #auto-instrumentation-post-install-configuration) section. 1. If log collection is required, see the [Fluentd](#fluentd) section. 1. To upgrade the Collector, run the following commands: - Debian: @@ -165,10 +165,9 @@ installed on x86_64/amd64 platforms. sudo apt-get update sudo apt-get install --only-upgrade splunk-otel-auto-instrumentation ``` - **Note:** You may be prompted to keep or overwrite the configuration file - at `/usr/lib/splunk-instrumentation/instrumentation.conf`. Choosing to - overwrite will revert this file to the default file provided by the new - package. + **Note:** You may be prompted to keep or overwrite the configuration files + in the `/etc/splunk/zeroconfig` directory. Choosing to overwrite will + revert this file to the default file provided by the new package. - RPM: - `yum` ```sh @@ -181,8 +180,12 @@ installed on x86_64/amd64 platforms. - `zypper` ```sh sudo zypper refresh - sudo zypper update splunk-otel-instrumentation + sudo zypper update splunk-otel-auto-instrumentation ``` + **Note:** If the default configuration files in `/etc/splunk/zeroconfig` + have been modified after initial installation, the existing files will be + preserved and the files from the new package may be installed + with a `.rpmnew` extension. #### Collector Debian/RPM Packages @@ -317,54 +320,47 @@ and install it with the following commands (requires `root` privileges). ```sh sudo dpkg -i ``` - **Note:** You may be prompted to keep or overwrite the configuration file - at `/usr/lib/splunk-instrumentation/instrumentation.conf`. Choosing to - overwrite will revert this file to the default file provided by the new - package. + **Note:** You may be prompted to keep or overwrite the configuration files + in the `/etc/splunk/zeroconfig` directory. Choosing to overwrite will + revert this file to the default file provided by the new package. - RPM ```sh sudo rpm -Uvh ``` + **Note:** If the default configuration files in `/etc/splunk/zeroconfig` + have been modified after initial installation, the existing files will be + preserved and the files from the new package may be installed + with a `.rpmnew` extension. #### Auto Instrumentation Post-Install Configuration -Choose one of the following methods to activate and configure Splunk -OpenTelemetry Auto Instrumentation ***globally*** with either the provided -`libsplunk.so` shared object library or sample `systemd` drop-in files. To -activate and configure auto instrumentation for individual services or -applications, see -[Instrument back-end applications to send spans to Splunk APM]( -https://docs.splunk.com/Observability/gdi/get-data-in/application/application.html). - -1. Preload method - - The `/usr/lib/splunk-instrumentation/libsplunk.so` shared object library - can be added to the [`/etc/ld.so.preload`]( - https://man7.org/linux/man-pages/man8/ld.so.8.html#FILES) file to activate - auto instrumentation for ***all*** supported processes. - - The `/usr/lib/splunk-instrumentation/instrumentation.conf` configuration - file can be configured for resource attributes and other supported - parameters. By default, this file will contain the `java_agent_jar` - parameter set to the path of the installed [Java Instrumentation Agent]( - https://github.com/signalfx/splunk-otel-java) - (`/usr/lib/splunk-instrumentation/splunk-otel-javaagent.jar`). - - See [Linux Java Auto Instrumentation](../../instrumentation/libsplunk.md) - for more details. - -2. `Systemd` method - - The sample `systemd` drop-in files in the - `/usr/lib/splunk-instrumentation/examples/systemd/` directory can be - configured and copied to the host's [`systemd` configuration - directory]( - https://www.freedesktop.org/software/systemd/man/systemd-system.conf.html), - for example `/usr/lib/systemd/system.conf.d/`, to activate and - configure auto instrumentation for ***all*** supported applications - running as `systemd` services. - - See [Splunk OpenTelemetry Zero Configuration Auto Instrumentation for - Systemd](../../instrumentation/systemd.md) for more details. - -**Note:** After installation/upgrade or any configuration changes, reboot the -system or restart the application(s) on the host for automatic instrumentation -to take effect and/or to source the updated values. +The `splunk-otel-auto-instrumentation` deb/rpm package installs and supports +configuration for the following Auto Instrumentation agents: + +- [Java](https://docs.splunk.com/Observability/gdi/get-data-in/application/java/get-started.html) +- [Node.js](https://docs.splunk.com/Observability/en/gdi/get-data-in/application/nodejs/get-started.html) + +To manually activate and configure the Auto Instrumentation agents: +1. Check agent compatibility and requirements: + - [Java](https://docs.splunk.com/Observability/gdi/get-data-in/application/java/java-otel-requirements.html) + - [Node.js](https://docs.splunk.com/Observability/en/gdi/get-data-in/application/nodejs/nodejs-otel-requirements.html) +2. If Auto Instrumentation for Node.js is required, install the provided + `/usr/lib/splunk-instrumentation/splunk-otel-js.tgz` Node.js package with + `npm`. For example: + ```sh + sudo npm install --global /usr/lib/splunk-instrumentation/splunk-otel-js.tgz + ``` + > **Notes:** + > - Ensure that all Node.js applications/services to be instrumented have + > access to the installation path of the Node.js package. + > - On `arm64` architectures, it may be necessary to build/compile the + > Node.js package when installing with `npm`. Ensure that any required + > tools/libraries are installed on these systems, for example, + > `sudo apt-get install build-essential` on Debian-based systems or + > `sudo yum groupinstall 'Development Tools'` on RPM-based systems. +3. See [Activation and Configuration]( + ../../instrumentation/README.md#activation-and-configuration) for supported + methods and options. #### Fluentd diff --git a/instrumentation/README.md b/instrumentation/README.md index 8d5cd857e9..d26af49e16 100644 --- a/instrumentation/README.md +++ b/instrumentation/README.md @@ -1,50 +1,129 @@ # Splunk OpenTelemetry Zero Configuration Auto Instrumentation for Linux -**Splunk OpenTelemetry Zero Configuration Auto Instrumentation for Linux** (`splunk-otel-auto-instrumentation`) -Debian/RPM package installs Splunk OpenTelemetry Auto Instrumentation agent(s), the `libsplunk.so` shared object -library, and sample configuration files to automatically instrument applications and services to capture and report -distributed traces and metrics to the [Splunk OpenTelemetry Collector]( +The **Splunk OpenTelemetry Zero Configuration Auto Instrumentation for Linux** Debian/RPM package +(`splunk-otel-auto-instrumentation`) installs Splunk OpenTelemetry Auto Instrumentation agents, the `libsplunk.so` +shared object library, and default/sample configuration files to automatically instrument applications and services to +capture and report distributed traces and metrics to the [Splunk OpenTelemetry Collector]( https://docs.splunk.com/Observability/gdi/opentelemetry/opentelemetry.html), and then on to [Splunk APM]( https://docs.splunk.com/Observability/apm/intro-to-apm.html). -Currently, `splunk-otel-auto-instrumentation` installs and supports configuration of the following Auto Instrumentation -agent(s): +The `splunk-otel-auto-instrumentation` deb/rpm package installs and supports configuration of the following Auto +Instrumentation agents: - [Java](https://docs.splunk.com/Observability/gdi/get-data-in/application/java/get-started.html) +- [Node.js](https://docs.splunk.com/Observability/en/gdi/get-data-in/application/nodejs/get-started.html) + +For other languages or if the `splunk-otel-auto-instrumentation` deb/rpm package is not applicable for the target host +or applications/services, see [Instrument back-end applications to send spans to Splunk APM]( +https://docs.splunk.com/Observability/en/gdi/get-data-in/application/application.html). ## Prerequisites/Requirements - Check agent compatibility and requirements: - [Java](https://docs.splunk.com/Observability/gdi/get-data-in/application/java/java-otel-requirements.html) + - [Node.js](https://docs.splunk.com/Observability/en/gdi/get-data-in/application/nodejs/nodejs-otel-requirements.html) - [Install and configure](https://docs.splunk.com/Observability/gdi/opentelemetry/install-linux.html) the Splunk OpenTelemetry Collector. - Debian or RPM based Linux distribution (amd64/x86_64 or arm64/aarch64). -## Zero Configuration Options - -The following options are supported to enable the installed Auto Instrumentation agent(s): - -- **[`libsplunk.so`](./libsplunk.md)**: The provided `/usr/lib/splunk-instrumentation/libsplunk.so` shared object - library can be added to the `/etc/ld.so.preload` file to enable and configure Auto Instrumentation for ***all*** - supported processes on the system, or it can be assigned to the `LD_PRELOAD` environment variable for specific - applications/services. Configuration of the installed agent(s) is supported by the - [`/usr/lib/splunk-instrumentation/instrumentation.conf`](./libsplunk.md#configuration-file) file. - -- **[`systemd`](./systemd.md)**: The provided `systemd` drop-in file(s) in the - `/usr/lib/splunk-instrumentation/examples/systemd/` directory can be copied to the host's `systemd` configuration - directory, e.g. `/usr/lib/systemd/system.conf.d/`, to enable and configure Auto Instrumentation for ***all*** - supported applications running as `systemd` services. Configuration of the installed agent(s) is supported by - modifying these files or adding custom drop-in files with the desired environment variables. - -Alternatively, [manually install and configure]( -https://docs.splunk.com/Observability/gdi/get-data-in/application/application.html) -Auto Instrumentation if neither option is appropriate for the target host or application. - -> ### Notes -> -> 1. To prevent conflicts and duplicate traces/metrics, only one option should be enabled on the target system. -> 2. The configuration files and the options defined within are only applicable for the respective option that is -> configured. For example, `/usr/lib/splunk-instrumentation/instrumentation.conf` is only applicable with -> `libsplunk.so`, and the systemd drop-in file is not applicable for `libsplunk.so`. -> 3. The [`splunk.linux-autoinstr.executions`](./libsplunk.md#disable_telemetry-optional) telemetry -> metric is currently only provided with `libsplunk.so`. +## Installation + +### Manual + +1. [Install and configure](https://docs.splunk.com/Observability/gdi/opentelemetry/install-linux.html) the Splunk + OpenTelemetry Collector +2. [Install](../docs/getting-started/linux-manual.md#auto-instrumentation-debianrpm-packages) the + `splunk-otel-auto-instrumentation` deb/rpm package +3. If Auto Instrumentation for Node.js is required, [install]( + ../docs/getting-started/linux-manual.md#auto-instrumentation-post-install-configuration) the provided + `/usr/lib/splunk-instrumentatgion/splunk-otel-js.tgz` Node.js package with `npm`. +4. [Activate and configure](#activation-and-configuration) Auto Instrumentation with the supported methods and options. + +## Activation and Configuration + +The following methods are supported to manually activate and configure Auto Instrumentation after installation of the +`splunk-otel-auto-instrumentation` deb/rpm package (requires `root` privileges): + +- [System-wide](#system-wide) +- [`Systemd` services only](#systemd-services-only) + +> **Note**: To prevent conflicts and duplicate traces/metrics, only one method should be activated on the target system. + +### System-wide + +1. Add the path of the provided `/usr/lib/splunk-instrumentation/libsplunk.so` shared object library to the + [`/etc/ld.so.preload`](https://man7.org/linux/man-pages/man8/ld.so.8.html#FILES) file to activate Auto + Instrumentation for ***all*** supported processes on the system. For example: + ``` + echo /usr/lib/splunk-instrumentation/libsplunk.so >> /etc/ld.so.preload + ``` +2. The default configuration files in the `/etc/splunk/zeroconfig` directory includes the required environment variables + to activate the respective agents with the default options: + - `/etc/splunk/zeroconfig/java.conf`: + ``` + JAVA_TOOL_OPTIONS=-javaagent:/usr/lib/splunk-instrumentation/splunk-otel-javaagent.jar + ``` + - `/etc/splunk/zeroconfig/node.conf`: + ``` + NODE_OPTIONS=-r @splunk/otel/instrument + ``` + Configuration of the respective agents is supported by the adding/updating the following environment variables in + each of these files (***any environment variable not in this list will be ignored***): + - `OTEL_EXPORTER_OTLP_ENDPOINT` + - `OTEL_RESOURCE_ATTRIBUTES` + - `OTEL_SERVICE_NAME` + - `SPLUNK_METRICS_ENABLED` + - `SPLUNK_PROFILER_ENABLED` + - `SPLUNK_PROFILER_MEMORY_ENABLED` + + Check the following for details about these environment variables and default values: + - [Java](https://docs.splunk.com/Observability/en/gdi/get-data-in/application/java/configuration/advanced-java-otel-configuration.html) + - [Node.js](https://docs.splunk.com/Observability/en/gdi/get-data-in/application/nodejs/configuration/advanced-nodejs-otel-configuration.html) +3. Reboot the system or restart the applications/services for any changes to take effect. The `libsplunk.so` shared + object library will then be preloaded for all subsequent processes and inject the environment variables from the + `/etc/splunk/zeroconfig` configuration files for Java and Node.js processes. + +### `Systemd` services only + +> **Note**: The following steps utilize a sample `systemd` drop-in file to activate/configure the provided agents for +> all `systemd` services via default environment variables. `Systemd` supports many options, methods, and paths for +> configuring environment variables at the system level or for individual services, and are not limited to the steps +> below. Before making any changes, it is recommended to consult the documentation specific to your Linux distribution +> or service, and check the existing configurations of the system and individual services for potential conflicts or to +> override an environment variable for a particular service. For general details about `systemd`, see the +> [`systemd` man page](https://www.freedesktop.org/software/systemd/man/index.html). + +1. Copy the provided sample `systemd` drop-in file + `/usr/lib/splunk-instrumentation/examples/systemd/00-splunk-otel-auto-instrumentation.conf` to the host's `systemd` + [drop-in configuration directory](https://www.freedesktop.org/software/systemd/man/systemd-system.conf.html) to + activate Auto Instrumentation for ***all*** supported applications running as `systemd` services. For example: + ``` + mkdir -p /usr/lib/systemd/system.conf.d/ && cp /usr/lib/splunk-instrumentation/examples/systemd/00-splunk-otel-auto-instrumentation.conf /usr/lib/systemd/system.conf.d/ + ``` + This file includes the required environment variables to activate the respective agents with the default options: + - Java: + ``` + DefaultEnvironment="JAVA_TOOL_OPTIONS=-javaagent:/usr/lib/splunk-instrumentation/splunk-otel-javaagent.jar" + ``` + - Node.js: + ``` + DefaultEnvironment="NODE_OPTIONS=-r @splunk/otel/instrument" + ``` +2. To configure the activated agents, add/update [`DefaultEnvironment`]( + https://www.freedesktop.org/software/systemd/man/systemd-system.conf.html#DefaultEnvironment=) within the target file + from the previous step for the desired environment variables. For example: + ``` + cat <> /usr/lib/systemd/system.conf.d/00-splunk-otel-auto-instrumentation.conf + DefaultEnvironment="OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:4317" + DefaultEnvironment="OTEL_RESOURCE_ATTRIBUTES=deployment.environment=my_deployment_environment" + DefaultEnvironment="OTEL_SERVICE_NAME=my_service_name" + DefaultEnvironment="SPLUNK_METRICS_ENABLED=true" + DefaultEnvironment="SPLUNK_PROFILER_ENABLED=true" + DefaultEnvironment="SPLUNK_PROFILER_MEMORY_ENABLED=true" + EOH + ``` + Check the following for all supported environment variables and default values: + - [Java](https://docs.splunk.com/Observability/en/gdi/get-data-in/application/java/configuration/advanced-java-otel-configuration.html) + - [Node.js](https://docs.splunk.com/Observability/en/gdi/get-data-in/application/nodejs/configuration/advanced-nodejs-otel-configuration.html) +3. Reboot the system, or run `systemctl daemon-reload` and then restart the applicable `systemd` services for any + changes to take effect. diff --git a/instrumentation/libsplunk.md b/instrumentation/libsplunk.md deleted file mode 100644 index fc6604f7c2..0000000000 --- a/instrumentation/libsplunk.md +++ /dev/null @@ -1,181 +0,0 @@ -# Linux Java Auto Instrumentation - -This directory contains functionality to automatically instrument your local Java applications so that they capture and -report distributed traces to Splunk APM. - -## Operation - -This directory contains functionality for building a Linux .so (shared object) file, which, in conjunction with a -reference to that file in -`/etc/ld.so.preload` (provided by an installer defined elsewhere) causes processes on the host to run this .so before -the main executable runs. If the executable that's starting is not named `java`, the .so quits silently and the -executable starts normally. Otherwise, it attempts to set environment variables that will cause the -[Splunk OTel Java JAR](https://github.com/signalfx/splunk-otel-java) (also provided by the installer) to instrument the -soon-to-be running Java application. In this way, all Java applications on the host will be automatically instrumented -by the Splunk OTel Java agent. - -Once instrumented, Java executables send traces to a locally running -[Splunk Open Telemetry Collector](https://github.com/signalfx/splunk-otel-collector) -(installed separately) and then on to Splunk APM. - -## Configuration File - -At startup, the shared object reads the config file, `/usr/lib/splunk-instrumentation/instrumentation.conf` which by -default, looks like this: - -``` -java_agent_jar=/usr/lib/splunk-instrumentation/splunk-otel-javaagent.jar -``` - -The `java_agent_jar` parameter is set to the default location of the agent jar. - -### Supported parameters - -#### `java_agent_jar` (required) - -The full path to the auto instrumentation JAR (provided by the installer). - -#### `service_name` (optional) - -This is an optional override for the service name that would otherwise be generated by the shared object before Java -startup. By default, this line is commented out, but can be uncommented to override the generated name. If this -parameter is set, all instrumented Java applications on this host will have the specified service name (via the -OTEL_SERVICE_NAME environment variable). If this override is set and `generate_service_name` is also explicitly set to -`false`, that parameter will win, and the service name will not be set. - -#### `resource_attributes` (optional -- typically set by the installer script) - -This value, if present, should contain a list of name-value pairs (separated by `=`s and pairs separated by `,`s) to -which the .so will set the OTEL_RESOURCE_ATTRIBUTES environment variable. The OTEL_RESOURCE_ATTRIBUTES environment -variable will then be picked up by the Java instrumentation jar. Typically, it will be set to something like: - -`resource_attributes=deployment.environment=test` - -to set the deployment environment for the Splunk backend. - -#### `disable_telemetry` (optional) - -Set this value to `true` to disable the preloader from sending the `splunk.linux-autoinstr.executions` metric to the -local collector. Default: `false`. - -#### `generate_service_name` (optional) - -Set this value to `false` to prevent the preloader from setting the `OTEL_SERVICE_NAME` environment variable. If this -value is `false`, the preloader will not set `OTEL_SERVICE_NAME`, and the soon-to-be running Java instrumentation -library will attempt to set it instead (in the future, this will be the default behavior). Default: `true`. - -#### `enable_profiler` (optional) - -Set this value to `true` to pass `-Dsplunk.profiler.enabled=true` to the starting Java executable, which will enable -[AlwaysOn CPU Profiling](https://docs.splunk.com/Observability/apm/profiling/get-data-in-profiling.html). -Default: `false`. - -#### `enable_profiler_memory` (optional) - -Set this value to `true` to pass `-Dsplunk.profiler.memory.enabled=true` to the starting Java executable, which will -enable -[AlwaysOn Memory Profiling](https://docs.splunk.com/Observability/apm/profiling/get-data-in-profiling.html). -Default: `false`. - -#### `enable_metrics` (optional) - -Set this value to `true` to pass `-Dsplunk.metrics.enabled=true` to the starting Java executable, which will enable -[exporting metrics](https://github.com/signalfx/splunk-otel-java/blob/main/docs/metrics.md). Default: `false`. - -### Syntax - -To add a comment or comment out a line, start it with a `#`. - -Not supported (and unnecessary) are: - -* Quoting of any kind -* Whitespace on either side of the equals sign -* Leading whitespace - -### Environment Variables - -The way the .so causes a Java executable to be instrumented is by setting the environment variables, JAVA_TOOL_OPTIONS -and OTEL_SERVICE_NAME, and optionally, OTEL_RESOURCE_ATTRIBUTES. - -#### JAVA_TOOL_OPTIONS - -This environment variable contains a `-javaagent` flag set to the full path of the Splunk OTel Java JAR. - -e.g. `JAVA_TOOL_OPTIONS='-javaagent:/usr/lib/splunk-instrumentation/splunk-otel-javaagent.jar'` - -This variable is populated by the .so by concatenating the `java_agent_jar` attribute in the config to a `-javaagent:` -prefix, and then appending any additional system properties specified in the configuration file. - -#### OTEL_SERVICE_NAME - -This environment variable sets the service name for the soon-to-be running Java application, usually derived from the -arguments of the Java executable (can be overridden via the config). - -This variable is set directly from the `service_name` attribute in the config. - -_Meta: link to docs about how service name is used and why it's required._ - -#### OTEL_RESOURCE_ATTRIBUTES - -This environment variable contains a list of name-value pairs (separated by `=`s) passed on to the Java instrumentation -jar. - -This variable is set directly from the optional `resource_attributes` attribute in the config. - -##### Service Name Generation - -The OTEL_SERVICE_NAME environment variable is set to a value that the .so generates from the arguments passed to the -Java executable. The .so does this by reading the arguments to the Java application from left to right, ignoring -arguments that look like flags (that start with a `-`), and reading arguments containing `.jar`, splitting those on `:`, -then on `/`, removing known path parts such as `usr`, `local`, etc., truncating the `.jar` extension, replacing dots -with dashes, removing segments, and concatenating the result with dashes. If while scanning the arguments, it finds a -main class name, it just returns the main class name with dots replaced with dashes and caps to lowercase, otherwise, -it returns the munged jar names. - -For example, the following command: - -``` -/usr/bin/java -jar app/petclinic/spring-petclinic-2.4.5.jar -``` - -produces a service name of: - -``` -app-petclinic-spring-2.4.5 -``` - -The following, more complex command: - -``` -java -Djava.util.logging.config.file=\ -/usr/local/apache-tomcat/8.5.4/conf/logging.properties \ --Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager \ --Djdk.tls.ephemeralDHKeySize=2048 \ --classpath \ -/usr/local/apache-tomcat/8.5.4/bin/bootstrap.jar:\ -/usr/local/apache-tomcat/8.5.4/bin/tomcat-juli.jar \ --Dcatalina.base=/usr/local/apache-tomcat/8.5.4 \ --Dcatalina.home=/usr/local/apache-tomcat/8.5.4 \ --Djava.io.tmpdir=/usr/local/apache-tomcat/8.5.4/temp \ -org.apache.catalina.startup.Bootstrap start -``` - -produces a service name of: - -``` -org-apache-catalina-startup-bootstrap -``` - -## Disabling - -Short of uninstalling the package, there are a few safe ways of disabling auto instrumentation - -* Set `DISABLE_SPLUNK_AUTOINSTRUMENTATION` to any non-empty value other than false, FALSE, or 0 -* Set `JAVA_TOOL_OPTIONS` to some value that you want the JVM to pick up -* Delete or move the config `instrumentation.conf` file - -## Files - -* /usr/lib/splunk-instrumentation/libsplunk.so -* /usr/lib/splunk-instrumentation/instrumentation.conf -* /usr/lib/splunk-instrumentation/splunk-otel-javaagent.jar diff --git a/instrumentation/packaging/fpm/examples/systemd/00-splunk-otel-js.conf b/instrumentation/packaging/fpm/examples/systemd/00-splunk-otel-auto-instrumentation.conf similarity index 54% rename from instrumentation/packaging/fpm/examples/systemd/00-splunk-otel-js.conf rename to instrumentation/packaging/fpm/examples/systemd/00-splunk-otel-auto-instrumentation.conf index fdbcef9801..5199d821e6 100644 --- a/instrumentation/packaging/fpm/examples/systemd/00-splunk-otel-js.conf +++ b/instrumentation/packaging/fpm/examples/systemd/00-splunk-otel-auto-instrumentation.conf @@ -12,17 +12,22 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Sample systemd drop-in file to activate and configure Splunk OpenTelemetry Auto Instrumentation for Node.js +# Sample systemd drop-in file to activate and configure Splunk OpenTelemetry Auto Instrumentation for Java and Node.js +# https://docs.splunk.com/Observability/gdi/get-data-in/application/java/get-started.html # https://docs.splunk.com/Observability/gdi/get-data-in/application/nodejs/get-started.html -# To use this file to activate/configure auto instrumentation for all supported Node.js applications running as systemd +# To use this file to activate/configure auto instrumentation for all supported applications running as systemd # services (requires root privileges): -# 1. Check https://docs.splunk.com/Observability/gdi/get-data-in/application/nodejs/nodejs-otel-requirements.html for -# minimum requirements. -# 2. Install the provided Node.js auto instrumentation package with npm. For example: -# $ sudo npm install --global /usr/lib/splunk-instrumentation/splunk-otel-js.tar.gz -# 3. See https://docs.splunk.com/Observability/gdi/get-data-in/application/nodejs/configuration/advanced-nodejs-otel-configuration.html -# for supported environment variables and defaults for Node.js auto instrumentation +# 1. Check agent compatibility and requirements: +# - Java: https://docs.splunk.com/Observability/gdi/get-data-in/application/java/java-otel-requirements.html for +# - Node.js: https://docs.splunk.com/Observability/gdi/get-data-in/application/nodejs/nodejs-otel-requirements.html +# 2. Check supported environment variables and defaults: +# - Java: https://docs.splunk.com/Observability/gdi/get-data-in/application/java/configuration/advanced-java-otel-configuration.html +# - Node.js: https://docs.splunk.com/Observability/gdi/get-data-in/application/nodejs/configuration/advanced-nodejs-otel-configuration.html +# 3. If Node.js is required, install the provided Node.js auto instrumentation package with npm and any dependencies. +# For example: +# $ sudo npm install --global /usr/lib/splunk-instrumentation/splunk-otel-js.tgz +# Important: Ensure that all Node.js services to be instrumented has access to the installation path. # 4. Add/Update the DefaultEnvironment entries below for the desired environment variables and values # 5. Copy this file to the systemd configuration directory, e.g. /usr/lib/systemd/system.conf.d/ # 6. Reboot the system or run the following commands to restart the applicable service(s) for any changes to take effect: @@ -33,11 +38,17 @@ # about systemd configuration and other supported options. [Manager] +# Required to activate Splunk OpenTelemetry Auto Instrumentation for Java +DefaultEnvironment="JAVA_TOOL_OPTIONS=-javaagent:/usr/lib/splunk-instrumentation/splunk-otel-javaagent.jar" + # Required to activate Splunk OpenTelemetry Auto Instrumentation for Node.js DefaultEnvironment="NODE_OPTIONS=-r @splunk/otel/instrument" -# Examples of common configuration options: -#DefaultEnvironment="OTEL_EXPORTER_OTLP_ENDPOINT=http://1.2.3.4:5678" +# Examples of common configuration options. +# The environment variables defined in this file will apply to all activated agents. +#DefaultEnvironment="OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:4317" #DefaultEnvironment="OTEL_RESOURCE_ATTRIBUTES=deployment.environment=my_deployment_environment" #DefaultEnvironment="OTEL_SERVICE_NAME=my_service_name" +#DefaultEnvironment="SPLUNK_METRICS_ENABLED=true" #DefaultEnvironment="SPLUNK_PROFILER_ENABLED=true" +#DefaultEnvironment="SPLUNK_PROFILER_MEMORY_ENABLED=true" diff --git a/instrumentation/packaging/fpm/examples/systemd/00-splunk-otel-javaagent.conf b/instrumentation/packaging/fpm/examples/systemd/00-splunk-otel-javaagent.conf deleted file mode 100644 index e08382f45f..0000000000 --- a/instrumentation/packaging/fpm/examples/systemd/00-splunk-otel-javaagent.conf +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright Splunk Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Sample systemd drop-in file to activate and configure Splunk OpenTelemetry Auto Instrumentation for Java -# https://docs.splunk.com/Observability/gdi/get-data-in/application/java/get-started.html - -# To use this file to activate/configure auto instrumentation for all supported Java applications running as systemd -# services (requires root privileges): -# 1. Check https://docs.splunk.com/Observability/gdi/get-data-in/application/java/java-otel-requirements.html for -# minimum requirements -# 2. See https://docs.splunk.com/Observability/gdi/get-data-in/application/java/configuration/advanced-java-otel-configuration.html -# for supported environment variables and defaults for Java auto instrumentation -# 3. Add/Update the DefaultEnvironment entries below for the desired environment variables and values -# 4. Copy this file to the systemd configuration directory, e.g. /usr/lib/systemd/system.conf.d/ -# 5. Reboot the system or run the following commands to restart the applicable service(s) for any changes to take effect: -# $ sudo systemctl daemon-reload -# $ sudo systemctl restart # replace "" and run for each applicable service - -# See https://www.freedesktop.org/software/systemd/man/systemd-system.conf.html for general information -# about systemd configuration and other supported options. - -[Manager] -# Required to activate Splunk OpenTelemetry Auto Instrumentation for Java -DefaultEnvironment="JAVA_TOOL_OPTIONS=-javaagent:/usr/lib/splunk-instrumentation/splunk-otel-javaagent.jar" - -# Examples of common configuration options: -#DefaultEnvironment="OTEL_EXPORTER_OTLP_ENDPOINT=http://1.2.3.4:5678" -#DefaultEnvironment="OTEL_RESOURCE_ATTRIBUTES=deployment.environment=my_deployment_environment" -#DefaultEnvironment="OTEL_SERVICE_NAME=my_service_name" -#DefaultEnvironment="SPLUNK_PROFILER_ENABLED=true" diff --git a/instrumentation/packaging/nodejs-agent-release.txt b/instrumentation/packaging/nodejs-agent-release.txt index 8721bbc46a..6bd4da99c9 100644 --- a/instrumentation/packaging/nodejs-agent-release.txt +++ b/instrumentation/packaging/nodejs-agent-release.txt @@ -1 +1 @@ -v2.4.0 +v2.4.4 diff --git a/instrumentation/systemd.md b/instrumentation/systemd.md deleted file mode 100644 index 15633b6e47..0000000000 --- a/instrumentation/systemd.md +++ /dev/null @@ -1,95 +0,0 @@ -# Splunk OpenTelemetry Zero Configuration Auto Instrumentation for Systemd - -The `splunk-otel-auto-instrumentation` Debian/RPM package provides examples of drop-in file(s) that can be copied to the -host's `systemd` configuration directory to activate/configure Auto Instrumentation agent(s) for supported applications -running as `systemd` services by defining default environment variables. - -## Manual Systemd Configuration - -> `systemd` supports many options, methods, and paths for configuring environment variables at the system level or for -> individual services, and are not limited to the examples below. Before making any changes, it is recommended to -> consult the documentation specific to your Linux distribution or service, and check the existing configuration of the -> system or individual services for potential conflicts. For general details about `systemd`, see the -> [`systemd` man page](https://www.freedesktop.org/software/systemd/man/index.html). - -### Java Auto Instrumentation ### - -See the [Advanced Configuration Guide]( -https://docs.splunk.com/Observability/gdi/get-data-in/application/java/configuration/advanced-java-otel-configuration.html) -for details about supported options and defaults for the Java agent. These options can be configured via environment -variables or their corresponding system properties. - -#### Configuration Priority #### - -The Java agent can consume configuration options from one or more of the following sources (ordered from highest to -lowest priority): -1. Java system properties (`-D` flags) passed directly to the agent. For example, - ```shell - JAVA_TOOL_OPTIONS="-javaagent:/usr/lib/splunk-instrumentation/splunk-otel-javaagent.jar -Dotel.service.name=my-service" - ``` -2. Environment variables -3. Property files - -See [Configuring the agent]( -https://opentelemetry.io/docs/instrumentation/java/automatic/agent-config/#configuring-the-agent) for more -information. - -#### Quick Start #### - -The [`/usr/lib/splunk-instrumentation/examples/systemd/00-splunk-otel-javaagent.conf`]( -packaging/fpm/examples/systemd/00-splunk-otel-javaagent.conf) example drop-in file defines the following environment variable: - -- `JAVA_TOOL_OPTIONS=-javaagent:/usr/lib/splunk-instrumentation/splunk-otel-javaagent.jar` - -To activate the Java agent and its default configuration for ***all*** Java applications running as `systemd` services, -copy this file to the host's `systemd` configuration directory, e.g. `/usr/lib/systemd/system.conf.d/`, and -reboot the system or run the following commands to restart the applicable services for the changes to take effect -(requires `root` privileges): - ```shell - $ systemctl daemon-reload - $ systemctl restart # replace "" and run for each applicable service - ``` - -#### Configuration #### - -To configure the Java agent, add/modify/override [supported environment variables]( -https://docs.splunk.com/Observability/gdi/get-data-in/application/java/configuration/advanced-java-otel-configuration.html) -within `/usr/lib/systemd/system.conf.d/00-splunk-otel-javaagent.conf` (requires `root` privileges): - -1. **Option A**: Add/Update `DefaultEnvironment` within `/usr/lib/systemd/system.conf.d/00-splunk-otel-javaagent.conf` - for the desired environment variables. For example: - ```shell - $ cat < /usr/lib/systemd/system.conf.d/00-splunk-otel-javaagent.conf - [Manager] - DefaultEnvironment="JAVA_TOOL_OPTIONS=-javaagent:/my/custom/splunk-otel-javaagent.jar -Dotel.service.name=my-service" - DefaultEnvironment="OTEL_RESOURCE_ATTRIBUTES=myattrubute1=value1,myattribute2=value2" - DefaultEnvironment="SPLUNK_PROFILER_ENABLED=true" - EOH - ``` - **Option B**: Create/Modify a higher-priority drop-in file for ***all*** services to add or override the environment - variables defined in `/usr/lib/systemd/system.conf.d/00-splunk-otel-javaagent.conf`. For example: - ```shell - $ cat <> /usr/lib/systemd/system.conf.d/99-my-custom-env-vars.conf - [Manager] - DefaultEnvironment="JAVA_TOOL_OPTIONS=-javaagent:/my/custom/splunk-otel-javaagent.jar -Dotel.service.name=my-service" - DefaultEnvironment="OTEL_RESOURCE_ATTRIBUTES=myattrubute1=value1,myattribute2=value2" - DefaultEnvironment="SPLUNK_PROFILER_ENABLED=true" - EOH - ``` - **Option C**: Create/Modify a higher-priority drop-in file for a ***specific*** service to add or override the - environment variables defined in `/usr/lib/systemd/system.conf.d/00-splunk-otel-javaagent.conf`. For - example: - ```shell - $ cat <> /usr/lib/systemd/system/my-service.d/99-my-custom-env-vars.conf - [Service] - Environment="JAVA_TOOL_OPTIONS=-javaagent:/my/custom/splunk-otel-javaagent.jar -Dotel.service.name=my-service" - Environment="OTEL_RESOURCE_ATTRIBUTES=myattrubute1=value1,myattribute2=value2" - Environment="SPLUNK_PROFILER_ENABLED=true" - EOH - ``` -2. After any configuration changes, reboot the system or run the following commands to restart the applicable services - for the changes to take effect: - ```shell - $ systemctl daemon-reload - $ systemctl restart # replace "" and run for each applicable service - ``` diff --git a/internal/buildscripts/packaging/tests/instrumentation/images/deb/Dockerfile.debian-bullseye b/internal/buildscripts/packaging/tests/instrumentation/images/deb/Dockerfile.debian-bullseye index b33257b79a..367b459b1e 100644 --- a/internal/buildscripts/packaging/tests/instrumentation/images/deb/Dockerfile.debian-bullseye +++ b/internal/buildscripts/packaging/tests/instrumentation/images/deb/Dockerfile.debian-bullseye @@ -7,7 +7,7 @@ FROM debian:bullseye ENV DEBIAN_FRONTEND noninteractive RUN apt-get update &&\ - apt-get install -yq ca-certificates curl procps systemd wget + apt-get install -yq ca-certificates curl procps python3 systemd wget ENV container docker RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i = \ @@ -24,7 +24,6 @@ COPY instrumentation/setup-tomcat.sh /opt/ RUN bash /opt/setup-tomcat.sh ARG NODE_VERSION=v16 -ENV NODE_PATH=/opt/express/node_modules COPY instrumentation/setup-express.sh /opt RUN bash /opt/setup-express.sh diff --git a/internal/buildscripts/packaging/tests/instrumentation/images/deb/Dockerfile.debian-buster b/internal/buildscripts/packaging/tests/instrumentation/images/deb/Dockerfile.debian-buster index fbcabe2929..d4d955132d 100644 --- a/internal/buildscripts/packaging/tests/instrumentation/images/deb/Dockerfile.debian-buster +++ b/internal/buildscripts/packaging/tests/instrumentation/images/deb/Dockerfile.debian-buster @@ -7,7 +7,7 @@ FROM debian:buster ENV DEBIAN_FRONTEND noninteractive RUN apt-get update &&\ - apt-get install -yq ca-certificates curl procps systemd wget + apt-get install -yq ca-certificates curl procps python3 systemd wget ENV container docker RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i = \ @@ -24,7 +24,6 @@ COPY instrumentation/setup-tomcat.sh /opt/ RUN bash /opt/setup-tomcat.sh ARG NODE_VERSION=v16 -ENV NODE_PATH=/opt/express/node_modules COPY instrumentation/setup-express.sh /opt RUN bash /opt/setup-express.sh diff --git a/internal/buildscripts/packaging/tests/instrumentation/images/deb/Dockerfile.debian-stretch b/internal/buildscripts/packaging/tests/instrumentation/images/deb/Dockerfile.debian-stretch index ddc5fcafb8..b82b32ccea 100644 --- a/internal/buildscripts/packaging/tests/instrumentation/images/deb/Dockerfile.debian-stretch +++ b/internal/buildscripts/packaging/tests/instrumentation/images/deb/Dockerfile.debian-stretch @@ -10,7 +10,7 @@ RUN sed -i 's|http://.*.debian.org|http://archive.debian.org|' /etc/apt/sources. RUN sed -i '/stretch-updates/d' /etc/apt/sources.list RUN apt-get update &&\ - apt-get install -yq ca-certificates curl procps systemd wget + apt-get install -yq ca-certificates curl procps python3 systemd wget ENV container docker RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i = \ @@ -27,7 +27,6 @@ COPY instrumentation/setup-tomcat.sh /opt/ RUN bash /opt/setup-tomcat.sh ARG NODE_VERSION=v14 -ENV NODE_PATH=/opt/express/node_modules COPY instrumentation/setup-express.sh /opt RUN bash /opt/setup-express.sh diff --git a/internal/buildscripts/packaging/tests/instrumentation/images/deb/Dockerfile.ubuntu-bionic b/internal/buildscripts/packaging/tests/instrumentation/images/deb/Dockerfile.ubuntu-bionic index aa28c546bf..92f5c124dd 100644 --- a/internal/buildscripts/packaging/tests/instrumentation/images/deb/Dockerfile.ubuntu-bionic +++ b/internal/buildscripts/packaging/tests/instrumentation/images/deb/Dockerfile.ubuntu-bionic @@ -7,7 +7,7 @@ FROM ubuntu:bionic ENV DEBIAN_FRONTEND noninteractive RUN apt-get update &&\ - apt-get install -yq ca-certificates curl procps systemd wget + apt-get install -yq ca-certificates curl procps python3 systemd wget ENV container docker RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i = \ @@ -24,7 +24,6 @@ COPY instrumentation/setup-tomcat.sh /opt/ RUN bash /opt/setup-tomcat.sh ARG NODE_VERSION=v16 -ENV NODE_PATH=/opt/express/node_modules COPY instrumentation/setup-express.sh /opt RUN bash /opt/setup-express.sh diff --git a/internal/buildscripts/packaging/tests/instrumentation/images/deb/Dockerfile.ubuntu-focal b/internal/buildscripts/packaging/tests/instrumentation/images/deb/Dockerfile.ubuntu-focal index 42ff230e64..875e0ed6d9 100644 --- a/internal/buildscripts/packaging/tests/instrumentation/images/deb/Dockerfile.ubuntu-focal +++ b/internal/buildscripts/packaging/tests/instrumentation/images/deb/Dockerfile.ubuntu-focal @@ -7,7 +7,7 @@ FROM ubuntu:focal ENV DEBIAN_FRONTEND noninteractive RUN apt-get update &&\ - apt-get install -yq ca-certificates curl procps systemd wget + apt-get install -yq ca-certificates curl procps python3 systemd wget ENV container docker RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i = \ @@ -24,7 +24,6 @@ COPY instrumentation/setup-tomcat.sh /opt/ RUN bash /opt/setup-tomcat.sh ARG NODE_VERSION=v16 -ENV NODE_PATH=/opt/express/node_modules COPY instrumentation/setup-express.sh /opt RUN bash /opt/setup-express.sh diff --git a/internal/buildscripts/packaging/tests/instrumentation/images/deb/Dockerfile.ubuntu-jammy b/internal/buildscripts/packaging/tests/instrumentation/images/deb/Dockerfile.ubuntu-jammy index 8025db7dbb..a41743666a 100644 --- a/internal/buildscripts/packaging/tests/instrumentation/images/deb/Dockerfile.ubuntu-jammy +++ b/internal/buildscripts/packaging/tests/instrumentation/images/deb/Dockerfile.ubuntu-jammy @@ -7,7 +7,7 @@ FROM ubuntu:jammy ENV DEBIAN_FRONTEND noninteractive RUN apt-get update &&\ - apt-get install -yq ca-certificates curl procps systemd wget + apt-get install -yq ca-certificates curl procps python3 systemd wget ENV container docker RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i = \ @@ -24,7 +24,6 @@ COPY instrumentation/setup-tomcat.sh /opt/ RUN bash /opt/setup-tomcat.sh ARG NODE_VERSION=v16 -ENV NODE_PATH=/opt/express/node_modules COPY instrumentation/setup-express.sh /opt RUN bash /opt/setup-express.sh diff --git a/internal/buildscripts/packaging/tests/instrumentation/images/deb/Dockerfile.ubuntu-xenial b/internal/buildscripts/packaging/tests/instrumentation/images/deb/Dockerfile.ubuntu-xenial index b88c42849d..3692ac0886 100644 --- a/internal/buildscripts/packaging/tests/instrumentation/images/deb/Dockerfile.ubuntu-xenial +++ b/internal/buildscripts/packaging/tests/instrumentation/images/deb/Dockerfile.ubuntu-xenial @@ -7,7 +7,7 @@ FROM ubuntu:xenial ENV DEBIAN_FRONTEND noninteractive RUN apt-get update &&\ - apt-get install -yq ca-certificates curl procps systemd wget + apt-get install -yq ca-certificates curl procps python3 systemd wget ENV container docker RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i = \ @@ -24,7 +24,6 @@ COPY instrumentation/setup-tomcat.sh /opt/ RUN bash /opt/setup-tomcat.sh ARG NODE_VERSION=v16 -ENV NODE_PATH=/opt/express/node_modules COPY instrumentation/setup-express.sh /opt RUN bash /opt/setup-express.sh diff --git a/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.amazonlinux-2 b/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.amazonlinux-2 index cd71cf7bfe..ca5c78f4cc 100644 --- a/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.amazonlinux-2 +++ b/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.amazonlinux-2 @@ -6,7 +6,7 @@ FROM amazonlinux:2 ENV container docker -RUN yum install -y curl procps initscripts systemd wget tar +RUN yum install -y curl procps initscripts python3 systemd wget tar RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i = \ "systemd-tmpfiles-setup.service" ] || rm -f $i; done); \ @@ -23,7 +23,6 @@ COPY instrumentation/setup-tomcat.sh /opt/ RUN bash /opt/setup-tomcat.sh ARG NODE_VERSION=v16 -ENV NODE_PATH=/opt/express/node_modules COPY instrumentation/setup-express.sh /opt RUN bash /opt/setup-express.sh diff --git a/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.amazonlinux-2023 b/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.amazonlinux-2023 index 1a5fb6e431..eb83559dd1 100644 --- a/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.amazonlinux-2023 +++ b/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.amazonlinux-2023 @@ -6,7 +6,7 @@ FROM amazonlinux:2023 ENV container docker -RUN yum install -y procps initscripts systemd systemd-udev wget tar +RUN yum install -y procps initscripts python3 systemd systemd-udev wget tar RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i = \ "systemd-tmpfiles-setup.service" ] || rm -f $i; done); \ @@ -23,7 +23,6 @@ COPY instrumentation/setup-tomcat.sh /opt/ RUN bash /opt/setup-tomcat.sh ARG NODE_VERSION=v16 -ENV NODE_PATH=/opt/express/node_modules COPY instrumentation/setup-express.sh /opt RUN bash /opt/setup-express.sh diff --git a/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.centos-7 b/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.centos-7 index 70a13aee46..84114fbeab 100644 --- a/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.centos-7 +++ b/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.centos-7 @@ -7,7 +7,7 @@ FROM centos:7 ENV container docker RUN echo 'fastestmirror=1' >> /etc/yum.conf -RUN yum install -y curl procps initscripts systemd wget +RUN yum install -y curl procps initscripts python3 systemd wget RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i = \ "systemd-tmpfiles-setup.service" ] || rm -f $i; done); \ @@ -24,7 +24,6 @@ COPY instrumentation/setup-tomcat.sh /opt/ RUN bash /opt/setup-tomcat.sh ARG NODE_VERSION=v14 -ENV NODE_PATH=/opt/express/node_modules COPY instrumentation/setup-express.sh /opt RUN bash /opt/setup-express.sh diff --git a/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.centos-8 b/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.centos-8 index 865908e292..e4ab80b670 100644 --- a/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.centos-8 +++ b/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.centos-8 @@ -7,7 +7,7 @@ FROM quay.io/centos/centos:stream8 ENV container docker RUN echo 'fastestmirror=1' >> /etc/yum.conf -RUN dnf install -y procps initscripts systemd wget +RUN dnf install -y procps initscripts python3 systemd wget RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i = \ "systemd-tmpfiles-setup.service" ] || rm -f $i; done); \ @@ -24,7 +24,6 @@ COPY instrumentation/setup-tomcat.sh /opt/ RUN bash /opt/setup-tomcat.sh ARG NODE_VERSION=v16 -ENV NODE_PATH=/opt/express/node_modules COPY instrumentation/setup-express.sh /opt RUN bash /opt/setup-express.sh diff --git a/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.centos-9 b/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.centos-9 index 77b48b9cf3..c3c8b794ff 100644 --- a/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.centos-9 +++ b/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.centos-9 @@ -8,7 +8,7 @@ ENV container docker RUN rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial RUN echo 'fastestmirror=1' >> /etc/yum.conf -RUN dnf install -y procps initscripts systemd wget +RUN dnf install -y procps initscripts python3 systemd wget RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i = \ "systemd-tmpfiles-setup.service" ] || rm -f $i; done); \ @@ -25,7 +25,6 @@ COPY instrumentation/setup-tomcat.sh /opt/ RUN bash /opt/setup-tomcat.sh ARG NODE_VERSION=v16 -ENV NODE_PATH=/opt/express/node_modules COPY instrumentation/setup-express.sh /opt RUN bash /opt/setup-express.sh diff --git a/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.opensuse-12 b/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.opensuse-12 index ca995191e2..99a5c62ee1 100644 --- a/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.opensuse-12 +++ b/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.opensuse-12 @@ -8,7 +8,7 @@ ENV container docker RUN sed -i 's|download.opensuse.org|ftp5.gwdg.de/pub/opensuse/discontinued|' /etc/zypp/repos.d/*.repo RUN zypper -n clean && zypper -n refresh -RUN zypper -n install -l curl dbus-1 gzip procps systemd-sysvinit tar wget +RUN zypper -n install -l curl dbus-1 gzip procps python3 systemd-sysvinit tar wget RUN (cd /usr/lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i = \ "systemd-tmpfiles-setup.service" ] || rm -f $i; done); \ @@ -25,7 +25,6 @@ COPY instrumentation/setup-tomcat.sh /opt/ RUN bash /opt/setup-tomcat.sh ARG NODE_VERSION=v16 -ENV NODE_PATH=/opt/express/node_modules COPY instrumentation/setup-express.sh /opt RUN bash /opt/setup-express.sh diff --git a/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.opensuse-15 b/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.opensuse-15 index 8568d5499d..1be395f8a7 100644 --- a/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.opensuse-15 +++ b/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.opensuse-15 @@ -7,7 +7,7 @@ FROM opensuse/leap:15 ENV container docker RUN sed -i 's|download.opensuse.org|provo-mirror.opensuse.org|' /etc/zypp/repos.d/*.repo -RUN zypper -n install -l curl dbus-1 gzip systemd-sysvinit tar wget +RUN zypper -n install -l curl dbus-1 gzip python3 systemd-sysvinit tar wget RUN (cd /usr/lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i = \ "systemd-tmpfiles-setup.service" ] || rm -f $i; done); \ @@ -23,7 +23,6 @@ COPY instrumentation/setup-tomcat.sh /opt/ RUN bash /opt/setup-tomcat.sh ARG NODE_VERSION=v16 -ENV NODE_PATH=/opt/express/node_modules COPY instrumentation/setup-express.sh /opt RUN bash /opt/setup-express.sh diff --git a/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.oraclelinux-7 b/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.oraclelinux-7 index 2c1ddbf18b..cdab8f5e7a 100644 --- a/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.oraclelinux-7 +++ b/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.oraclelinux-7 @@ -6,7 +6,7 @@ FROM oraclelinux:7 ENV container docker -RUN yum install -y curl procps initscripts systemd wget +RUN yum install -y curl procps initscripts python3 systemd wget RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i = \ "systemd-tmpfiles-setup.service" ] || rm -f $i; done); \ @@ -23,7 +23,6 @@ COPY instrumentation/setup-tomcat.sh /opt/ RUN bash /opt/setup-tomcat.sh ARG NODE_VERSION=v14 -ENV NODE_PATH=/opt/express/node_modules COPY instrumentation/setup-express.sh /opt RUN bash /opt/setup-express.sh diff --git a/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.oraclelinux-8 b/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.oraclelinux-8 index a935096bd8..ce1010fb37 100644 --- a/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.oraclelinux-8 +++ b/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.oraclelinux-8 @@ -6,7 +6,7 @@ FROM oraclelinux:8 ENV container docker -RUN dnf install -y curl procps initscripts systemd wget +RUN dnf install -y curl procps initscripts python3 systemd wget RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i = \ "systemd-tmpfiles-setup.service" ] || rm -f $i; done); \ @@ -23,7 +23,6 @@ COPY instrumentation/setup-tomcat.sh /opt/ RUN bash /opt/setup-tomcat.sh ARG NODE_VERSION=v16 -ENV NODE_PATH=/opt/express/node_modules COPY instrumentation/setup-express.sh /opt RUN bash /opt/setup-express.sh diff --git a/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.oraclelinux-9 b/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.oraclelinux-9 index 4de6b7c6c2..cda8cf6ae6 100644 --- a/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.oraclelinux-9 +++ b/internal/buildscripts/packaging/tests/instrumentation/images/rpm/Dockerfile.oraclelinux-9 @@ -6,7 +6,7 @@ FROM oraclelinux:9 ENV container docker -RUN dnf install -y curl procps initscripts systemd wget +RUN dnf install -y curl procps initscripts python3 systemd wget RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i = \ "systemd-tmpfiles-setup.service" ] || rm -f $i; done); \ @@ -23,7 +23,6 @@ COPY instrumentation/setup-tomcat.sh /opt/ RUN bash /opt/setup-tomcat.sh ARG NODE_VERSION=v16 -ENV NODE_PATH=/opt/express/node_modules COPY instrumentation/setup-express.sh /opt RUN bash /opt/setup-express.sh diff --git a/internal/buildscripts/packaging/tests/instrumentation/instrumentation_test.py b/internal/buildscripts/packaging/tests/instrumentation/instrumentation_test.py index ba98b6bbcb..580d7fc486 100644 --- a/internal/buildscripts/packaging/tests/instrumentation/instrumentation_test.py +++ b/internal/buildscripts/packaging/tests/instrumentation/instrumentation_test.py @@ -43,20 +43,20 @@ COLLECTOR_CONFIG_PATH = TESTS_DIR / "instrumentation" / "config.yaml" PKG_NAME = "splunk-otel-auto-instrumentation" -LIBSPLUNK_PATH = "/usr/lib/splunk-instrumentation/libsplunk.so" +LIB_DIR = "/usr/lib/splunk-instrumentation" +LIBSPLUNK_PATH = f"{LIB_DIR}/libsplunk.so" PRELOAD_PATH = "/etc/ld.so.preload" SYSTEMD_CONF_DIR = "/usr/lib/systemd/system.conf.d" +SAMPLE_SYSTEMD_CONF_PATH = f"{LIB_DIR}/examples/systemd/00-splunk-otel-auto-instrumentation.conf" -JAVA_AGENT_PATH = "/usr/lib/splunk-instrumentation/splunk-otel-javaagent.jar" +JAVA_AGENT_PATH = f"{LIB_DIR}/splunk-otel-javaagent.jar" JAVA_CONFIG_PATH = "/etc/splunk/zeroconfig/java.conf" CUSTOM_JAVA_CONFIG_PATH = TESTS_DIR / "instrumentation" / "libsplunk-java-test.conf" -SAMPLE_JAVA_SYSTEMD_CONF_PATH = "/usr/lib/splunk-instrumentation/examples/systemd/00-splunk-otel-javaagent.conf" CUSTOM_JAVA_SYSTEMD_CONF_PATH = TESTS_DIR / "instrumentation" / "systemd-java-test.conf" -NODE_AGENT_PATH = "/usr/lib/splunk-instrumentation/splunk-otel-js.tgz" +NODE_AGENT_PATH = f"{LIB_DIR}/splunk-otel-js.tgz" NODE_CONFIG_PATH = "/etc/splunk/zeroconfig/node.conf" CUSTOM_NODE_CONFIG_PATH = TESTS_DIR / "instrumentation" / "libsplunk-node-test.conf" -SAMPLE_NODE_SYSTEMD_CONF_PATH = "/usr/lib/splunk-instrumentation/examples/systemd/00-splunk-otel-js.conf" CUSTOM_NODE_SYSTEMD_CONF_PATH = TESTS_DIR / "instrumentation" / "systemd-node-test.conf" INSTALLED_FILES = [ @@ -65,8 +65,7 @@ LIBSPLUNK_PATH, JAVA_CONFIG_PATH, NODE_CONFIG_PATH, - SAMPLE_JAVA_SYSTEMD_CONF_PATH, - SAMPLE_NODE_SYSTEMD_CONF_PATH, + SAMPLE_SYSTEMD_CONF_PATH, ] TOMCAT_PIDFILE = "/usr/local/tomcat/temp/tomcat.pid" @@ -251,7 +250,7 @@ def test_tomcat_instrumentation(distro, arch): if method == "systemd": # install the sample drop-in file to enable the agent run_container_cmd(container, f"mkdir -p {SYSTEMD_CONF_DIR}") - run_container_cmd(container, f"cp -f {SAMPLE_JAVA_SYSTEMD_CONF_PATH} {SYSTEMD_CONF_DIR}/") + run_container_cmd(container, f"cp -f {SAMPLE_SYSTEMD_CONF_PATH} {SYSTEMD_CONF_DIR}/") if container_file_exists(container, "/etc/ld.so.preload"): run_container_cmd(container, "rm -f /etc/ld.so.preload") else: @@ -300,19 +299,15 @@ def test_express_instrumentation(distro, arch): pkg_base = os.path.basename(pkg_path) # minimum supported node version required for profiling - node_version = "v16" - - if distro in ("centos-7", "oraclelinux-7"): + node_version = 16 + if arch == "arm64" and distro in ("centos-7", "oraclelinux-7"): # g++ for these distros is too old to install splunk-otel-js with node v16: - # g++: error: unrecognized command line option '-std=gnu++14' - # use the minimum supported node version without profiling instead - node_version = "v14" - elif distro in ("debian-stretch", "ubuntu-xenial"): - # these distros only provide python 3.5, but node v16 requires python 3.6+ + # g++: error: unrecognized command line option '-std=gnu++14' # use the minimum supported node version without profiling instead - node_version = "v14" + node_version = 14 + + buildargs = {"NODE_VERSION": f"v{node_version}"} - buildargs = {"NODE_VERSION": node_version} with run_distro_container(distro, dockerfile=get_dockerfile(distro), arch=arch, buildargs=buildargs) as container: copy_file_into_container(container, COLLECTOR_CONFIG_PATH, "/test/config.yaml") copy_file_into_container(container, pkg_path, f"/test/{pkg_base}") @@ -321,19 +316,23 @@ def test_express_instrumentation(distro, arch): install_package(container, distro, f"/test/{pkg_base}") - # install dependencies for splunk-otel-js - if "opensuse" in distro: - run_container_cmd(container, "zypper -n install -t pattern devel_basis") - run_container_cmd(container, "zypper -n install -t pattern devel_C_C++") - run_container_cmd(container, "zypper -n install python3") - elif distro in RPM_DISTROS: - run_container_cmd(container, "yum groupinstall -y 'Development Tools'") - run_container_cmd(container, "yum install -y python3") - else: - run_container_cmd(container, "apt-get install -y build-essential python3") + if arch == "arm64": + # dev packages and libs required to build splunk-otel-js + if "opensuse" in distro: + run_container_cmd(container, "zypper -n install -t pattern devel_basis") + run_container_cmd(container, "zypper -n install -t pattern devel_C_C++") + elif distro in RPM_DISTROS: + run_container_cmd(container, "yum groupinstall -y 'Development Tools'") + else: + run_container_cmd(container, "apt-get install -y build-essential") + + if distro in ("debian-stretch", "ubuntu-xenial"): + # npm installed with node v16 only supports python 3.6+, but these distros only provide python 3.5 + # downgrade npm to support python 3.5 + run_container_cmd(container, "bash -l -c 'npm install --global npm@^6'") # install splunk-otel-js - run_container_cmd(container, f"bash -l -c 'npm install --prefix /opt/express {NODE_AGENT_PATH}'") + run_container_cmd(container, f"bash -l -c 'npm install --global {NODE_AGENT_PATH}'") for method in ["systemd", "libsplunk"]: # attributes from default config @@ -345,7 +344,7 @@ def test_express_instrumentation(distro, arch): if method == "systemd": # install the sample drop-in file to enable the agent run_container_cmd(container, f"mkdir -p {SYSTEMD_CONF_DIR}") - run_container_cmd(container, f"cp -f {SAMPLE_NODE_SYSTEMD_CONF_PATH} {SYSTEMD_CONF_DIR}/") + run_container_cmd(container, f"cp -f {SAMPLE_SYSTEMD_CONF_PATH} {SYSTEMD_CONF_DIR}/") if container_file_exists(container, "/etc/ld.so.preload"): run_container_cmd(container, "rm -f /etc/ld.so.preload") else: @@ -360,7 +359,7 @@ def test_express_instrumentation(distro, arch): r"telemetry\.sdk\.language": r"Str\(nodejs\)", r"service\.name": rf"Str\(service_name_from_{method}_node\)", r"deployment\.environment": rf"Str\(deployment_environment_from_{method}_node\)", - r"com\.splunk\.sourcetype": None if node_version == "v14" else r"Str\(otel\.profiling\)", + r"com\.splunk\.sourcetype": None if node_version < 16 else r"Str\(otel\.profiling\)", } if method == "systemd": diff --git a/internal/buildscripts/packaging/tests/instrumentation/setup-express.sh b/internal/buildscripts/packaging/tests/instrumentation/setup-express.sh index 28f8f18079..77d7040118 100644 --- a/internal/buildscripts/packaging/tests/instrumentation/setup-express.sh +++ b/internal/buildscripts/packaging/tests/instrumentation/setup-express.sh @@ -13,9 +13,15 @@ NVM_DIR="$NVM_HOME/.nvm" nvm install --default ${NODE_VERSION:-v16} -echo "PATH=\$PATH:${NVM_BIN}" >> /etc/profile +npm config --global set user root -npm install --prefix $EXPRESS_HOME express +NODE_PATH="$( npm root -g )" + +mkdir -p /etc/profile.d +echo "export PATH=\$PATH:${NVM_BIN}" >> /etc/profile.d/node.sh +echo "export NODE_PATH=${NODE_PATH}" >> /etc/profile.d/node.sh + +npm install --global express cat < ${EXPRESS_HOME}/app.js var express = require('express'); @@ -44,7 +50,7 @@ After=network.target Type=simple User=express Group=express -Environment=NODE_PATH=${EXPRESS_HOME}/node_modules +Environment=NODE_PATH=${NODE_PATH} ExecStart=${NVM_BIN}/node ${EXPRESS_HOME}/app.js ExecStop=/bin/kill -TERM \$MAINPID Restart=on-failure