spring-cloud-sleuth | Distributed tracing for spring cloud | Microservice library
kandi X-RAY | spring-cloud-sleuth Summary
kandi X-RAY | spring-cloud-sleuth Summary
Spring Cloud Sleuth provides Spring Boot auto-configuration for distributed tracing. Sleuth configures everything you need to get started. This includes where trace data (spans) are reported to, how many traces to keep (sampling), if remote fields (baggage) are sent, and which libraries are traced.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Creates a queue from the trace context .
- Post process bean factory .
- Lazily creates a BiFunction from the Spring Context .
- Wrap the input message .
- Filter incoming request .
- The http tracing bean .
- Sets before result set next .
- Triggers a command started event .
- Extracts the span context from the trace parent .
- Instrument a bean .
spring-cloud-sleuth Key Features
spring-cloud-sleuth Examples and Code Snippets
Importing spring-cloud-sleuth as a BOM for dependency management is very suspect.
org.springframework.cloud
spring-cloud-sleuth
3.0.0
Community Discussions
Trending Discussions on spring-cloud-sleuth
QUESTION
I'm in a Spring course, and I have a maven application (downloaded from the course resources) built from spring initializr. I can build a local Docker image with mvn spring-boot:build-image
(no Dockerfile in the project). By default a Docker image is built as linux/amd64, but I am working with a M1 Apple Silicon chip (arm64). I've been looking many workarounds but with no success. Lastly, I found that maybe adding a Dockerfile and specifying the platform it would build the image accordingly.
My goal is to build a docker image for arm64 architecture.
So, I created a Dockerfile:
...ANSWER
Answered 2022-Mar-24 at 00:10Building an ARM-based image is not currently possible with mvn spring-boot:build-image
, because the Cloud Native Buildpacks builders that Spring Boot integrates with do not support this. This is one of the possible items of focus on the Paketo buildpacks 2022 roadmap, which you can cast votes for.
CNB documents a work-around for this, but it's not simple to set up and run.
RUN mvn -f /home/path_to_app/pom.xml spring-boot:build-image -DskipTests
You would need Docker-in-Docker to make something like this work, since the CNB builder processes that would run inside the Docker container need to talk to the Docker daemon. Regardless, this would not allow you to build an ARM image for the reasons stated above.
QUESTION
Small question regarding a Spring Webflux Reactive Cassandra application please.
On a setup Spring Boot 2.6.4 with Webflux and reactive Cassandra, I am using the app to insert some data in Cassandra tables.
Things works fine, until when there is a higher load, I am seeing an issue (stack trace attached)
The thing is, reading some documentation, I thought this piece of code would help solve the issue:
...ANSWER
Answered 2022-Mar-05 at 23:29You have configured the wrong option on the driver. METADATA_SCHEMA_REQUEST_TIMEOUT
is the timeout for the requests to retrieve the schema.
The default request timeout for the Java driver is basic.request.timeout
(see reference configuration):
QUESTION
I have a Spring Boot application with Spring Cloud Sleuth, OpenTelemetry instrumentation and OpenTelemetry exporter OTLP.
This is a gist of dependencies:
spring-cloud-starter-sleuth
without Brave, because we are using OpenTelemetry instrumentationspring-cloud-sleuth-otel-autoconfigure
which introduces OpenTelemetry instrumentation libs and provides Spring autoconfiguration
...opentelemetry-exporter-otlp
for sending data to apm server
ANSWER
Answered 2022-Feb-17 at 16:26To me, it looks like span and transaction names are missing (I only see HTTP GET instead of a name)
No, they are not missing. The reason you are seeing name as HTTP GET
is due to preference for less cardinal names and the semantic conventions for tracing data. There is a detailed explanation about the naming conventions for the HTTP spans here https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/http.md#name. Any data generated by auto-instrumentation libraries will adhere to the semantic conventions specification. I am guessing the visualisation from the linked vendor is coming from manual instrumentation where you as an end user can give any name (although it is recommended everyone uses less cardinal values but there is not enforcement there). I don't think there is anything you can "fix" here.
QUESTION
With the exciting releases of both SpringBoot 3.0.0-M1 and SpringCloud 2022.0.0-M1, I went ahead to bump the versions up.
https://spring.io/blog/2022/01/20/spring-boot-3-0-0-m1-is-now-available
https://spring.io/blog/2022/01/27/spring-cloud-2022-0-0-m1-codename-kilburn-has-been-released
While things worked perfectly fine on my SpringBoot 2.6.3 + Jubilee, the exact same code, with just the version change on the pom file to the new pair SpringBoot 3.0.0-M1 + SpringCloud 2022.0.0-M1, the following error is observed.
...ANSWER
Answered 2022-Feb-11 at 21:29I am having a hard time understanding. Does it mean from 3.0/2022.0 onward, there is no Sleuth anymore? We need to use Micrometer instead?
Yes
How to keep existing features offered by Sleuth please?
We will be providing support for those via Micrometer & Micrometer Tracing.
does it means we can just remove the Sleuth dependency from the pom file, and instead add/replace with the micrometer one, and things will be the same, still be working?
If you don't have any custom Sleuth configuration then there should be nothing that you should do for observability to work. If you had custom Sleuth configuration you will need to port it to Micrometer Tracing which essentially is a copy of Sleuth so that should be mostly a package change. If you were doing Brave customizations then most likely you'll have nothing to change.
QUESTION
I'm trying to setup a dynamic IntegrationFlow
to read files from a local directory. Therefore I've created the following parameterizable class:
ANSWER
Answered 2022-Feb-08 at 14:57The error means that TransactionSynchronizationFactory
must be declared as a bean and therefore its BeanFactory
requirements would be fulfilled.
Please, revise all your volatile objects and consider to make some of them as global singleton beans.
I believe all of these could go to the main configuration, not dynamic: PollerMetadata
, TransactionInterceptor
, TransactionManager
and TransactionSynchronizationFactory
. The dynamic part in your solution is really just that FileReadingMessageSource
.
It is better to use as less dynamic as possible for better performance and proper reusability. You also would avoid duplications whenever they are not needed.
I would even move that .handle(message -> System.out.println(message))
to the separate global singleton IntegrationFlow
and use only a channel reference from this one to avoid extra duplication.
QUESTION
In my code I have scheduled a runnable task using the schedule method of task schedular. I went through this link - https://docs.spring.io/spring-cloud-sleuth/docs/current-SNAPSHOT/reference/html/integrations.html#sleuth-runnablecallable-integration. I implemented this way. The current state is - for any schedule a trace is created, and the same trace id is being used for all the runs invoked by this schedule, though spans are new. But I want that each run should have it's own unique trace id. There is a method of tracer which creates a new trace, but is there any way to do this in sleuth by which I can avoid manual creation of a new trace? I am using the 2.0.x version.
...ANSWER
Answered 2022-Feb-03 at 09:29- I created a new trace using newtrace method of tracer which returns a span.
- Started this span.
- Then added this span in the currentscope using withspaninscope method.
- Started scoped span for the runnable task and finished both of these spans.
It worked.
QUESTION
I'm using spring-cloud-sleuth.version:3.0.4
and spring-cloud-aws-messaging:2.2.6.RELEASE
It correctly propogates trace id with HTTP requests.
However, it seems that it doesn't work with SQS.
Is there any way to automatically send and consume sleuth traceId with SQS communication.
...ANSWER
Answered 2021-Nov-18 at 19:14Spring Cloud AWS is now a community project, see: https://awspring.io/ The current release train of Spring Cloud (2020.x), where you can find Sleuth 3.x does not include/support it.
You should use io.awspring.cloud:spring-cloud-aws-messaging:2.3.x
instead of org.springframework.cloud:spring-cloud-aws-messaging:2.2.x
with the current release train of Spring Cloud (2020.x).
Because of these, Sleuth does not instrument Spring AWS Messaging directly but if you can use SQS in a way that integrates with Spring Integration/Messaging/Stream/something that is already instrumented, this could work; i.e.: I would try using QueueMessageChannel
and the annotations, I don't think QueueMessagingTemplate
will work.
Another thing you can do is manually instrument it and propagate tracing information in the headers, see: TraceSpringMessagingAutoConfiguration
QUESTION
I'm in the midst of upgrading an app from Spring Boot 1.x to Spring Boot 2.x. When I attempted to run an existing (and previously working) unit test, I saw the following output:
...ANSWER
Answered 2021-Nov-16 at 19:35Check the compatibility matrix, you should use Spring Cloud 2020.0.x aka Ilford (Sleuth 3.x) with Spring Boot 2.4 (or 2.5).
Sleuth 2.2.8 is Spring Cloud Hoxton, it is not compatible with Boot 2.4.
QUESTION
If the service has a lot of traffic, tracing each invocation and saving the corresponding link log costs a lot, but once the sample rate is set, some trace with errors may be missed. If I want to keep some rate collection, and the trace with errors must be traced, is this possible in spring-cloud-sleuth
? If not, is there a solution?
ANSWER
Answered 2021-Nov-16 at 18:57Spring Cloud Sleuth pushes the sampling decision down to the tracer implementation, you need to create either a SamplerFunction
or a Sampler
to do this, please see the docs:
Update:
Sampling is an early decision because tracing has some overhead and early sampling can save your app from that.
If you want to filter out your spans at the end, you can setup an always sampler and a SpanHandler
where you can access the Span
(error
, tags
, etc.) and you can also keep/drop them based on this (you can inject a sampler to your handler and apply its logic to the rest of your spans).
QUESTION
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
...ANSWER
Answered 2021-Oct-08 at 10:22Please 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.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install spring-cloud-sleuth
In order to setup Intellij you should import our coding conventions, inspection profiles and set up the checkstyle plugin. The following files can be found in the Spring Cloud Build project. Go to File → Settings → Editor → Code style. There click on the icon next to the Scheme section. There, click on the Import Scheme value and pick the Intellij IDEA code style XML option. Import the spring-cloud-build-tools/src/main/resources/intellij/Intellij_Spring_Boot_Java_Conventions.xml file. Go to File → Settings → Editor → Inspections. There click on the icon next to the Profile section. There, click on the Import Profile and import the spring-cloud-build-tools/src/main/resources/intellij/Intellij_Project_Defaults.xml file. To have Intellij work with Checkstyle, you have to install the Checkstyle plugin. It’s advisable to also install the Assertions2Assertj to automatically convert the JUnit assertions.
Default Checkstyle rules
File header setup
Default suppression rules
Project defaults for Intellij that apply most of Checkstyle rules
Project style conventions for Intellij that apply most of Checkstyle rules
checkstyle.header.file - please point it to the Spring Cloud Build’s, spring-cloud-build-tools/src/main/resources/checkstyle-header.txt file either in your cloned repo or via the https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/main/resources/checkstyle-header.txt URL.
checkstyle.suppressions.file - default suppressions. Please point it to the Spring Cloud Build’s, spring-cloud-build-tools/src/checkstyle/checkstyle-suppressions.xml file either in your cloned repo or via the https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/checkstyle/checkstyle-suppressions.xml URL.
checkstyle.additional.suppressions.file - this variable corresponds to suppressions in your local project. E.g. you’re working on spring-cloud-contract. Then point to the project-root/src/checkstyle/checkstyle-suppressions.xml folder. Example for spring-cloud-contract would be: /home/username/spring-cloud-contract/src/checkstyle/checkstyle-suppressions.xml.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page