From 16a4c87eb264efc35af938d79190275766840ae7 Mon Sep 17 00:00:00 2001 From: qinyingjie Date: Mon, 16 Jan 2023 17:33:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=B7=BB=E5=8A=A0=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 1 + .../dev/application-goods9100.yaml | 5 ++ .../dev/application-goods9200.yaml | 8 ++- .../dev/application-goods9300.yaml | 5 ++ .../dev/application-portal8080.yaml | 7 ++- .../dev/application-portal8081.yaml | 5 ++ springcloud-service-zipkin/pom.xml | 59 +++++++++++++++++++ .../kwan/springcloud/ZipkinApplication.java | 25 ++++++++ .../src/main/resources/application.yaml | 12 ++++ .../springcloud/ZipkinApplicationTests.java | 13 ++++ 10 files changed, 137 insertions(+), 3 deletions(-) create mode 100644 springcloud-service-zipkin/pom.xml create mode 100644 springcloud-service-zipkin/src/main/java/com/kwan/springcloud/ZipkinApplication.java create mode 100644 springcloud-service-zipkin/src/main/resources/application.yaml create mode 100644 springcloud-service-zipkin/src/test/java/com/kwan/springcloud/ZipkinApplicationTests.java diff --git a/pom.xml b/pom.xml index 1b2ef01..78d27be 100644 --- a/pom.xml +++ b/pom.xml @@ -36,6 +36,7 @@ springcloud-service-config-info springcloud-service-feign springcloud-service-zuul + springcloud-service-zipkin springcloud-service-consul springcloud-service-hystrix-dashboard springcloud-service-hystrix-turbine diff --git a/springcloud-service-config-info/dev/application-goods9100.yaml b/springcloud-service-config-info/dev/application-goods9100.yaml index 3b36723..97a39bd 100644 --- a/springcloud-service-config-info/dev/application-goods9100.yaml +++ b/springcloud-service-config-info/dev/application-goods9100.yaml @@ -8,6 +8,11 @@ spring: password: 716288qwe application: name: goods-service #服务名称 + zipkin: + base-url: http://localhost:9411 #zipkin地址 默认值就是0.1,代表收集10%的请求追踪信息。 + sleuth: + sampler: + percentage: 0.1 #收集百分比 #服务提供者 eureka: diff --git a/springcloud-service-config-info/dev/application-goods9200.yaml b/springcloud-service-config-info/dev/application-goods9200.yaml index 881086a..bb7cf25 100644 --- a/springcloud-service-config-info/dev/application-goods9200.yaml +++ b/springcloud-service-config-info/dev/application-goods9200.yaml @@ -7,7 +7,13 @@ spring: username: root password: 716288qwe application: - name: goods-service #服务名称 + name: goods-service #服务名 + zipkin: + base-url: http://localhost:9411 #zipkin地址 默认值就是0.1,代表收集10%的请求追踪信息。 + sleuth: + sampler: + percentage: 0.1 #收集百分比 + #服务提供者 eureka: diff --git a/springcloud-service-config-info/dev/application-goods9300.yaml b/springcloud-service-config-info/dev/application-goods9300.yaml index 5e214f1..13e2bac 100644 --- a/springcloud-service-config-info/dev/application-goods9300.yaml +++ b/springcloud-service-config-info/dev/application-goods9300.yaml @@ -8,6 +8,11 @@ spring: password: 716288qwe application: name: goods-service #服务名称 + zipkin: + base-url: http://localhost:9411 #zipkin地址 默认值就是0.1,代表收集10%的请求追踪信息。 + sleuth: + sampler: + percentage: 0.1 #收集百分比 #服务提供者 eureka: diff --git a/springcloud-service-config-info/dev/application-portal8080.yaml b/springcloud-service-config-info/dev/application-portal8080.yaml index 0542506..4c9f685 100644 --- a/springcloud-service-config-info/dev/application-portal8080.yaml +++ b/springcloud-service-config-info/dev/application-portal8080.yaml @@ -1,8 +1,11 @@ spring: application: name: portal-service #服务名称 - -#服务提供者 + zipkin: + base-url: http://localhost:9411 #zipkin地址 默认值就是0.1,代表收集10%的请求追踪信息。 + sleuth: + sampler: + percentage: 0.1 #收集百分比 eureka: client: service-url: diff --git a/springcloud-service-config-info/dev/application-portal8081.yaml b/springcloud-service-config-info/dev/application-portal8081.yaml index d9ba0e4..0666a24 100644 --- a/springcloud-service-config-info/dev/application-portal8081.yaml +++ b/springcloud-service-config-info/dev/application-portal8081.yaml @@ -1,6 +1,11 @@ spring: application: name: portal-service #服务名称 + zipkin: + base-url: http://localhost:9411 #zipkin地址 默认值就是0.1,代表收集10%的请求追踪信息。 + sleuth: + sampler: + percentage: 0.1 #收集百分比 #服务提供者 eureka: diff --git a/springcloud-service-zipkin/pom.xml b/springcloud-service-zipkin/pom.xml new file mode 100644 index 0000000..47da53c --- /dev/null +++ b/springcloud-service-zipkin/pom.xml @@ -0,0 +1,59 @@ + + + 4.0.0 + + com.kwan.springcloud + springcloud-service-parent + 1.0.0 + + springcloud-service-zipkin + 0.0.1-SNAPSHOT + springcloud-service-zipkin + + 1.8 + + + + + + org.springframework.boot + spring-boot-starter-test + test + + + + io.zipkin.java + zipkin-server + 2.10.4 + + + org.springframework.boot + spring-boot-starter-log4j2 + + + + + io.zipkin.java + zipkin-autoconfigure-ui + 2.10.4 + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.cloud + spring-cloud-starter-netflix-eureka-client + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + \ No newline at end of file diff --git a/springcloud-service-zipkin/src/main/java/com/kwan/springcloud/ZipkinApplication.java b/springcloud-service-zipkin/src/main/java/com/kwan/springcloud/ZipkinApplication.java new file mode 100644 index 0000000..c0b6a4c --- /dev/null +++ b/springcloud-service-zipkin/src/main/java/com/kwan/springcloud/ZipkinApplication.java @@ -0,0 +1,25 @@ +package com.kwan.springcloud; + + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import zipkin2.server.internal.EnableZipkinServer; + + +/** + * http:/localhost:9411/zipkin + * + * @author : qinyingjie + * @version : 2.2.0 + * @date : 2023/1/16 10:02 + */ +@EnableZipkinServer +@SpringBootApplication +public class ZipkinApplication { + + public static void main(String[] args) { + + SpringApplication.run(ZipkinApplication.class, args); + } + +} diff --git a/springcloud-service-zipkin/src/main/resources/application.yaml b/springcloud-service-zipkin/src/main/resources/application.yaml new file mode 100644 index 0000000..65e3163 --- /dev/null +++ b/springcloud-service-zipkin/src/main/resources/application.yaml @@ -0,0 +1,12 @@ +#端口号 +server: + port: 9411 +#spring 相关配置 +spring: + application: + name: zipkin-service +#注册中心 +eureka: + client: + service-url: + defaultZone: http://eureka8767:8767/eureka/,http://eureka8768:8768/eureka/,http://eureka8769:8769/eureka/ diff --git a/springcloud-service-zipkin/src/test/java/com/kwan/springcloud/ZipkinApplicationTests.java b/springcloud-service-zipkin/src/test/java/com/kwan/springcloud/ZipkinApplicationTests.java new file mode 100644 index 0000000..12bef34 --- /dev/null +++ b/springcloud-service-zipkin/src/test/java/com/kwan/springcloud/ZipkinApplicationTests.java @@ -0,0 +1,13 @@ +package com.kwan.springcloud; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class ZipkinApplicationTests { + + @Test + void contextLoads() { + } + +} -- GitLab