diff --git a/CHANGELOG.md b/CHANGELOG.md index f07fab6398..02c5dda4f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,16 @@ - (Splunk) Add `nginx` receiver ([5229](https://github.com/signalfx/splunk-otel-collector/pull/5229)) +### 💡 Enhancements 💡 + +- (Splunk) Auto Instrumentation for Linux ([#5243](https://github.com/signalfx/splunk-otel-collector/pull/5243)) + - Add support for the `OTEL_LOGS_EXPORTER` environment variable to `libsplunk.so` for system-wide auto instrumentation. + - Linux installer script: Add the `--logs-exporter ` option: + - Set the exporter for collected logs by all activated SDKs, for example `otlp`. + - Set the value to `none` to disable collection and export of logs. + - The value will be set to the `OTEL_LOGS_EXPORTER` environment variable. + - Defaults to `''` (empty), i.e. defer to the default `OTEL_LOGS_EXPORTER` value for each activated SDK. + ## v0.107.0 This Splunk OpenTelemetry Collector release includes changes from the [opentelemetry-collector v0.107.0](https://github.com/open-telemetry/opentelemetry-collector/releases/tag/v0.107.0) and the [opentelemetry-collector-contrib v0.107.0](https://github.com/open-telemetry/opentelemetry-collector-contrib/releases/tag/v0.107.0) releases where appropriate. diff --git a/instrumentation/README.md b/instrumentation/README.md index c4389d3343..2104d357dd 100644 --- a/instrumentation/README.md +++ b/instrumentation/README.md @@ -91,6 +91,7 @@ The following methods are supported to manually activate and configure Auto Inst each of these files (***any environment variable not in this list will be ignored***): - `OTEL_EXPORTER_OTLP_ENDPOINT` - `OTEL_EXPORTER_OTLP_PROTOCOL` + - `OTEL_LOGS_EXPORTER` - `OTEL_METRICS_EXPORTER` - `OTEL_RESOURCE_ATTRIBUTES` - `OTEL_SERVICE_NAME` diff --git a/instrumentation/src/main.c b/instrumentation/src/main.c index e922c0a55f..e6cb138a1e 100644 --- a/instrumentation/src/main.c +++ b/instrumentation/src/main.c @@ -6,7 +6,7 @@ #define MAX_LINE_LENGTH 1023 #define MAX_LINES 50 -#define ALLOWED_ENV_VARS "OTEL_SERVICE_NAME", "OTEL_EXPORTER_OTLP_ENDPOINT", "OTEL_RESOURCE_ATTRIBUTES", "SPLUNK_PROFILER_ENABLED", "SPLUNK_PROFILER_MEMORY_ENABLED", "SPLUNK_METRICS_ENABLED", "JAVA_TOOL_OPTIONS", "NODE_OPTIONS", "CORECLR_ENABLE_PROFILING", "CORECLR_PROFILER", "CORECLR_PROFILER_PATH", "DOTNET_ADDITIONAL_DEPS", "DOTNET_SHARED_STORE", "DOTNET_STARTUP_HOOKS", "OTEL_DOTNET_AUTO_HOME", "OTEL_DOTNET_AUTO_PLUGINS", "OTEL_EXPORTER_OTLP_PROTOCOL", "OTEL_METRICS_EXPORTER" +#define ALLOWED_ENV_VARS "OTEL_SERVICE_NAME", "OTEL_EXPORTER_OTLP_ENDPOINT", "OTEL_RESOURCE_ATTRIBUTES", "SPLUNK_PROFILER_ENABLED", "SPLUNK_PROFILER_MEMORY_ENABLED", "SPLUNK_METRICS_ENABLED", "JAVA_TOOL_OPTIONS", "NODE_OPTIONS", "CORECLR_ENABLE_PROFILING", "CORECLR_PROFILER", "CORECLR_PROFILER_PATH", "DOTNET_ADDITIONAL_DEPS", "DOTNET_SHARED_STORE", "DOTNET_STARTUP_HOOKS", "OTEL_DOTNET_AUTO_HOME", "OTEL_DOTNET_AUTO_PLUGINS", "OTEL_EXPORTER_OTLP_PROTOCOL", "OTEL_METRICS_EXPORTER", "OTEL_LOGS_EXPORTER" static char *const allowed_env_vars[] = {ALLOWED_ENV_VARS}; static size_t const allowed_env_vars_size = sizeof(allowed_env_vars) / sizeof(*allowed_env_vars); diff --git a/internal/buildscripts/packaging/installer/install.sh b/internal/buildscripts/packaging/installer/install.sh index ac8eb2f8c3..9c35d3d84d 100755 --- a/internal/buildscripts/packaging/installer/install.sh +++ b/internal/buildscripts/packaging/installer/install.sh @@ -119,6 +119,7 @@ enable_metrics="false" otlp_endpoint="" otlp_endpoint_protocol="" metrics_exporter="" +logs_exporter="" java_zeroconfig_path="/etc/splunk/zeroconfig/java.conf" node_zeroconfig_path="/etc/splunk/zeroconfig/node.conf" dotnet_zeroconfig_path="/etc/splunk/zeroconfig/dotnet.conf" @@ -532,6 +533,10 @@ EOH if [ -n "$metrics_exporter" ]; then echo "OTEL_METRICS_EXPORTER=${metrics_exporter}" >> $java_zeroconfig_path fi + + if [ -n "$logs_exporter" ]; then + echo "OTEL_LOGS_EXPORTER=${logs_exporter}" >> $java_zeroconfig_path + fi } splunk_otel_js_installed() { @@ -607,6 +612,10 @@ EOH if [ -n "$metrics_exporter" ]; then echo "OTEL_METRICS_EXPORTER=${metrics_exporter}" >> $node_zeroconfig_path fi + + if [ -n "$logs_exporter" ]; then + echo "OTEL_LOGS_EXPORTER=${logs_exporter}" >> $node_zeroconfig_path + fi } create_zeroconfig_dotnet() { @@ -650,6 +659,10 @@ EOH if [ -n "$metrics_exporter" ]; then echo "OTEL_METRICS_EXPORTER=${metrics_exporter}" >> $dotnet_zeroconfig_path fi + + if [ -n "$logs_exporter" ]; then + echo "OTEL_LOGS_EXPORTER=${logs_exporter}" >> $dotnet_zeroconfig_path + fi } create_systemd_instrumentation_config() { @@ -690,6 +703,10 @@ EOH echo "DefaultEnvironment=\"OTEL_METRICS_EXPORTER=${metrics_exporter}\"" >> $systemd_instrumentation_config_path fi + if [ -n "$logs_exporter" ]; then + echo "DefaultEnvironment=\"OTEL_LOGS_EXPORTER=${logs_exporter}\"" >> $systemd_instrumentation_config_path + fi + if item_in_list "java" "$sdks"; then echo "DefaultEnvironment=\"JAVA_TOOL_OPTIONS=-javaagent:${instrumentation_jar_path}\"" >> $systemd_instrumentation_config_path fi @@ -990,6 +1007,11 @@ Auto Instrumentation: environment variable. (default: empty, i.e. defer to the default OTEL_METRICS_EXPORTER value for each activated SDK) + --logs-exporter Set the exporter for collected logs by all activated SDKs, for example "otlp". + Set the value to "none" to disable collection and export of logs. The value will + be set to the OTEL_LOGS_EXPORTER environment variable. + (default: empty, i.e. defer to the default OTEL_LOGS_EXPORTER value for each + activated SDK) --[enable|disable]-profiler Enable or disable AlwaysOn Profiling for all activated SDKs that support the SPLUNK_PROFILER_ENABLED environment variable. (default: --disable-profiler) @@ -1409,6 +1431,10 @@ parse_args_and_install() { metrics_exporter="$2" shift 1 ;; + --logs-exporter) + logs_exporter="$2" + shift 1 + ;; --enable-profiler) enable_profiler="true" ;; diff --git a/internal/buildscripts/packaging/tests/installer_test.py b/internal/buildscripts/packaging/tests/installer_test.py index 7a8537fa58..ed508a237b 100644 --- a/internal/buildscripts/packaging/tests/installer_test.py +++ b/internal/buildscripts/packaging/tests/installer_test.py @@ -470,6 +470,7 @@ def test_installer_with_instrumentation_default(distro, arch, method): verify_config_file(container, config_path, "OTEL_EXPORTER_OTLP_ENDPOINT", ".*", exists=False) verify_config_file(container, config_path, "OTEL_SERVICE_NAME", ".*", exists=False) verify_config_file(container, config_path, "OTEL_METRICS_EXPORTER", ".*", exists=False) + verify_config_file(container, config_path, "OTEL_LOGS_EXPORTER", ".*", exists=False) verify_config_file(container, config_path, "OTEL_EXPORTER_OTLP_PROTOCOL", ".*", exists=False) else: # verify libsplunk.so was not added to /etc/ld.so.preload @@ -485,6 +486,7 @@ def test_installer_with_instrumentation_default(distro, arch, method): verify_config_file(container, SYSTEMD_CONFIG_PATH, "OTEL_EXPORTER_OTLP_ENDPOINT", ".*", exists=False) verify_config_file(container, SYSTEMD_CONFIG_PATH, "OTEL_SERVICE_NAME", ".*", exists=False) verify_config_file(container, SYSTEMD_CONFIG_PATH, "OTEL_METRICS_EXPORTER", ".*", exists=False) + verify_config_file(container, SYSTEMD_CONFIG_PATH, "OTEL_LOGS_EXPORTER", ".*", exists=False) verify_config_file(container, SYSTEMD_CONFIG_PATH, "OTEL_EXPORTER_OTLP_PROTOCOL", ".*", exists=False) verify_dotnet_config(container, SYSTEMD_CONFIG_PATH, exists=True if arch == "amd64" else False) @@ -548,6 +550,7 @@ def test_installer_with_instrumentation_custom(distro, arch, method, sdk): "--otlp-endpoint http://0.0.0.0:4318", "--otlp-endpoint-protocol http/protobuf", "--metrics-exporter none", + "--logs-exporter none", )) if LOCAL_INSTRUMENTATION_PACKAGE: install_cmd = f"{install_cmd} --instrumentation-version /test/instrumentation.pkg" @@ -631,6 +634,7 @@ def test_installer_with_instrumentation_custom(distro, arch, method, sdk): verify_config_file(container, config_path, "OTEL_EXPORTER_OTLP_ENDPOINT", "http://0.0.0.0:4318") verify_config_file(container, config_path, "OTEL_SERVICE_NAME", service_name) verify_config_file(container, config_path, "OTEL_METRICS_EXPORTER", "none") + verify_config_file(container, config_path, "OTEL_LOGS_EXPORTER", "none") verify_config_file(container, config_path, "OTEL_EXPORTER_OTLP_PROTOCOL", "http/protobuf") else: # verify libsplunk.so was not added to /etc/ld.so.preload @@ -657,6 +661,7 @@ def test_installer_with_instrumentation_custom(distro, arch, method, sdk): verify_config_file(container, SYSTEMD_CONFIG_PATH, "OTEL_EXPORTER_OTLP_ENDPOINT", "http://0.0.0.0:4318") verify_config_file(container, SYSTEMD_CONFIG_PATH, "OTEL_SERVICE_NAME", service_name) verify_config_file(container, SYSTEMD_CONFIG_PATH, "OTEL_METRICS_EXPORTER", "none") + verify_config_file(container, SYSTEMD_CONFIG_PATH, "OTEL_LOGS_EXPORTER", "none") verify_config_file(container, SYSTEMD_CONFIG_PATH, "OTEL_EXPORTER_OTLP_PROTOCOL", "http/protobuf") verify_uninstall(container, distro)