Rpc 调用监控
Skywalking(6.5.0) 支持的Rpc框架有以下几种:
Dubbo 2.5.4 -> 2.6.0
Dubbox 2.8.4
Apache Dubbo 2.7.0
Motan 0.2.x -> 1.1.0
gRPC 1.x
Apache ServiceComb Java Chassis 0.1 -> 0.5,1.0.x
SOFARPC 5.4.0
使用Spring Boot和Dubbo搭建一个简单的服务提供方和服务消费方来测试Skywalking对于Rpc调用的支持。可以使用资源文件夹下已经完成打包的 skywalking_dubbo_consumer.jar 和skywalking_dubbo_provider.jar 来进行测试。
服务提供方
pom文件:
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
org.springframework.boot
spring-boot-starter-parent
2.1.10.RELEASE
com.itcast
skywalking_dubbo_provider
0.0.1-SNAPSHOT
skywalking_dubbo_provider
Demo project for Spring Boot
1.8
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-test
test
com.alibaba.spring.boot
dubbo-spring-boot-starter
2.0.0
org.springframework.boot
spring-boot-maven-plugin
application.properties:
spring.application.name=skywalking_dubbo_provider
spring.dubbo.server=true
spring.dubbo.registry=N/A
server.port=8086
IHelloService接口:
public interface IHelloService {
public String hello();
}
HelloServiceImpl实现类:
@Service(interfaceClass = IHelloService.class)
@Component
public class HelloServiceImpl implements IHelloService {
@Override
public String hello() {
return "hello skywalking";
}
}
SkywalkingDubboProviderApplication启动类:
@SpringBootApplication
//添加dubbo生效注解
@EnableDubboConfiguration
public class SkywalkingDubboProviderApplication {
public static void main(String[] args) {
SpringApplication.run(SkywalkingDubboProviderApplication.class, args);
}
}
服务消费方
pom文件:
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
org.springframework.boot
spring-boot-starter-parent
2.1.10.RELEASE
com.itcast
skywalking_dubbo_consumer
0.0.1-SNAPSHOT
skywalking_dubbo_consumer
Demo project for Spring Boot
1.8
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-test
test
com.alibaba.spring.boot
dubbo-spring-boot-starter
2.0.0
org.springframework.boot
spring-boot-maven-plugin
application.properties:
spring.application.name=skywalking_dubbo_consumer
server.port=8085
IHelloService接口:
public interface IHelloService {
public String hello();
}
TestController:
@RestController
public class TestController {
@Reference(url = "dubbo://127.0.0.1:20880")
private IHelloService helloService;
@GetMapping("/hello")
public String hello(){
return helloService.hello();
}
}
SkywalkingDubboConsumerApplication启动类:
@SpringBootApplication
//添加dubbo生效注解
@EnableDubboConfiguration
public class SkywalkingDubboConsumerApplication {
public static void main(String[] args) {
SpringApplication.run(SkywalkingDubboConsumerApplication.class, args);
}
}
部署方式
1、将 skywalking_dubbo_consumer.jar 和 skywalking_dubbo_provider.jar 上传
至 /usr/local/skywalking 目录下。
2、首先我们复制两份agent,防止使用的冲突。