瀏覽代碼

feat:使用Sleuth和Zipkin搭建微服务调用链路的监控系统

yang yi 1 年之前
父節點
當前提交
ba3e202349

文件差異過大導致無法顯示
+ 626 - 0
components/zipkin-server-2.12.9-exec.jar


+ 6 - 0
member-service-consumer/pom.xml

@@ -16,6 +16,12 @@
         <maven.compiler.target>17</maven.compiler.target>
         <maven.compiler.target>17</maven.compiler.target>
     </properties>
     </properties>
     <dependencies>
     <dependencies>
+        <!--引入zipkin依赖,其中已经包含了sleuth-->
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-zipkin</artifactId>
+            <version>2.2.8.RELEASE</version>
+        </dependency>
         <!--引入eureka-client依赖-->
         <!--引入eureka-client依赖-->
         <dependency>
         <dependency>
             <groupId>org.springframework.cloud</groupId>
             <groupId>org.springframework.cloud</groupId>

+ 5 - 0
member-service-consumer/src/main/resources/application.yaml

@@ -54,6 +54,11 @@ spring:
             - Method=POST
             - Method=POST
           filters:
           filters:
             - RewritePath=/member-gateway/(?<segment>.*), /member-provider/$\{segment}
             - RewritePath=/member-gateway/(?<segment>.*), /member-provider/$\{segment}
+  zipkin:
+    base-url: http://localhost:9411
+  sleuth:
+    sampler:
+      probability: 1.0
 eureka:
 eureka:
   instance:
   instance:
     #配置注册到Eureka Server中的名称
     #配置注册到Eureka Server中的名称

+ 6 - 0
member-service-provider_10000/pom.xml

@@ -16,6 +16,12 @@
         <maven.compiler.target>17</maven.compiler.target>
         <maven.compiler.target>17</maven.compiler.target>
     </properties>
     </properties>
     <dependencies>
     <dependencies>
+        <!--引入zipkin依赖,其中已经包含了sleuth-->
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-zipkin</artifactId>
+            <version>2.2.8.RELEASE</version>
+        </dependency>
         <!--引入eureka-client依赖-->
         <!--引入eureka-client依赖-->
         <dependency>
         <dependency>
             <groupId>org.springframework.cloud</groupId>
             <groupId>org.springframework.cloud</groupId>

+ 7 - 0
member-service-provider_10000/src/main/resources/application.yaml

@@ -12,6 +12,13 @@ spring:
       driver-class-name: com.mysql.jdbc.Driver
       driver-class-name: com.mysql.jdbc.Driver
   application:
   application:
     name: member-service-provider
     name: member-service-provider
+  zipkin:
+    #配置zipkin服务器的地址
+    base-url: http://localhost:9411
+  sleuth:
+    sampler:
+      #probability标识采样率,取值范围[0.0,1.0],1.0表示全部采集
+      probability: 1.0
 mybatis-plus:
 mybatis-plus:
   configuration:
   configuration:
     log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
     log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

+ 6 - 0
member-service-provider_10002/pom.xml

@@ -16,6 +16,12 @@
         <maven.compiler.target>17</maven.compiler.target>
         <maven.compiler.target>17</maven.compiler.target>
     </properties>
     </properties>
     <dependencies>
     <dependencies>
+        <!--引入zipkin依赖,其中已经包含了sleuth-->
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-zipkin</artifactId>
+            <version>2.2.8.RELEASE</version>
+        </dependency>
         <!--引入eureka-client依赖-->
         <!--引入eureka-client依赖-->
         <dependency>
         <dependency>
             <groupId>org.springframework.cloud</groupId>
             <groupId>org.springframework.cloud</groupId>

+ 7 - 0
member-service-provider_10002/src/main/resources/application.yaml

@@ -12,6 +12,13 @@ spring:
       driver-class-name: com.mysql.jdbc.Driver
       driver-class-name: com.mysql.jdbc.Driver
   application:
   application:
     name: member-service-provider
     name: member-service-provider
+  zipkin:
+    #配置zipkin服务器的地址
+    base-url: http://localhost:9411
+  sleuth:
+    sampler:
+      #probability标识采样率,取值范围[0.0,1.0],1.0表示全部采集
+      probability: 1.0
 mybatis-plus:
 mybatis-plus:
   configuration:
   configuration:
     log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
     log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

部分文件因文件數量過多而無法顯示