How to configure Spring Cloud Sleuth in Spring Boot microservices - spring-boot

Can someone please help me? I want to integrate Spring Sleuth with my Spring Boot microservices. I added spring-cloud-starter-sleuth dependency. Also tried by added SLF4J along with it. But it is print normal logs. Not printing in Sleuth style like app name, span id ,traceid etc. I am not sure if it is recognizing dependency? Do I need to add any other dependency? Any properties file?
Could you please guide with exact dependency? and exact steps to configure?

In terms of logging, we support slf4j out of the box. You have to implement your own SpanLogger interface to add the logging support for log4j

Related

Spring boot sleuth no traces in zipkin

we are trying to use sleuth to send logs to zipkin. We are using spring boot '2.2.6.RELEASE' and cloud version Hoxton.RELEASE. I have added below dependencies
implementation "org.springframework.cloud:spring-cloud-starter-zipkin:2.2.6.RELEASE"
implementation "org.springframework.cloud:spring-cloud-starter-sleuth:2.2.6.RELEASE"
implementation "org.springframework.cloud:spring-cloud-sleuth-zipkin:2.2.6.RELEASE"
And added below props in logback.xml
[%X{traceId} %X{spanId} %X{X-Span-Export}]
With the above changes in our 2 services, we were expecting zipkin will have some logs, but nothing appeared. So then we tried to add below properties in application.properties
spring.zipkin.base-url=http://localhost:9411
spring.zipkin.enabled=true
spring.zipkin.service.name=xyz-service
spring.sleuth.enabled=true
spring.sleuth.integration.enabled=true
spring.sleuth.sampler.rate=100
spring.sleuth.sampler.probability=1.0
spring.zipkin.sender.type=web
And still dont see logs / service name in zipkin.
Can you see what am I doing wrong here. Out apps have cloud-stream dependencies as well. And also noted that in logs I am getting X-span-export coming as false. For ex: [3e205e41db60212f 77a405a53d62c9fa false]
Please upgrade the project to the latest version of Spring Boot and Spring Cloud. Also use the BOM as the source of versions - do not set them manually. Please do not set the default properties manually cause as defaults they are already set.

Which dependency should be used to integrate Apache Camel with Spring Boot

Apache Camel provides two ways to integrate with Spring Boot:
camel-spring-boot
camel-spring-boot-starter
When I look at the starter then I see that it only includes camel-spring-boot and spring-boot-starter. What is the difference then and what are the advantages of using starter?
At the moment of writing this answer, camel-spring-boot is only supported from Camel 2.15 and camel-spring-boot-starter only from Camel 2.17, which is important considering the current version that your project is using.
Then the major difference between these two dependencies, lies in the "opinionated" auto-configuration provided by the starter.
camel-spring-boot, should be used if you want just to include a jar to make your camel routes auto-discovered by spring boot, this also gives you the freedom to update this dependency regardless of your spring-boot version.
camel-spring-boot-starter, (recommended way to go) should be used if you want a collection of dependencies (including camel-spring-boot) that provides the best developer/user experience, due to the fact of customizable properties, additional libraries, and default configuration for the camel library. Check the reference documentation for the starter: https://camel.apache.org/components/latest/spring-boot.html#_spring_boot_auto_configuration
Summary
Use camel-spring-boot, if you want a vanilla jar to use camel with spring boot
Use camel-spring-boot-starter, if you want an automatic-configured component to start to develop with.
You should always use the camel-xxx-starter dependencies, as these are the Camel components that is support with Spring Boot. Also as mentioned they provide auto configuration and some of them additional capabilities.
If there is no camel-xxx-starter component then its because its not supported on Spring Boot with Camel.
See more at: https://github.com/apache/camel/tree/master/platforms/spring-boot/components-starter#camel-component-starters

Why are there no Java classes in Spring Boot starters JARs?

On springboot 2.0 I want to know why spring authorities do this?
spring-boot-starter-jdbc-2.0.0.jar why not content????
This is done on purpose.
The code for the auto-configuration is contained in the spring-boot module; Spring Boot starters are "just" POMs bringing all the dependencies that will trigger the auto-configuration for that use case.
Third party starters (i.e. maintained by the community) can ship auto-configuration code as well.
You can learn more about how to create your own starter and why they're structured like this in the reference documentation.

Spring Boot, Velocity Tools

I'm trying to integrate spring boot with velocity tools but it still fails, the documentation did not find anything related to how to load velocity.properties, anyone have any help? Thank you.
I ran into some Boot/Velocity configuration issues this morning. You are right that the documentation is spare here.
If you are looking to use Velocity for Spring MVC templating, be sure to include spring-context-support on the classpath. Based on the behavior, it appears that Boot is doing some classpath autodetection here, and creates VelocityConfigurer and VelocityViewResolver beans if and only if spring-context-support is on the classpath.

How to add email to Spring Boot gradle build

Spring boot has a number of starter dependencies. The default set does not include support for mail (org.springframework.mail is missing in Boot). How do I configure my build.gradle to include the spring framework mail support?
For spring boot you want to use this:
compile("org.springframework.boot:spring-boot-starter-mail")
See more about spring starters here
Try spring-context-support, ie
compile 'org.springframework:spring-context-support'
You might find this a helpful tool for that kind of query: http://www.findjar.com.

Resources