OpenTelemetry Support
...
Service Integration Guides
Kubernetes Auto-Instrumentatio...

Java Application

6min

This document explains how to instrument a Java Spring Boot application with KloudMate, using OpenTelemetry.

This instrumentation can be done using the OpenTelemetry operator, which supports injecting and configuring auto-instrumentation libraries for .NET, Java, Node.js, Python, and Go service.

Prerequisites:

  1. Running a Kubernetes cluster.
  2. The cert-manager must be installed. If you use the helm chart, there is an option to generate a self-signed cert instead.

Step 1: First, install the OpenTelemetry Operator into your cluster.

You can do this with the Operator release manifest, the Operator helm chart, or with Operator Hub.

Bash


Step 2: Create an OpenTelemetry collector to send telemetry from containers to a collector instead of directly to a backend.

For example, here is a demo collector:

YAML


Note: Change your Kloudmate organization API key to configure the collector to export data to KloudMate.

Step 3: Configure automatic instrumentation

To be able to manage automatic instrumentation, the Operator needs to be configured to know what pods to instrument and which automatic instrumentation to use for those pods. This is done via the Instrumentation CRD

For our example, we have used Java SDK auto instrumentation.

The following command creates a basic Instrumentation resource that is configured for instrumenting Java services:

YAML


Note: The endpoint used under exporter must be the same as the service name of the collector created in Step 2

Step 4: Now opt-in your services to automatic instrumentation. This is done by updating your service’s spec.template.metadata.annotations to include a language-specific annotation:

To patch your existing Java application with the necessary annotation use the below command:

BASH


Following the above steps, you can get the necessary telemetry data on KloudMate.

Following is a sample YAML file where the annotation is used:

YAML




JVM Metrics

Name

Description

Unit

jvm.memory.used

Measure of memory used.

Bytes

jvm.memory.committed

Measure of memory committed.

Bytes

jvm.memory.limit

Measure of max obtainable memory.

Bytes

jvm.memory.used_after_last_gc

Measure of memory used, as measured after the most recent garbage collection event on this pool.

Bytes

jvm.gc.duration

Duration of JVM garbage collection actions.

seconds

jvm.thread.count

Number of executing platform threads.

thread

jvm.class.loaded

Number of classes loaded since JVM start.

class

jvm.class.unloaded

Number of classes unloaded since JVM start.

class

jvm.class.count

Number of classes currently loaded.

class

jvm.cpu.time

CPU time used by the process as reported by the JVM.

seconds

jvm.cpu.count

Number of processors available to the Java virtual machine.

cpu

jvm.cpu.recent_utilization

Recent CPU utilization for the process as reported by the JVM.

one

jvm.memory.init

Measure of initial memory requested.

Bytes

jvm.system.cpu.utilization

Recent CPU utilization for the whole system as reported by the JVM.

one

jvm.system.cpu.load_1m

Average CPU load of the whole system for the last minute as reported by the JVM.

run_queue_item

jvm.buffer.memory.used

Measure of memory used by buffers.

Bytes

jvm.buffer.memory.limit

Measure of total memory capacity of buffers.

Bytes

jvm.buffer.count

Number of buffers in the pool.

buffer