diff --git a/clientui/pom.xml b/clientui/pom.xml index 6684242..455df86 100644 --- a/clientui/pom.xml +++ b/clientui/pom.xml @@ -61,6 +61,10 @@ spring-cloud-starter-netflix-ribbon + + org.springframework.cloud + spring-cloud-starter-sleuth + diff --git a/clientui/src/main/java/com/clientui/ClientUiApplication.java b/clientui/src/main/java/com/clientui/ClientUiApplication.java index f21671f..d3339cc 100644 --- a/clientui/src/main/java/com/clientui/ClientUiApplication.java +++ b/clientui/src/main/java/com/clientui/ClientUiApplication.java @@ -1,10 +1,12 @@ package com.clientui; +import brave.sampler.Sampler; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.netflix.ribbon.RibbonClient; import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.context.annotation.Bean; @SpringBootApplication @EnableFeignClients("com.clientui") @@ -14,4 +16,9 @@ public class ClientUiApplication { public static void main(String[] args) { SpringApplication.run(ClientUiApplication.class, args); } + + @Bean + public Sampler defaultSampler(){ + return Sampler.ALWAYS_SAMPLE; + } } diff --git a/clientui/src/main/java/com/clientui/configuration/FeignConfig.java b/clientui/src/main/java/com/clientui/configuration/FeignConfig.java new file mode 100644 index 0000000..d921cf7 --- /dev/null +++ b/clientui/src/main/java/com/clientui/configuration/FeignConfig.java @@ -0,0 +1,15 @@ +package com.clientui.configuration; + +import feign.auth.BasicAuthRequestInterceptor; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class FeignConfig { + + @Bean + public BasicAuthRequestInterceptor mBasicAuthRequestInterceptor(){ + return new BasicAuthRequestInterceptor("utilisateur", "mdp"); + } + +} diff --git a/clientui/src/main/java/com/clientui/configuration/SleuthConfig.java b/clientui/src/main/java/com/clientui/configuration/SleuthConfig.java new file mode 100644 index 0000000..27b1e64 --- /dev/null +++ b/clientui/src/main/java/com/clientui/configuration/SleuthConfig.java @@ -0,0 +1,14 @@ +package com.clientui.configuration; + +import brave.sampler.Sampler; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class SleuthConfig { + + + public Sampler defaultSampler(){ + return Sampler.ALWAYS_SAMPLE; + } +} diff --git a/clientui/src/main/java/com/clientui/controller/ClientController.java b/clientui/src/main/java/com/clientui/controller/ClientController.java index f427d0f..24439ed 100644 --- a/clientui/src/main/java/com/clientui/controller/ClientController.java +++ b/clientui/src/main/java/com/clientui/controller/ClientController.java @@ -6,6 +6,8 @@ import com.clientui.beans.ProductBean; import com.clientui.proxies.MicroserviceCommandeProxy; import com.clientui.proxies.MicroservicePaiementProxy; import com.clientui.proxies.MicroserviceProduitsProxy; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -33,6 +35,8 @@ public class ClientController { private MicroservicePaiementProxy paiementProxy; + Logger log = LoggerFactory.getLogger(this.getClass()); + /* * Étape (1) * Opération qui récupère la liste des produits et on les affichent dans la page d'accueil. @@ -42,10 +46,14 @@ public class ClientController { @RequestMapping("/") public String accueil(Model model){ + + log.info("Envoi requête vers microservice-produits"); + List produits = ProduitsProxy.listeDesProduits(); model.addAttribute("produits", produits); + return "Accueil"; } diff --git a/config-server-repo/microservice-clientui.properties b/config-server-repo/microservice-clientui.properties index 8a2ff05..7801b47 100644 --- a/config-server-repo/microservice-clientui.properties +++ b/config-server-repo/microservice-clientui.properties @@ -1,5 +1,5 @@ -server.port 8080 +server.port: 8080 #Eureka eureka.client.serviceUrl.defaultZone: http://localhost:9102/eureka/ diff --git a/config-server-repo/zuul-server.properties b/config-server-repo/zuul-server.properties index bb9c060..7fd518f 100644 --- a/config-server-repo/zuul-server.properties +++ b/config-server-repo/zuul-server.properties @@ -2,4 +2,8 @@ server.port 9004 #Eureka -eureka.client.serviceUrl.defaultZone: http://localhost:9102/eureka/ \ No newline at end of file +eureka.client.serviceUrl.defaultZone: http://localhost:9102/eureka/ + +#Spring Security +spring.security.user.name=utilisateur +spring.security.user.password=mdp \ No newline at end of file diff --git a/config-server/pom.xml b/config-server/pom.xml index ae2ec45..d81a130 100644 --- a/config-server/pom.xml +++ b/config-server/pom.xml @@ -31,6 +31,11 @@ spring-cloud-config-server + + org.springframework.cloud + spring-cloud-starter-sleuth + + org.springframework.boot spring-boot-starter-test diff --git a/eureka-server/pom.xml b/eureka-server/pom.xml index f9ffbc3..80b895d 100644 --- a/eureka-server/pom.xml +++ b/eureka-server/pom.xml @@ -35,6 +35,16 @@ spring-cloud-starter-netflix-eureka-server + + org.springframework.cloud + spring-cloud-starter-sleuth + + + + org.springframework.cloud + spring-cloud-sleuth-zipkin + + org.springframework.boot spring-boot-starter-test diff --git a/microservice-produits/pom.xml b/microservice-produits/pom.xml index dfce676..8538789 100644 --- a/microservice-produits/pom.xml +++ b/microservice-produits/pom.xml @@ -59,6 +59,15 @@ spring-cloud-starter-netflix-eureka-server + + org.springframework.cloud + spring-cloud-starter-sleuth + + + + org.springframework.cloud + spring-cloud-sleuth-zipkin + diff --git a/microservice-produits/src/main/java/com/mproduits/MproduitsApplication.java b/microservice-produits/src/main/java/com/mproduits/MproduitsApplication.java index 511d20f..6224ad8 100644 --- a/microservice-produits/src/main/java/com/mproduits/MproduitsApplication.java +++ b/microservice-produits/src/main/java/com/mproduits/MproduitsApplication.java @@ -1,10 +1,12 @@ package com.mproduits; +import brave.sampler.Sampler; import com.mproduits.configurations.ApplicationPropertiesConfiguration; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.context.annotation.Bean; @SpringBootApplication @EnableConfigurationProperties @@ -14,4 +16,9 @@ public class MproduitsApplication { public static void main(String[] args) { SpringApplication.run(MproduitsApplication.class, args); } + + @Bean + public Sampler defaultSampler(){ + return Sampler.ALWAYS_SAMPLE; + } } diff --git a/microservice-produits/src/main/java/com/mproduits/configurations/SleuthConfig.java b/microservice-produits/src/main/java/com/mproduits/configurations/SleuthConfig.java new file mode 100644 index 0000000..9ce2c34 --- /dev/null +++ b/microservice-produits/src/main/java/com/mproduits/configurations/SleuthConfig.java @@ -0,0 +1,14 @@ +package com.mproduits.configurations; + +import brave.sampler.Sampler; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class SleuthConfig { + + + public Sampler defaultSampler(){ + return Sampler.ALWAYS_SAMPLE; + } +} diff --git a/microservice-produits/src/main/java/com/mproduits/web/controller/ProductController.java b/microservice-produits/src/main/java/com/mproduits/web/controller/ProductController.java index cdc8e11..008bab9 100644 --- a/microservice-produits/src/main/java/com/mproduits/web/controller/ProductController.java +++ b/microservice-produits/src/main/java/com/mproduits/web/controller/ProductController.java @@ -4,6 +4,8 @@ import com.mproduits.configurations.ApplicationPropertiesConfiguration; import com.mproduits.dao.ProductDao; import com.mproduits.model.Product; import com.mproduits.web.exceptions.ProductNotFoundException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.web.bind.annotation.GetMapping; @@ -19,6 +21,9 @@ public class ProductController { @Autowired ProductDao productDao; + + Logger log = LoggerFactory.getLogger(this.getClass()); + @Autowired ApplicationPropertiesConfiguration appProperties; @@ -32,6 +37,9 @@ public class ProductController { List listeLimitee = products.subList(0, appProperties.getLimitDeProduits()); + + log.info("Récupération de la liste des produits"); + return listeLimitee; } diff --git a/zuul-server/pom.xml b/zuul-server/pom.xml index ae7b621..6b70def 100644 --- a/zuul-server/pom.xml +++ b/zuul-server/pom.xml @@ -40,6 +40,21 @@ spring-cloud-starter-config + + org.springframework.cloud + spring-cloud-starter-security + + + + org.springframework.cloud + spring-cloud-starter-sleuth + + + + org.springframework.cloud + spring-cloud-sleuth-zipkin + + org.springframework.boot spring-boot-starter-test diff --git a/zuul-server/src/main/java/com/mcommerce/zuulserver/ZuulServerApplication.java b/zuul-server/src/main/java/com/mcommerce/zuulserver/ZuulServerApplication.java index 6ff777a..491c565 100644 --- a/zuul-server/src/main/java/com/mcommerce/zuulserver/ZuulServerApplication.java +++ b/zuul-server/src/main/java/com/mcommerce/zuulserver/ZuulServerApplication.java @@ -1,9 +1,11 @@ package com.mcommerce.zuulserver; +import brave.sampler.Sampler; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.netflix.zuul.EnableZuulProxy; +import org.springframework.context.annotation.Bean; @SpringBootApplication @EnableZuulProxy @@ -13,4 +15,6 @@ public class ZuulServerApplication { public static void main(String[] args) { SpringApplication.run(ZuulServerApplication.class, args); } + + } diff --git a/zuul-server/src/main/java/com/mcommerce/zuulserver/configuration/SleuthConfig.java b/zuul-server/src/main/java/com/mcommerce/zuulserver/configuration/SleuthConfig.java new file mode 100644 index 0000000..03b4da9 --- /dev/null +++ b/zuul-server/src/main/java/com/mcommerce/zuulserver/configuration/SleuthConfig.java @@ -0,0 +1,14 @@ +package com.mcommerce.zuulserver.configuration; + +import brave.sampler.Sampler; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class SleuthConfig { + + + public Sampler defaultSampler(){ + return Sampler.ALWAYS_SAMPLE; + } +}