Skip to content

Commit 49bf25f

Browse files
committed
add
分布式链路跟踪
1 parent fa24bb2 commit 49bf25f

File tree

18 files changed

+393
-0
lines changed

18 files changed

+393
-0
lines changed

spring-cloud-sleuth-zipkin/pom.xml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<groupId>com.neo</groupId>
7+
<artifactId>spring-cloud-parent</artifactId>
8+
<version>1.0.0.BUILD-SNAPSHOT</version>
9+
10+
<modules>
11+
<module>zipkin-server</module>
12+
<module>spring-cloud-eureka</module>
13+
<module>spring-cloud-producer</module>
14+
<module>spring-cloud-zuul</module>
15+
</modules>
16+
17+
<packaging>pom</packaging>
18+
<name>Spring cloud sleuth zipkin</name>
19+
<description>Demo project for Spring Cloud</description>
20+
21+
<parent>
22+
<groupId>org.springframework.boot</groupId>
23+
<artifactId>spring-boot-starter-parent</artifactId>
24+
<version>1.5.9.RELEASE</version>
25+
<relativePath/> <!-- lookup parent from repository -->
26+
</parent>
27+
28+
<properties>
29+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
30+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
31+
<java.version>1.8</java.version>
32+
<spring-cloud.version>Edgware.SR1</spring-cloud.version>
33+
</properties>
34+
35+
<dependencies>
36+
<dependency>
37+
<groupId>org.springframework.boot</groupId>
38+
<artifactId>spring-boot-starter-test</artifactId>
39+
<scope>test</scope>
40+
</dependency>
41+
</dependencies>
42+
43+
<dependencyManagement>
44+
<dependencies>
45+
<dependency>
46+
<groupId>org.springframework.cloud</groupId>
47+
<artifactId>spring-cloud-dependencies</artifactId>
48+
<version>${spring-cloud.version}</version>
49+
<type>pom</type>
50+
<scope>import</scope>
51+
</dependency>
52+
</dependencies>
53+
</dependencyManagement>
54+
55+
</project>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<parent>
5+
<groupId>com.neo</groupId>
6+
<artifactId>spring-cloud-parent</artifactId>
7+
<version>1.0.0.BUILD-SNAPSHOT</version>
8+
</parent>
9+
<modelVersion>4.0.0</modelVersion>
10+
11+
<artifactId>spring-cloud-eureka</artifactId>
12+
<packaging>jar</packaging>
13+
14+
<dependencies>
15+
<dependency>
16+
<groupId>org.springframework.cloud</groupId>
17+
<artifactId>spring-cloud-starter-eureka-server</artifactId>
18+
</dependency>
19+
<dependency>
20+
<groupId>org.springframework.boot</groupId>
21+
<artifactId>spring-boot-starter-test</artifactId>
22+
<scope>test</scope>
23+
</dependency>
24+
</dependencies>
25+
26+
<build>
27+
<plugins>
28+
<plugin>
29+
<groupId>org.springframework.boot</groupId>
30+
<artifactId>spring-boot-maven-plugin</artifactId>
31+
</plugin>
32+
</plugins>
33+
</build>
34+
35+
</project>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.neo;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
6+
7+
@SpringBootApplication
8+
@EnableEurekaServer
9+
public class EurekaApplication {
10+
11+
public static void main(String[] args) {
12+
SpringApplication.run(EurekaApplication.class, args);
13+
}
14+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
server:
2+
port: 8761
3+
spring:
4+
application:
5+
name: eureka
6+
eureka:
7+
client:
8+
serviceUrl:
9+
defaultZone: http://localhost:8761/eureka/
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.neo;
2+
3+
import org.junit.Test;
4+
import org.junit.runner.RunWith;
5+
import org.springframework.boot.test.context.SpringBootTest;
6+
import org.springframework.test.context.junit4.SpringRunner;
7+
8+
@RunWith(SpringRunner.class)
9+
@SpringBootTest
10+
public class EurekaApplicationTests {
11+
12+
@Test
13+
public void contextLoads() {
14+
}
15+
16+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<groupId>com.neo</groupId>
7+
<artifactId>spring-cloud-parent</artifactId>
8+
<version>1.0.0.BUILD-SNAPSHOT</version>
9+
</parent>
10+
11+
<artifactId>spring-cloud-producer</artifactId>
12+
<packaging>jar</packaging>
13+
14+
<dependencies>
15+
<dependency>
16+
<groupId>org.springframework.cloud</groupId>
17+
<artifactId>spring-cloud-starter-eureka</artifactId>
18+
</dependency>
19+
<dependency>
20+
<groupId>org.springframework.cloud</groupId>
21+
<artifactId>spring-cloud-starter-zipkin</artifactId>
22+
</dependency>
23+
</dependencies>
24+
25+
<build>
26+
<plugins>
27+
<plugin>
28+
<groupId>org.springframework.boot</groupId>
29+
<artifactId>spring-boot-maven-plugin</artifactId>
30+
</plugin>
31+
</plugins>
32+
</build>
33+
34+
</project>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.neo;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
6+
7+
@SpringBootApplication
8+
@EnableDiscoveryClient
9+
public class ProducerApplication {
10+
11+
public static void main(String[] args) {
12+
SpringApplication.run(ProducerApplication.class, args);
13+
}
14+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.neo.controller;
2+
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
5+
import org.springframework.cloud.netflix.zuul.filters.route.FallbackProvider;
6+
import org.springframework.web.bind.annotation.RequestMapping;
7+
import org.springframework.web.bind.annotation.RequestParam;
8+
import org.springframework.web.bind.annotation.RestController;
9+
10+
@RestController
11+
public class HelloController {
12+
private final Logger logger = LoggerFactory.getLogger(FallbackProvider.class);
13+
14+
@RequestMapping("/hello")
15+
public String index(@RequestParam String name) {
16+
logger.info("request name is "+name);
17+
return "hello "+name+",this is first messge";
18+
}
19+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
server:
2+
port: 9001
3+
spring:
4+
application:
5+
name: producer
6+
zipkin:
7+
base-url: http://localhost:9000
8+
sleuth:
9+
sampler:
10+
percentage: 1.0
11+
eureka:
12+
client:
13+
serviceUrl:
14+
defaultZone: http://localhost:8761/eureka/
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.neo;
2+
3+
import org.junit.Test;
4+
import org.junit.runner.RunWith;
5+
import org.springframework.boot.test.context.SpringBootTest;
6+
import org.springframework.test.context.junit4.SpringRunner;
7+
8+
@RunWith(SpringRunner.class)
9+
@SpringBootTest
10+
public class ProducerApplicationTests {
11+
12+
@Test
13+
public void contextLoads() {
14+
}
15+
16+
}

0 commit comments

Comments
 (0)