Showing results for 
Show  only  | Search instead for 
Did you mean: 
AppDynamics Team

The integration of OpenTelemetry Java agents into your application’s Docker containers represents a significant leap towards enhanced observability and monitoring capabilities. This guide details how to embed the OpenTelemetry Java Agent into your Dockerfile for a Java application, deploy it on Kubernetes, and monitor its traces using Cisco AppDynamics, thereby providing a robust solution for real-time application performance monitoring.


Ensure you have the following set up and ready:

  • A Kubernetes cluster
  • Docker and Kubernetes command-line tools, docker and kubectl, installed and configured
  • Access to an AppDynamics account for monitoring

1. Preparing Your Dockerfile for Observability

The Dockerfile outlined integrates the OpenTelemetry Java agent into a Tomcat server to enable automated instrumentation of your Java application.

FROM tomcat:latest
RUN apt-get update -y && apt-get -y install wget
RUN apt-get install -y curl
ADD sample.war /usr/local/tomcat/webapps/
ADD /tmp
ENV JAVA_OPTS="-javaagent:/tmp/opentelemetry-javaagent.jar -Dappdynamics.opentelemetry.enabled=true -Dotel.resource.attributes=",service.namespace=tomcatOtelJavaK8s""
ENV OTEL_EXPORTER_OTLP_ENDPOINT=http://appdynamics-collectors-ds-appdynamics-otel-collector.cco.svc.cluster.local:4318
CMD ["","run"]
  • Base Image: Start with tomcat:latest as the base image for deploying a Java web application.
  • Installing Utilities: Update the package list and install necessary utilities like wget and curl for downloading the OpenTelemetry Java agent.
  • Adding Your Application: Use the ADD command to place your .war file in the webapps directory of Tomcat.
  • Integrating OpenTelemetry: Download the latest OpenTelemetry Java agent using ADD command and set JAVA_OPTS to include the path to the downloaded agent, enabling specific OpenTelemetry configurations.
  • Environment Variables: Define OTEL_EXPORTER_OTLP_ENDPOINT to specify the endpoint of the AppDynamics OTel Collector or your custom otel collector, which will process and forward your telemetry data to AppDynamics.

2. Deploying Your Application on Kubernetes

Your deployment YAML file configures Kubernetes to deploy your containerized application, exposing it through a service for external access.

apiVersion: apps/v1
kind: Deployment
name: java-app-with-otel-agent
app: java-app-with-otel-agent
namespace: appd-cloud-apps
replicas: 1
app: java-app-with-otel-agent
app: java-app-with-otel-agent
- name: java-app-with-otel-agent
imagePullPolicy: Always
- containerPort: 8080
apiVersion: v1
kind: Service
name: java-app-with-otel-agent
app: java-app-with-otel-agent
namespace: appd-cloud-apps
- port: 8080
targetPort: 8080
app: java-app-with-otel-agent
  • Deployment Configuration: Define a deployment in Kubernetes to manage your application’s replicas, ensuring it’s set to match your application’s requirements.
  • Service Exposure: Create a Kubernetes service to expose your application on a specified port, allowing traffic to reach your application.

3. Setting Up the AppDynamics Otel Collector

To monitor your application’s traces in Cisco AppDynamics, deploy the AppDynamics Otel Collector within your Kubernetes cluster. This collector processes traces from your application and sends them to AppDynamics.

4. Monitoring Traces in AppDynamics

To produce a load for our Sample App, Exec inside the pod and run

curl -v http://localhost:8080/sample/

With your application deployed and the Otel Collector set up, you can now monitor your application’s performance in AppDynamics.

  • Accessing AppDynamics: Log into your AppDynamics dashboard.
  • Viewing Traces: Navigate to the tracing or application monitoring section to view the traces sent from your Kubernetes-deployed application, allowing you to monitor requests, response times, and error rates.

Screenshot 2024-04-10 at 9.18.50 PM.png


Integrating the OpenTelemetry Java agent into your Java application’s Dockerfile and deploying it on Kubernetes offers a seamless path to observability. By leveraging Cisco AppDynamics in conjunction with this setup, you gain powerful insights into your application’s performance, helping you diagnose and resolve issues more efficiently. This guide serves as a starting point for developers looking to enhance their application’s observability in a Kubernetes environment.

Version history
Last update:
‎04-10-2024 04:08 PM
Updated by: