live-demo 与 skywalkingThe source alignment

Build the project

Find a directory and run the following command

Git clone https://github.com/apache/skywalking.git # clone skywalking project CD skywalking # into skywalking directory git checkout Git checkout -b new_v8.4.0 -b new_v8.4.0 -b new_v8.4.0 / MVNW clean package-dskiptests # Run maven to build skyWalking project cd .. # # into the superior directory git clone https://github.com/SkyAPMTest/skywalking-live-demo clone live - demo CD skywalking case project MVN clean Package # Build the demo project CD.. # Go to the parent directoryCopy the code

After the build is successful, the installation package is generated in the following two directories

.├ ── ├─ dist │ ├── ├─ exercises │ ├─ ├─ dist │ ├── ├─ ├─ exercises │ ├─ ├─ exercises Apache-skywalk-apm-bin.tar.gz ├ ── Skywalk-live -demo ├ ── live-demo-assembly.tar.gz # Demo projectCopy the code

skywalkingPartial module construction

#When you package the Agent module, the Skywalk-agent directory appears
./mvnw package -Pagent -DskipTests
#Package the Agent module and then package it into the dist directory
./mvnw package -Pagent,dist -DskipTests
#Package the Backend module and then package it into the dist directory
./mvnw package -Pbackend,dist -DskipTests
#Package the UI module and then package it into the dist directory
./mvnw package -Pui,dist -DskipTests
Copy the code

willskywalkingImport as a moduleskywalking-live-demoproject

  1. inIDEAIn the openskywalking-live-demoproject
  2. In the openskywalking-live-demoUsed in projectsModule from Existing SourcesImport by usingSkywalking 

  1. After the import is successful, the following two modules are displayed

PS: When importing a SkyWalking project, it is possible that skyWalking submodules may be ignored. You can use the following methods to cancel the neglect

Start theOAPservice

Perform org. Apache. Skywalking. Oap. Server starter. OAPServerStartUp# main method, start the oap service

generateskywalking-agent

CD skywalking # Go to the Skywalking directory./ MVNW package-agent-dSkiptests # package the agent module. The Skywalking -agent directory appearsCopy the code

The generated Skywalk-agent directory structure is as follows:

└─ ├─ exercises ├── Exercises ├── Exercises ├── Exercises ├── Exercises ├── Exercises ├── Exercises ├── Exercises ├─ Exercises ├── Exercises ├─ Exercises ├─ Exercises ├─ Exercises ├─ Exercises ├─ Exercises Optional - Reporter - Exercises ├── Plugins ├─ Key.htmCopy the code

Configuration itemsJVMLaunch parameters

ProjectA, ProjectB, ProjectC, and ProjectD all need to be configured, taking ProjectA as an example

-javaagent:{to be replaced with the project directory}/skywalking/ skywalk-agent/skywalk-agent.jar -Dskywalking.collector.grpc_channel_check_interval=2 -Dskywalking.collector.app_and_service_register_check_interval=2 -Dcollector.discovery_check_interval=2 -Dskywalking.collector.backend_service=localhost:11800 -Dskywalking.agent.service_name=business-zone::projectA -Dskywalking.logging.level=info -Dskywalking.plugin.toolkit.log.grpc.reporter.server_host=localhost -Dskywalking.plugin.toolkit.log.grpc.reporter.server_port=11800 -Dskywalking.plugin.toolkit.log.grpc.reporter.max_message_size=10485760 -Dskywalking.plugin.toolkit.log.grpc.reporter.upstream_timeout=30Copy the code

validation

validationagentWhether the breakpoint takes effect

In org. Apache. Skywalking. Apm. Agent. SkyWalkingAgent# premain method in any statement on the breakpoint, start ProjectA

inUIThe validationtraceWhether to generate

  1. Start theKafka 、 Eureka 、 ProjectB 、 ProjectC 、 ProjectD 、 ProjectA 
  2. On the command linecurl "http://localhost:8764/projectA/test" 
$ curl "http://localhost:8764/projectA/test"{" traceId ":" 20 b7bb868a384b7bac5130efb5f76f17. 82.16244120942450001 "} %Copy the code
  1. Use what you got in the previous steptraceIdIn theUI, the following results can be obtained

PS: Note that ProjectA, ProjectB, ProjectC, ProjectD, Eureka can all be started from the IDEA source code, but Kafka needs to be started from a command, see the live-demo/bin/startup.sh script

conclusion

Debugging source code is the most basic operation, whether it is researching the source code execution process or writing some plug-ins and extending some functions. Skywalking is different in that the client block is not directly executable and needs to be attached to another application.

Reference documentation

  1. skywalking-live-demo

Share and record what you learn and see