The OpenTelemetry (OTel) agent for Java based Spring Boot application enables JMX profiling, tracing, eventing on any Java 8+ application, and dynamically injects bytecode to capture telemetry from a number of popular libraries and frameworks. This provides the ability to gather telemetry data from a Java application without code changes. The OpenTelemetry Java agent uses OTLP
exporter configured to send data to OpenTelemetry collector
For this demonstration, we’ve enabled the Spring Micrometer traces for a sample Spring Boot application through the OpenTelemetry Java agent that is available with the latest Java buildpack v4.66.0
.
Before using the buildpack to fetch the metrics, we must enable OpenTelemetry Collector agent on TAS under the Wavefront Nozzle tile settings.
In this section, we’ll configure OTel on Tanzu Observability (TO) by configuraing few parameters in TAS for the Wavefront tile.
Config
section under Wavefront Proxy Config > Custom Proxy Configuration > Custom. otlpGrpcListenerPorts=4317
otlpHttpListenerPorts=4318
otlpResourceAttrsOnMetricsIncluded=true
Add a pre-processing rule under the Preprocessor Rules
section under Wavefront Proxy Config > Custom Proxy Configuration > Custom.
'4317':
- rule : drop_process_command
action : dropTag
tag : process.command_args
In the next step, we’ll create a Spring Boot application with the java-buildpack (v4.66.0) that has the open-telemetry JAVA agent.
NoteWe’ve used TAS 5.0.4 for this demonstration purpsoe.
The spring-music app is cloned from https://github.com/cloudfoundry-samples/spring-music in the jumpbox.
Clone the spring-music app from Github to jumpbox.
Go to the spring-music directory and run the following command:
$ cf push spring-music -f manifest.yml -b https://github.com/cloudfoundry/java-buildpack.git
$ cf app spring-music
Showing health and status for app spring-music in org otel-test / space otel-space as admin...
name: spring-music
requested state: started
routes: spring-music-agile-baboon-rr.apps.h2o-2-22348.h2o.vmware.com
last uploaded: Fri 02 Feb 12:23:31 IST 2024
stack: cflinuxfs4
buildpacks:
name version detect output buildpack name
https://github.com/cloudfoundry/java-buildpack.git 9e8f9be-https://github.com/cloudfoundry/java-buildpack.git#9e8f9be java java
type: web
sidecars:
instances: 1/1
memory usage: 1024M
state since cpu memory disk logging details
#0 running 2024-02-06T09:31:09Z 0.6% 422.9M of 1G 320.3M of 1G 0/s of 16K/s
type: task
sidecars:
instances: 0/0
memory usage: 1024M
There are no running instances of this process.
$ cf cups spring-music-otel-collector -p '{"otel.exporter.otlp.endpoint":"http://wavefront-proxy.service.internal:4317","otel.exporter.otlp.metrics.temporality.preference":"delta","otel.resource.attributes":"application=spring-music,cluster=otel-test,shard=ap1","otel.traces.exporter":"otlp","otlp.metrics.exporter":"otlp","otel.exporter.otlp.protocol":"grpc","otel.service.name":"spring-music-svc","otel.jmx.target.system":"jetty,kafka-broker,tomcat","otel.javaagent.debug":"true"}'
Bind the service to the spring-music app and restage the app.
$ cf bind-service spring-music spring-music-otel-collector && cf restage spring-music
$ cf service spring-music-otel-collector
Showing info of service spring-music-otel-collector in org otel-test / space otel-space as admin...
name: spring-music-otel-collector
guid: c6e74b4b-7680-4915-b56d-87268988aafd
type: user-provided
tags:
route service url:
syslog drain url:
Showing status of last operation:
status: create succeeded
message: Operation succeeded
started: 2024-02-02T06:52:23Z
updated: 2024-02-02T06:52:23Z
Showing bound apps:
name binding name status message
spring-music create succeeded
For Spring micrometer traces for the application, the data is populated in the Spring Boot dashboard under the Tanzu Observability portal.
JVM Utilization:
Garbage collection and Buffer pools:
JDBC connections:
The telemetry data further enriches to provide tracing information, services call, operational tasks, and latency between the classes and system calls: