Skip to content

Commit 756dc19

Browse files
auto instrumentation: support the OTEL_LOGS_EXPORTER env var (#5243)
1 parent a78d2a0 commit 756dc19

File tree

5 files changed

+40
-1
lines changed

5 files changed

+40
-1
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
### 💡 Enhancements 💡
1212

1313
- (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))
14+
- (Splunk) Auto Instrumentation for Linux ([#5243](https://github.com/signalfx/splunk-otel-collector/pull/5243))
15+
- Add support for the `OTEL_LOGS_EXPORTER` environment variable to `libsplunk.so` for system-wide auto instrumentation.
16+
- Linux installer script: Add the `--logs-exporter <value>` option:
17+
- Set the exporter for collected logs by all activated SDKs, for example `otlp`.
18+
- Set the value to `none` to disable collection and export of logs.
19+
- The value will be set to the `OTEL_LOGS_EXPORTER` environment variable.
20+
- Defaults to `''` (empty), i.e. defer to the default `OTEL_LOGS_EXPORTER` value for each activated SDK.
1421

1522

1623
## v0.107.0

instrumentation/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ The following methods are supported to manually activate and configure Auto Inst
9191
each of these files (***any environment variable not in this list will be ignored***):
9292
- `OTEL_EXPORTER_OTLP_ENDPOINT`
9393
- `OTEL_EXPORTER_OTLP_PROTOCOL`
94+
- `OTEL_LOGS_EXPORTER`
9495
- `OTEL_METRICS_EXPORTER`
9596
- `OTEL_RESOURCE_ATTRIBUTES`
9697
- `OTEL_SERVICE_NAME`

instrumentation/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#define MAX_LINE_LENGTH 1023
77
#define MAX_LINES 50
88

9-
#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"
9+
#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"
1010

1111
static char *const allowed_env_vars[] = {ALLOWED_ENV_VARS};
1212
static size_t const allowed_env_vars_size = sizeof(allowed_env_vars) / sizeof(*allowed_env_vars);

internal/buildscripts/packaging/installer/install.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ enable_metrics="false"
119119
otlp_endpoint=""
120120
otlp_endpoint_protocol=""
121121
metrics_exporter=""
122+
logs_exporter=""
122123
java_zeroconfig_path="/etc/splunk/zeroconfig/java.conf"
123124
node_zeroconfig_path="/etc/splunk/zeroconfig/node.conf"
124125
dotnet_zeroconfig_path="/etc/splunk/zeroconfig/dotnet.conf"
@@ -532,6 +533,10 @@ EOH
532533
if [ -n "$metrics_exporter" ]; then
533534
echo "OTEL_METRICS_EXPORTER=${metrics_exporter}" >> $java_zeroconfig_path
534535
fi
536+
537+
if [ -n "$logs_exporter" ]; then
538+
echo "OTEL_LOGS_EXPORTER=${logs_exporter}" >> $java_zeroconfig_path
539+
fi
535540
}
536541

537542
splunk_otel_js_installed() {
@@ -607,6 +612,10 @@ EOH
607612
if [ -n "$metrics_exporter" ]; then
608613
echo "OTEL_METRICS_EXPORTER=${metrics_exporter}" >> $node_zeroconfig_path
609614
fi
615+
616+
if [ -n "$logs_exporter" ]; then
617+
echo "OTEL_LOGS_EXPORTER=${logs_exporter}" >> $node_zeroconfig_path
618+
fi
610619
}
611620

612621
create_zeroconfig_dotnet() {
@@ -650,6 +659,10 @@ EOH
650659
if [ -n "$metrics_exporter" ]; then
651660
echo "OTEL_METRICS_EXPORTER=${metrics_exporter}" >> $dotnet_zeroconfig_path
652661
fi
662+
663+
if [ -n "$logs_exporter" ]; then
664+
echo "OTEL_LOGS_EXPORTER=${logs_exporter}" >> $dotnet_zeroconfig_path
665+
fi
653666
}
654667

655668
create_systemd_instrumentation_config() {
@@ -690,6 +703,10 @@ EOH
690703
echo "DefaultEnvironment=\"OTEL_METRICS_EXPORTER=${metrics_exporter}\"" >> $systemd_instrumentation_config_path
691704
fi
692705

706+
if [ -n "$logs_exporter" ]; then
707+
echo "DefaultEnvironment=\"OTEL_LOGS_EXPORTER=${logs_exporter}\"" >> $systemd_instrumentation_config_path
708+
fi
709+
693710
if item_in_list "java" "$sdks"; then
694711
echo "DefaultEnvironment=\"JAVA_TOOL_OPTIONS=-javaagent:${instrumentation_jar_path}\"" >> $systemd_instrumentation_config_path
695712
fi
@@ -990,6 +1007,11 @@ Auto Instrumentation:
9901007
environment variable.
9911008
(default: empty, i.e. defer to the default OTEL_METRICS_EXPORTER value for each
9921009
activated SDK)
1010+
--logs-exporter <exporter> Set the exporter for collected logs by all activated SDKs, for example "otlp".
1011+
Set the value to "none" to disable collection and export of logs. The value will
1012+
be set to the OTEL_LOGS_EXPORTER environment variable.
1013+
(default: empty, i.e. defer to the default OTEL_LOGS_EXPORTER value for each
1014+
activated SDK)
9931015
--[enable|disable]-profiler Enable or disable AlwaysOn Profiling for all activated SDKs that support the
9941016
SPLUNK_PROFILER_ENABLED environment variable.
9951017
(default: --disable-profiler)
@@ -1409,6 +1431,10 @@ parse_args_and_install() {
14091431
metrics_exporter="$2"
14101432
shift 1
14111433
;;
1434+
--logs-exporter)
1435+
logs_exporter="$2"
1436+
shift 1
1437+
;;
14121438
--enable-profiler)
14131439
enable_profiler="true"
14141440
;;

internal/buildscripts/packaging/tests/installer_test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ def test_installer_with_instrumentation_default(distro, arch, method):
470470
verify_config_file(container, config_path, "OTEL_EXPORTER_OTLP_ENDPOINT", ".*", exists=False)
471471
verify_config_file(container, config_path, "OTEL_SERVICE_NAME", ".*", exists=False)
472472
verify_config_file(container, config_path, "OTEL_METRICS_EXPORTER", ".*", exists=False)
473+
verify_config_file(container, config_path, "OTEL_LOGS_EXPORTER", ".*", exists=False)
473474
verify_config_file(container, config_path, "OTEL_EXPORTER_OTLP_PROTOCOL", ".*", exists=False)
474475
else:
475476
# verify libsplunk.so was not added to /etc/ld.so.preload
@@ -485,6 +486,7 @@ def test_installer_with_instrumentation_default(distro, arch, method):
485486
verify_config_file(container, SYSTEMD_CONFIG_PATH, "OTEL_EXPORTER_OTLP_ENDPOINT", ".*", exists=False)
486487
verify_config_file(container, SYSTEMD_CONFIG_PATH, "OTEL_SERVICE_NAME", ".*", exists=False)
487488
verify_config_file(container, SYSTEMD_CONFIG_PATH, "OTEL_METRICS_EXPORTER", ".*", exists=False)
489+
verify_config_file(container, SYSTEMD_CONFIG_PATH, "OTEL_LOGS_EXPORTER", ".*", exists=False)
488490
verify_config_file(container, SYSTEMD_CONFIG_PATH, "OTEL_EXPORTER_OTLP_PROTOCOL", ".*", exists=False)
489491
verify_dotnet_config(container, SYSTEMD_CONFIG_PATH, exists=True if arch == "amd64" else False)
490492

@@ -548,6 +550,7 @@ def test_installer_with_instrumentation_custom(distro, arch, method, sdk):
548550
"--otlp-endpoint http://0.0.0.0:4318",
549551
"--otlp-endpoint-protocol http/protobuf",
550552
"--metrics-exporter none",
553+
"--logs-exporter none",
551554
))
552555
if LOCAL_INSTRUMENTATION_PACKAGE:
553556
install_cmd = f"{install_cmd} --instrumentation-version /test/instrumentation.pkg"
@@ -631,6 +634,7 @@ def test_installer_with_instrumentation_custom(distro, arch, method, sdk):
631634
verify_config_file(container, config_path, "OTEL_EXPORTER_OTLP_ENDPOINT", "http://0.0.0.0:4318")
632635
verify_config_file(container, config_path, "OTEL_SERVICE_NAME", service_name)
633636
verify_config_file(container, config_path, "OTEL_METRICS_EXPORTER", "none")
637+
verify_config_file(container, config_path, "OTEL_LOGS_EXPORTER", "none")
634638
verify_config_file(container, config_path, "OTEL_EXPORTER_OTLP_PROTOCOL", "http/protobuf")
635639
else:
636640
# 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):
657661
verify_config_file(container, SYSTEMD_CONFIG_PATH, "OTEL_EXPORTER_OTLP_ENDPOINT", "http://0.0.0.0:4318")
658662
verify_config_file(container, SYSTEMD_CONFIG_PATH, "OTEL_SERVICE_NAME", service_name)
659663
verify_config_file(container, SYSTEMD_CONFIG_PATH, "OTEL_METRICS_EXPORTER", "none")
664+
verify_config_file(container, SYSTEMD_CONFIG_PATH, "OTEL_LOGS_EXPORTER", "none")
660665
verify_config_file(container, SYSTEMD_CONFIG_PATH, "OTEL_EXPORTER_OTLP_PROTOCOL", "http/protobuf")
661666

662667
verify_uninstall(container, distro)

0 commit comments

Comments
 (0)