I need to know the SpandId in java code but I don't know how to get it. I had been searching and I found that many people refer to Tracer class, but it is not available at sleuth 2.0.4.
Does anybody know how to get the SpandId using sleuth 2.0.4?
Thanks!
Just inject the brave.Tracer bean and then you can call tracer.currentSpan().context().spanId() or tracer.currentSpan().context().spanIdString()
Related
I have upgraded my Spring boot dependencies from 2.1 to 2.4.5 and spring cloud to 2020.0.2.
After this upgrade, my MDC context is not populated.
Any ideas of what should be done here?
in spring cloud 2020.0.2 you have sleuth 3.x and there is a migration guide telling about some changes to MDC
I think the answer depends on your use-case but as far as I remember, there was a change and the MDC context is cleaned-up after the span is finished.
This means that if you are in the scope of the Span (e.g.: controller method), you can see the Sleuth-related parts of the MDC but if you are outside of the scope of the span (e.g.: Tomcat access logs), you don't.
To test this, try to log out the MDC context map inside of the controller method, the MDC context should contain the tracing-related fields.
We incorporated spring cloud sleuth (1.1.3 RELEASE) in our spring boot 1.x application and had no problems with header propagation over rest.
However we upgraded our application to spring boot 2.0.4 and added cloud sleuth 2.0.1 RELEASE. Now, trace and Span Ids are not propagated over rest calls.
Debug points inside of B3Propagation and TracingClientHttpRequestInterceptor are not being invoked at all.
Has something changed in the newer versions of sleuth or is any additional configuration required for the TracingClientHttpRequestInterceptor?
Any pointers would be greatly appreciated.
Thanks.
In your bean you need to inject the interceptor, for example with a RestTemplateBuilder:
#Bean
public RestTemplateBuilder clientRestTemplateBuilder(TracingClientHttpRequestInterceptor tracingClientHttpRequestInterceptor) {
return new RestTemplateBuilder()
.additionalInterceptors(tracingClientHttpRequestInterceptor)
.(additional config);
}
This was happening because the rest template was not available at the time of hooking the TracingClientHttpRequestInterceptor. (was created much before the injection)
Changing the way the rest template was being injected fixed this issue.
Thanks.
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
I am developing a Jersey RESTful service using the Spring framework integration with Hibernate. I get a NoSuchMethodException on a org.jboss.logging.logger.debugf call. As I noticed, the class is indeed loaded from the bean-validator.jar included alongside the jersey-spring3 library, eventhough I have specifically referenced the jboss logging artifact.
Has anyone encountered this issue? And if so, how should I solve it?
Update
I have found a workaround, but it is far from being a solution. In order for the required classes to have the same signature, I have downgraded the hibernate-entitymanager to version 4.2.8.Final. However, this leads the way to other compatibility issues.
Update 2
In the end, I have chosen to implement the REST service functionality using the Spring Framework instead of using the aforementioned integration.
Check out the answers in the following post, your issue might be similar:
Error "java.lang.NoSuchMethodError: org.jboss.logging.Logger.getMessageLogger"
I am trying to integrate Atlassian Crowd with Spring Security.
The available code samples on this are very few, especially for Spring Boot. I have only found this.
This example calls class CrowdUserDetailsServiceImpl method setAuthenticationManager(), which has vanished in the haze in version 2.8.0 (compare 2.8.0 and 2.7.1 APIs).
Question: how should I replace the method call in 2.8.0 to make things work?
As you've found, there's no need to replace this method call. The AuthenticationManager is no longer needed by the CrowdUserDetailsServiceImpl in 2.8.
This applicationContext-security.xml shows a working example of wiring with Spring.