Come join our live training webinar every other Wednesday at 11am PST and hear LogicMonitor experts explain best practices and answer common questions. We understand these are uncertain times, and we are here to help!
There are two ways to approach OpenTelemetry-facilitated instrumentation for a Java application:
In the end, you may need a combination of both manual and auto-instrumentation.
LogicMonitor provides a configuration wizard for automatic Instrumentation of Java applications.
1. At the top right of the Traces page, select Onboarding.
2. Select Java, and confirm automatic instrumentation.
The wizard will prompt you to download the JAR file you’ll attach to your application. This JAR file is a Java client library provided by OpenTelemetry.
3. After the JAR downloads, provide the following information:
Note: LogicMonitor requires the following custom tags to map traces to existing monitored resources: ip, resource.type (which should be set to kubernetes-pod, cloud, or host), and host.name (which should be the pod name for Kubernetes). We recommend using these custom tags when possible to ensure that traces can be shown in the context of logs, metrics, and alerts.
4. Based on what you enter in the three fields, commands for attaching the auto-instrumentation client library to your application with the correct configuration are generated. Copy and run these commands on the server where your application is running. Make sure to reference the JAR for your application at the end.
Note: If your OpenTelemetry Collector was installed on a different server, you may need to update the value of Dotel.export.otlp.endpoint from localhost to the IP of the server where the OpenTelemetry Collector is running.
When instrumenting your application in Kubernetes, you will need to specify the javaagent flag with configuration options as environment values using JAVA_TOOL_OPTIONS. For example:
- name: server
- mountPath: /mnt/auto-trace
- containerPort: 9555
- name: PORT
- name: JAVA_TOOL_OPTIONS
value: "-javaagent:/mnt/auto-trace/opentelemetry-javaagent-all.jar -Dotel.resource.attributes=service.name=adservice -Dotel.traces.exporter=otlp -Dotel.exporter.otlp.endpoint=10.74.8.33:55680"
To make the agent JAR available to your application running in a Kubernetes pod, extend your Docker image or add an init container that downloads the JAR and copies it to a volume that is shared with your application container in a single pod:
- name: attach-jar
- mountPath: /mnt/shared
- name: otel-jar
Where the dockerfile for the lm/provide-jar image may look like:
RUN yum install -y curl
RUN curl -L "https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v0.13.0/opentelemetry-javaagent-all.jar" > opentelemetry-javaagent-all.jar
RUN mkdir -p /mnt/shared
ENTRYPOINT ["cp", "-v", "opentelemetry-javaagent-all.jar", "/mnt/shared"]
You may need to manually instrument some or all of your Java applications if (1) you are using libraries that are not supported for the OpenTelemetry auto-instrumentation; or (2) you want to customize how operations are generated by auto-instrumentation (such as how operations are named).
The best source of instruction for manually instrumenting your Java application is the official OpenTelemetry documentation. This documentation will guide you through instantiating the OpenTelemetry SDK and a tracer, creating traces, and enriching them.
In This Article