Zipkin server is not showing Microservices trace - spring

I have a Microservice A calling another Microservice B with the following pom.xml and application.properties values:
pom.xml
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
</dependency>
application.properties
spring.zipkin.base-url=http://localhost:9411/
spring.sleuth.sampler.probability=1.0
spring.zipkin.sender.type=web
spring.zipkin.collector.http.enabled=true
Zipkin server version: zipkin-server-2.12.9
Spring Boot Version: 2.7.5
Spring cloud version: 2021.0.4
Issue is that trace that Microservice A called Microservice B with the trace-ID is not getting displayed in Zipkin.
Any issue?
Trace of Microservices calling chain with trace-ID should be coming in Zipkin server

The problem was that RestTemplate used to call the another service was create as New.
Solution is that create it as a bean and inject it to your code.

Related

Which is the best way for the routs uri in spring boot except zuul and spring cloud gateway

I am upgrading the spring boot 1.3.7.RELEASE to 2.5.12 and spring framework 5.3.18 in my spring boot microservice based project we have upgrade successfully with all service except gateway service when i am unabling t add zuul dependency because its maintenance mode that why we have implemented spring cloud gateway then i am getting below issue.
***************************
APPLICATION FAILED TO START
***************************
Description:
Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway.
Action:
Please set spring.main.web-application-type=reactive or remove spring-boot-starter-web dependency.
Wwhat we need to do implementation for best way?
We have fix the routing issue using the spring cloud gateway.
Please add dependency in the pom.xml
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-gateway</artifactId> </dependency>
bootstrap.yml
spring:main:web-application-type:reactive
Thanks you guys for supporting.

implement circuit breaker with openfeign in spring-boot 2.4 and spring cloud 2020

If I want to upgrade to spring-boot 2.4 and spring cloud 2020.
Now that spring-cloud-starter-netflix-hystrix has been removed from spring-cloud-netflix,
How can I implement circuit breaker with openfeign?
I did a direct import but my IDE cannot resolve feign.hystrix.enabled and feign is not executing the fallback class.
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
<version>2.2.7.RELEASE</version>
</dependency>

Spring Cloud Bus - Refresh a specific cluster of client

I have a spring cloud config server configured over spring cloud bus over kafka.
I am using Edgware.RELEASE with boot 1.5.9.
When I send a POST request to the endpoint /bus/refresh with destination=clientId:dev:** in the body via POSTMAN to config server, all the clients get their beans refreshed even though their clientId doesn't match the value in the destination field.
Here are additional configuration details:
spring cloud config server
pom.xml
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-monitor</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bus-kafka</artifactId>
</dependency>
application.properties
server.port=8888
management.security.enabled=false
spring.cloud.bus.enabled=true
spring.kafka.bootstrap-servers=localhost:9092
I have two config clients with id - config-client1 and config-client2
After changing an application property in the repository for config-client2, I submit a POST request to /bus/refresh endpoint on the config server, with destination=config-client2:dev:** in the body of the request. I was hoping this would refresh/re-initialize the beans only in config-client2 application. But I noticed beans in config-client application are also refreshed/re-initialized. I also noticed config-client application receiving refresh event along with config-client2.
I was hoping only config-client2 application receives the event and its beans are the only ones that are refreshed as a result of it.
Wondering if I am missing any configuration setting to enable granular refresh at specific client level.
I did go through the document posted at - http://cloud.spring.io/spring-cloud-static/Edgware.RELEASE/single/spring-cloud.html, but the results are not as explained.
Any help with a working example is appreciated.
You can use:
curl -X POST http://localhost:8001/actuator/bus-refresh/config-client2
You also need this in your application.properties or .yml.
spring.cloud.config.uri=http://localhost:8001
spring.cloud.config.uri should point to your Spring Config Server

How to use zuul in spring cloud without spring boot actuator?

I want to use zuul as a proxy server in my application, but I don't want to use spring boot actuator, I tried to remove it from the dependency as follow:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zuul</artifactId>
<version>${spring-cloud-netflix.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</exclusion>
</exclusions>
</dependency>
However, it will cause some ClassNotFoundException.
I don't need spring boot actuator in my application, but it has so many autoconfiguration in spring boot that will produce many endpoints that I don't want.
Is there any good way to solve this?
The issue has been addressed in spring cloud netflix 1135. It will be available shortly in Brixton.SR2.

How to add Spring Boot Actuator to a Spring application?

In the "Bootiful" Applications with Spring Boot Spring One 2014 section(https://www.youtube.com/watch?v=HCyYEVRZISk), Josh mentioned that it is easy to add the Boot Actuator to a Spring (non-bootiful) application. I assume that an Actuator configuration is needed somehow, but can't find how it shall be done.
Just add the starter to your pom.xml:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
... and the endpoints such as /health will be available.

Resources