Spring Boot Project with External Tomcat Scenario for Observable Tracing¶
Introduction¶
Different enterprises use varying technology stacks when building their enterprise-level frameworks within the Java ecosystem. For instance, some companies use Spring Boot + Spring Cloud, while others use Spring Boot + Dubbo for microservice frameworks.
Guance supports various APM tools to integrate microservice tracing into Guance, allowing you to choose the appropriate APM tool based on your needs.
Typically, microservices are run as Jar files, but this article focuses on how to build these microservices into WAR packages and deploy them under Tomcat, and then integrate the tracing data into Guance. If it is a traditional WAR package project, the integration method is the same.
SkyWalking Scenario¶
Prerequisites¶
- Cloud host (CentOS 7.9)
- Install JDK
- Install Zookeeper
- Guance account
- Two Tomcat deployments with paths
/usr/local/df-demo/tomcat8080
and/usr/local/df-demo/tomcat8081
- The cloud host has <DataKit installed>
Steps¶
Warning
This case uses DataKit version 1.4.9
, Spring Cloud 3.1.1
, Spring Boot 2.6.6
, Dubbo 2.7.15
, Zookeeper 3.7.1
, JDK 1.8
, and Tomcat 9.0.48
for testing
1 DataKit Configuration¶
1.1 Modify http_api (Optional)¶
Edit the /usr/local/datakit/conf.d/datakit.conf
file, change the listen value of http_api
to 0.0.0.0:9529
to ensure that other hosts can access the 9529
port on this host.
If you do not want other hosts to access DataKit, you can skip this step.
1.2 Enable SkyWalking Collector¶
Log in to the host, copy the sample file, and enable the skywalking collector.
Restart DataKit.
2 APM Integration¶
2.1 Download SkyWalking¶
Download apache-skywalking-java-agent-8.11.0, extract the file and name it agent
, upload it to the directories /usr/local/df-demo/tomcat8080
and /usr/local/df-demo/tomcat8081
on the host.
2.2 Configure Tomcat¶
Modify the /usr/local/df-demo/tomcat8080/bin/catalina.sh
file and add the following content:
export CATALINA_OPTS="$CATALINA_OPTS -javaagent:/usr/local/df-demo/tomcat8080/agent/skywalking-agent.jar -Dskywalking.agent.service_name=tomcat-customer -Dskywalking.collector.backend_service=localhost:11800"
Parameter explanation:
-Dskywalking.agent.service_name
: Service name-Dskywalking.collector.backend_service
: DataKit address for trace reporting + SkyWalking collector port
Modify the /usr/local/df-demo/tomcat8081/bin/catalina.sh
file and add the following content:
export CATALINA_OPTS="$CATALINA_OPTS -javaagent:/usr/local/df-demo/tomcat8081/agent/skywalking-agent.jar -Dskywalking.agent.service_name=tomcat-provider -Dskywalking.collector.backend_service=localhost:11800"
Start Tomcat.
2.3 Deploy the Project¶
Download the WAR package, obtain consumer.war
and provider.war
from the skywalking directory.
- Place
provider.war
in the/usr/local/df-demo/tomcat8081/webapps
directory. - Place
consumer.war
in the/usr/local/df-demo/tomcat8080/webapps
directory.
3 Observable Tracing¶
Access http://192.168.0.100:8080/consumer/ping
in the browser; here, the IP is the host's address.
Log in to 「Guance」-「Application Performance Monitoring」, and you will see the tomcat-customer
and tomcat-provider
services.
Click on a trace to view the flame graph, span list, and call relationships.