opentelemetry

Instrumenting Java applications with EDOT SDKs on Kubernetes

This document focuses on instrumenting Java applications on Kubernetes, using the OpenTelemetry Operator, Elastic Distribution of OpenTelemetry (EDOT) Collectors, and the EDOT Java SDK.

Java agent extensions consideration

The operator supports a configuration that installs Java agent extensions in Instrumentation objects. The extension needs to be available in an image. Refer to using extensions with the OpenTelemetry Java agent for an example of adding an extension to an agent.

Instrument a Java app with EDOT Java SDK on Kubernetes

In this example, you’ll learn how to:

For this example, we assume the application you’re instrumenting is a deployment named java-app running in the java-ns namespace.

  1. Ensure you have successfully installed the OpenTelemetry Operator, and confirm that the following Instrumentation object exists in the system:
$ kubectl get instrumentation -n opentelemetry-operator-system
NAME                      AGE    ENDPOINT
elastic-instrumentation   107s   http://opentelemetry-kube-stack-daemon-collector.opentelemetry-operator-system.svc.cluster.local:4318

[!NOTE] If your Instrumentation object has a different name or is created in a different namespace, you will have to adapt the annotation value in the next step.

  1. Enable auto-instrumentation of your Java application using one of the following methods:
  1. Restart application

Once the annotation has been set, restart the application to create new Pods and inject the instrumentation libraries:

```bash
kubectl rollout restart deployment java-app -n java-ns
```
  1. Verify the auto-instrumentation resources are injected in the Pod:

Run a kubectl describe of one of your application Pods and check:

Ensure the environment variable OTEL_EXPORTER_OTLP_ENDPOINT points to a valid endpoint and there’s network communication between the Pod and the endpoint.

  1. Confirm data is flowing to Kibana:

Note that the container logs are not provided by the instrumentation library, but by the DaemonSet collector deployed as part of the operator installation.

Troubleshooting