Configure the Java agent for Splunk Observability Cloud
Configure the agent of the Splunk Distribution of OpenTelemetry Java to suit most of your instrumentation needs, like correlating traces with logs, activating custom sampling, and more.
You can configure the Java agent from the Splunk Distribution of OpenTelemetry Java to suit most of your instrumentation needs. In most cases, modifying the basic configuration is enough to get started. More advanced settings are also available.
The following sections describe all available settings for configuring the Java Virtual Machine (JVM) agent, including options for activating new features that are unique to the Splunk Distribution of OpenTelemetry Java.
Configuration methods
You can change the agent settings in two ways:
-
Set an environment variable. For example:
- Linux
-
export OTEL_SERVICE_NAME=my-java-app
- Windows PowerShell
-
$env:OTEL_SERVICE_NAME=my-java-app
-
Add a system property as runtime parameter. For example:
java -javaagent:./splunk-otel-javaagent.jar \ -Dotel.service.name=<my-java-app> \ -jar <myapp>.jar
Environment variables are the preferred way of configuring OpenTelemetry agents. System properties, if specified, override existing environment variables.
General settings
The following settings are specific to the Splunk Distribution of OpenTelemetry Java:
{"keys": "Identifier", "description": "Description", "instrumented_components": "Components", "signals": "Signals", "env": "Environment variable", "default": "Default", "type": "Type", "property": "System property"}
general
category
settings
https://raw.githubusercontent.com/splunk/o11y-gdi-metadata/main/apm/splunk-otel-java/metadata.yaml
Example of trace sampling
The following example shows how to use the rules
traces sampler to exclude the /healthcheck
endpoint from monitoring:
export OTEL_TRACES_SAMPLER=rules
export OTEL_TRACES_SAMPLER_ARG=drop=/healthcheck;fallback=parentbased_always_on
All requests to downstream services that happen as a consequence of calling an excluded endpoint are also excluded.
Considerations on trace propagation
For backward compatibility with older versions of the Splunk Distribution of OpenTelemetry Java or the SignalFx Java Agent, use the b3multi trace propagator:
- Linux
-
export OTEL_PROPAGATORS=b3multi
- Windows PowerShell
-
$env:OTEL_PROPAGATORS=b3multi
Instrumentation configuration
The following settings control the instrumentation, including tracing and :
{"keys": "Identifier", "description": "Description", "instrumented_components": "Components", "signals": "Signals", "env": "Environment variable", "default": "Default", "type": "Type", "property": "System property"}
instrumentation
category
settings
https://raw.githubusercontent.com/splunk/o11y-gdi-metadata/main/apm/splunk-otel-java/metadata.yaml
Exporters configuration
The following settings control trace exporters and their endpoints:
{"keys": "Identifier", "description": "Description", "instrumented_components": "Components", "signals": "Signals", "env": "Environment variable", "default": "Default", "type": "Type", "property": "System property"}
exporter
category
settings
https://raw.githubusercontent.com/splunk/o11y-gdi-metadata/main/apm/splunk-otel-java/metadata.yaml
The Splunk Distribution of OpenTelemetry Java uses the OTLP http/protobuf span exporter by default. To send data directly to Splunk Observability Cloud, see Send data directly to Splunk Observability Cloud.
Java settings for AlwaysOn Profiling
The following settings control the AlwaysOn Profiling feature for the Java agent:
{"keys": "Identifier", "description": "Description", "instrumented_components": "Components", "signals": "Signals", "env": "Environment variable", "default": "Default", "type": "Type", "property": "System property"}
profiler
category
settings
https://raw.githubusercontent.com/splunk/o11y-gdi-metadata/main/apm/splunk-otel-java/metadata.yaml
For more information on AlwaysOn Profiling, see Introduction to AlwaysOn Profiling for Splunk APM.
Server trace information
To connect Real User Monitoring (RUM) requests from mobile and web applications with server trace data, trace response headers are activated by default. The instrumentation adds the following response headers to HTTP responses:
Access-Control-Expose-Headers: Server-Timing
Server-Timing: traceparent;desc="00-<serverTraceId>-<serverSpanId>-01"
The Server-Timing
header contains the traceId
and spanId
parameters in traceparent
format. For more information, see the Server-Timing and traceparent documentation on the W3C website.
The following server frameworks and libraries add Server-Timing
information:
-
Servlet API versions 2.2 to 4.X.
-
Netty versions 3.8 to 4.0.
SPLUNK_TRACE_RESPONSE_HEADER_ENABLED
to false
.Other settings
Environment variable |
Description |
---|---|
|
Globally activates the Java agent automatic instrumentation. The default value is |