Skip to content

Commit f6bde23

Browse files
thuannguyenquangthuannguyenit
authored andcommitted
Adding Zipkin server
1 parent 7187a67 commit f6bde23

File tree

13 files changed

+101
-27
lines changed

13 files changed

+101
-27
lines changed

micro-services/currency-conversion-service/pom.xml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,17 @@
2626
</properties>
2727

2828
<dependencies>
29+
<!--
2930
<dependency>
3031
<groupId>org.springframework.boot</groupId>
3132
<artifactId>spring-boot-starter-actuator</artifactId>
3233
</dependency>
34+
<dependency>
35+
<groupId>org.springframework.boot</groupId>
36+
<artifactId>spring-boot-devtools</artifactId>
37+
<scope>runtime</scope>
38+
</dependency>
39+
-->
3340
<dependency>
3441
<groupId>org.springframework.cloud</groupId>
3542
<artifactId>spring-cloud-starter-config</artifactId>
@@ -46,22 +53,31 @@
4653
<artifactId>spring-cloud-starter-eureka</artifactId>
4754
<version>2.0.0.M2</version>
4855
</dependency>
56+
57+
<dependency>
58+
<groupId>org.springframework.cloud</groupId>
59+
<artifactId>spring-cloud-starter-sleuth</artifactId>
60+
</dependency>
4961

5062
<dependency>
5163
<groupId>org.springframework.cloud</groupId>
5264
<artifactId>spring-cloud-starter-ribbon</artifactId>
5365
<version>2.0.0.M2</version>
5466
</dependency>
55-
67+
5668
<dependency>
57-
<groupId>org.springframework.boot</groupId>
58-
<artifactId>spring-boot-starter-web</artifactId>
69+
<groupId>org.springframework.cloud</groupId>
70+
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
71+
</dependency>
72+
73+
<dependency>
74+
<groupId>org.springframework.cloud</groupId>
75+
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
5976
</dependency>
6077

6178
<dependency>
6279
<groupId>org.springframework.boot</groupId>
63-
<artifactId>spring-boot-devtools</artifactId>
64-
<scope>runtime</scope>
80+
<artifactId>spring-boot-starter-web</artifactId>
6581
</dependency>
6682
<dependency>
6783
<groupId>org.springframework.boot</groupId>

micro-services/currency-conversion-service/src/main/java/com/codekooking/microservices/currencyconversionservice/CurrencyConversionController.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import java.util.HashMap;
55
import java.util.Map;
66

7+
import org.slf4j.Logger;
8+
import org.slf4j.LoggerFactory;
79
import org.springframework.beans.factory.annotation.Autowired;
810
import org.springframework.http.ResponseEntity;
911
import org.springframework.web.bind.annotation.GetMapping;
@@ -14,6 +16,8 @@
1416
@RestController
1517
public class CurrencyConversionController {
1618

19+
private Logger logger = LoggerFactory.getLogger(this.getClass());
20+
1721
@Autowired
1822
private CurrencyConversionProxy proxy;
1923

@@ -50,6 +54,8 @@ public CurrencyConversionBean convertCurrencyFeign(@PathVariable String from,
5054

5155
CurrencyConversionBean response = proxy.retrieveExchangeValue(from, to);
5256

57+
logger.info("{}", response);
58+
5359
return new CurrencyConversionBean(response.getId(),
5460
from,
5561
to,

micro-services/currency-conversion-service/src/main/java/com/codekooking/microservices/currencyconversionservice/CurrencyConversionServiceApplication.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
66
import org.springframework.cloud.openfeign.EnableFeignClients;
77

8+
import brave.sampler.Sampler;
9+
810
@SpringBootApplication
911
@EnableFeignClients("com.codekooking.microservices.currencyconversionservice")
1012
@EnableDiscoveryClient
@@ -13,4 +15,8 @@ public class CurrencyConversionServiceApplication {
1315
public static void main(String[] args) {
1416
SpringApplication.run(CurrencyConversionServiceApplication.class, args);
1517
}
18+
19+
public Sampler defaultSampler() {
20+
return Sampler.ALWAYS_SAMPLE;
21+
}
1622
}

micro-services/currency-exchange-service/pom.xml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,17 @@
2626
</properties>
2727

2828
<dependencies>
29+
<!--
2930
<dependency>
3031
<groupId>org.springframework.boot</groupId>
3132
<artifactId>spring-boot-starter-actuator</artifactId>
3233
</dependency>
34+
<dependency>
35+
<groupId>org.springframework.boot</groupId>
36+
<artifactId>spring-boot-devtools</artifactId>
37+
<scope>runtime</scope>
38+
</dependency>
39+
-->
3340
<dependency>
3441
<groupId>org.springframework.boot</groupId>
3542
<artifactId>spring-boot-starter-web</artifactId>
@@ -52,12 +59,22 @@
5259
<artifactId>spring-cloud-starter-eureka</artifactId>
5360
<version>2.0.0.M2</version>
5461
</dependency>
55-
62+
5663
<dependency>
57-
<groupId>org.springframework.boot</groupId>
58-
<artifactId>spring-boot-devtools</artifactId>
59-
<scope>runtime</scope>
64+
<groupId>org.springframework.cloud</groupId>
65+
<artifactId>spring-cloud-starter-sleuth</artifactId>
66+
</dependency>
67+
68+
<dependency>
69+
<groupId>org.springframework.cloud</groupId>
70+
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
6071
</dependency>
72+
73+
<dependency>
74+
<groupId>org.springframework.cloud</groupId>
75+
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
76+
</dependency>
77+
6178
<dependency>
6279
<groupId>org.springframework.boot</groupId>
6380
<artifactId>spring-boot-starter-test</artifactId>

micro-services/currency-exchange-service/src/main/java/com/codekooking/microservices/currencyexchangeservice/CurrencyExchangeController.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.codekooking.microservices.currencyexchangeservice;
22

3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
35
import org.springframework.beans.factory.annotation.Autowired;
46
import org.springframework.core.env.Environment;
57
import org.springframework.web.bind.annotation.GetMapping;
@@ -11,6 +13,8 @@
1113

1214
@RestController
1315
public class CurrencyExchangeController {
16+
17+
private Logger logger = LoggerFactory.getLogger(this.getClass());
1418

1519
@Autowired
1620
private Environment environment;
@@ -24,6 +28,8 @@ public ExchangeValue retrieveExchangeValue(@PathVariable String from, @PathVaria
2428
ExchangeValue exchangeValue = repository.findByFromAndTo(from, to);
2529

2630
exchangeValue.setPort(Integer.parseInt(environment.getProperty("local.server.port")));
31+
32+
logger.info("{}", exchangeValue);
2733

2834
return exchangeValue;
2935

micro-services/currency-exchange-service/src/main/java/com/codekooking/microservices/currencyexchangeservice/CurrencyExchangeServiceApplication.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
55
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
66

7+
import brave.sampler.Sampler;
8+
79
@SpringBootApplication
810
@EnableEurekaClient
911
public class CurrencyExchangeServiceApplication {
1012

11-
public static void main(String[] args) {
12-
SpringApplication.run(CurrencyExchangeServiceApplication.class, args);
13-
}
13+
public static void main(String[] args) {
14+
SpringApplication.run(CurrencyExchangeServiceApplication.class, args);
15+
}
16+
17+
public Sampler defaultSampler() {
18+
return Sampler.ALWAYS_SAMPLE;
19+
}
1420
}

micro-services/limits-service/pom.xml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,17 @@
2626
</properties>
2727

2828
<dependencies>
29+
<!--
2930
<dependency>
3031
<groupId>org.springframework.boot</groupId>
3132
<artifactId>spring-boot-starter-actuator</artifactId>
3233
</dependency>
34+
<dependency>
35+
<groupId>org.springframework.boot</groupId>
36+
<artifactId>spring-boot-devtools</artifactId>
37+
<scope>runtime</scope>
38+
</dependency>
39+
-->
3340
<dependency>
3441
<groupId>org.springframework.boot</groupId>
3542
<artifactId>spring-boot-starter-web</artifactId>
@@ -38,12 +45,6 @@
3845
<groupId>org.springframework.cloud</groupId>
3946
<artifactId>spring-cloud-starter-config</artifactId>
4047
</dependency>
41-
42-
<dependency>
43-
<groupId>org.springframework.boot</groupId>
44-
<artifactId>spring-boot-devtools</artifactId>
45-
<scope>runtime</scope>
46-
</dependency>
4748
<dependency>
4849
<groupId>org.springframework.boot</groupId>
4950
<artifactId>spring-boot-starter-test</artifactId>

micro-services/netflix-eureka-naming-server/pom.xml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,17 @@
2626
</properties>
2727

2828
<dependencies>
29+
<!--
2930
<dependency>
3031
<groupId>org.springframework.boot</groupId>
3132
<artifactId>spring-boot-starter-actuator</artifactId>
3233
</dependency>
34+
<dependency>
35+
<groupId>org.springframework.boot</groupId>
36+
<artifactId>spring-boot-devtools</artifactId>
37+
<scope>runtime</scope>
38+
</dependency>
39+
-->
3340
<dependency>
3441
<groupId>org.springframework.cloud</groupId>
3542
<artifactId>spring-cloud-starter-config</artifactId>
@@ -38,12 +45,6 @@
3845
<groupId>org.springframework.cloud</groupId>
3946
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
4047
</dependency>
41-
42-
<dependency>
43-
<groupId>org.springframework.boot</groupId>
44-
<artifactId>spring-boot-devtools</artifactId>
45-
<scope>runtime</scope>
46-
</dependency>
4748
<dependency>
4849
<groupId>org.springframework.boot</groupId>
4950
<artifactId>spring-boot-starter-test</artifactId>

micro-services/netflix-zuul-api-gateway-server/pom.xml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,20 @@
4343
<groupId>org.springframework.cloud</groupId>
4444
<artifactId>spring-cloud-starter-sleuth</artifactId>
4545
</dependency>
46-
46+
47+
<!--
4748
<dependency>
4849
<groupId>org.springframework.cloud</groupId>
4950
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
5051
</dependency>
51-
52+
-->
53+
54+
<dependency>
55+
<groupId>org.springframework.cloud</groupId>
56+
<artifactId>spring-cloud-starter-zipkin</artifactId>
57+
</dependency>
58+
59+
5260
<dependency>
5361
<groupId>org.springframework.cloud</groupId>
5462
<artifactId>spring-cloud-starter-bus-amqp</artifactId>

micro-services/netflix-zuul-api-gateway-server/src/main/java/com/codekooking/microservices/netflixzuulapigatewayserver/NetflixZuulApiGatewayServerApplication.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
66
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
77

8+
import brave.sampler.Sampler;
9+
810
@SpringBootApplication
911
@EnableZuulProxy
1012
@EnableDiscoveryClient
@@ -13,4 +15,8 @@ public class NetflixZuulApiGatewayServerApplication {
1315
public static void main(String[] args) {
1416
SpringApplication.run(NetflixZuulApiGatewayServerApplication.class, args);
1517
}
18+
19+
public Sampler defaultSampler() {
20+
return Sampler.ALWAYS_SAMPLE;
21+
}
1622
}

micro-services/spring-cloud-config-server/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@
3030
<groupId>org.springframework.cloud</groupId>
3131
<artifactId>spring-cloud-config-server</artifactId>
3232
</dependency>
33-
33+
<!--
3434
<dependency>
3535
<groupId>org.springframework.boot</groupId>
3636
<artifactId>spring-boot-devtools</artifactId>
3737
<scope>runtime</scope>
3838
</dependency>
39+
-->
3940
<dependency>
4041
<groupId>org.springframework.boot</groupId>
4142
<artifactId>spring-boot-starter-test</artifactId>
48.9 MB
Binary file not shown.
49.3 MB
Binary file not shown.

0 commit comments

Comments
 (0)