Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auto instrumentation: support the OTEL_LOGS_EXPORTER env var #5243

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
### 💡 Enhancements 💡

- (Splunk) Update JMX Metric Gatherer to [v1.37.0](https://github.com/open-telemetry/opentelemetry-java-contrib/releases/tag/v1.37.0) ([#5240](https://github.com/signalfx/splunk-otel-collector/pull/5240))
- (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 <value>` 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

Expand Down
1 change: 1 addition & 0 deletions instrumentation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion instrumentation/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
26 changes: 26 additions & 0 deletions internal/buildscripts/packaging/installer/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 <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)
Expand Down Expand Up @@ -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"
;;
Expand Down
5 changes: 5 additions & 0 deletions internal/buildscripts/packaging/tests/installer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down