Send Java application data to Observe¶
This page describes how to install the Observe Agent, then instrument your Java applications to send data to Observe.
OpenTelemetry automatically instruments and supports a large number of libraries, frameworks, and application servers for Java out of the box. See Supported libraries, frameworks, application servers, and JVMs in the OpenTelemetry documentation on GitHub.
To manually instrument custom logic, refer to Manage Telemetry with SDK in the Java SDK documentation.
Compatibility¶
To send Java application data to Observe, you must have Java version 8 or higher.
Get the Observe Agent¶
Use the Add Data portal in the product to get the Observe agent installed in your environment.
From the left navigation rail, select Data & integrations > Add data.
In the Observe Agent section, pick your environment, then follow the instructions to create a data ingest token and install the Observe Agent.
Add the OpenTelemetry zero-code instrumentation for Java¶
The instrumentation is packaged as a JAR file which dynamically injects bytecode to capture telemetry from your Java applications:
curl -L -O https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar
Configure the instrumentation¶
Set the following environment variables. Replace the placeholders such as ${YOUR_SERVICE_NAME} with the actual information from your environment.
OTEL_SERVICE_NAME=${YOUR_SERVICE_NAME}
JAVA_TOOL_OPTIONS=-javaagent:${PATH_TO}/opentelemetry-javaagent.jar
OTEL_RESOURCE_ATTRIBUTES=deployment.environment=${YOUR_APP_ENVIRONMENT}
OTEL_EXPORTER_OTLP_ENDPOINT=http://${YOUR_OBSERVE_AGENT_ENDPOINT}:4318
Run your instrumented app¶
Run the following command:
java -jar /path/to/myapp.jar
Next steps¶
Navigate to Traces in your Observe tenant to view traces from your application.
Troubleshooting¶
What to do if you encounter the following issues:
Your application data is not reaching Observe
Your ports are blocked by a firewall
You are getting duplicate spans in Observe
My application data is not reaching Observe¶
If your data is not showing up in Observe, first verify that Observe Agent is receiving data from your application. See Troubleshooting the Observe Agent.
Common reasons why the Observe agent is not receiving traces from your application:
Ports blocked by firewall¶
Ensure that any firewalls within the same network as your app and collector are configured to allow traffic on ports 4317 and 4318. The application instrumentation uses these ports to communicate with the Observe agent.
I am getting duplicate spans in Observe¶
If you’re seeing multiple spans with the same span_id in the Trace Explorer, the cause may be the following:
Multiple layers of OTel instrumentation for the same spans
Multiple exporters configured (either in your Agent, OTel collector, or application code) that point to Observe
Some other pathway in your environment is duplicating data (e.g., proxy or load balancer)