Automatic
Instrumenting Java

Adding instrumentation to Services

Generally, the only deployment change that needs to occur is to add an annotation to the pods that a Deployment, DaemonSet, or StatefulSet creates.

Signals

Java auto-instrumentation will typically set up logs, metrics, and traces to be exported from a large set of Java libraries without any additional effort.

Auto-Instrumentation for Java

A single annotation is used to enable instrumentation of Java.

Note: It is important that the attribute is applied to the pod template, and not the Deployment, StatefulSet, or DaemonSet.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: your-java-app-name
  labels:
    ...
spec:
  selector:
    matchLabels:
      ...
  template:
    metadata:
      labels:
        ...
      annotations:
        instrumentation.opentelemetry.io/inject-java: opentelemetry-operator/auto-instrumentation
...

For more information, see the opentelemetery-java-autoinstrumentation (opens in a new tab) documentation.