Not a customer? Click the 'Start a free trial' link to begin a 30-day SaaS trial of our product and to join our community.
Existing Cisco AppDynamics customers should click the 'Sign In' button to authenticate to access the community
on 04-10-2024 04:08 PM
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:
docker
and kubectl
, installed and configuredThe 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 https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar /tmp
ENV JAVA_OPTS="-javaagent:/tmp/opentelemetry-javaagent.jar -Dappdynamics.opentelemetry.enabled=true -Dotel.resource.attributes="service.name=tomcatOtelJavaK8s,service.namespace=tomcatOtelJavaK8s""
ENV OTEL_EXPORTER_OTLP_ENDPOINT=http://appdynamics-collectors-ds-appdynamics-otel-collector.cco.svc.cluster.local:4318
CMD ["catalina.sh","run"]
tomcat:latest
as the base image for deploying a Java web application.wget
and curl
for downloading the OpenTelemetry Java agent.ADD
command to place your .war
file in the webapps
directory of Tomcat.ADD
command and set JAVA_OPTS
to include the path to the downloaded agent, enabling specific OpenTelemetry configurations.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.Your deployment YAML file configures Kubernetes to deploy your containerized application, exposing it through a service for external access.
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: java-app-with-otel-agent
labels:
app: java-app-with-otel-agent
namespace: appd-cloud-apps
spec:
replicas: 1
selector:
matchLabels:
app: java-app-with-otel-agent
template:
metadata:
labels:
app: java-app-with-otel-agent
spec:
containers:
- name: java-app-with-otel-agent
image: docker.io/abhimanyubajaj98/java-app-with-otel-agent
imagePullPolicy: Always
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: java-app-with-otel-agent
labels:
app: java-app-with-otel-agent
namespace: appd-cloud-apps
spec:
ports:
- port: 8080
targetPort: 8080
selector:
app: java-app-with-otel-agent
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.
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.
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.
Thank you! Your submission has been received!
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form