Build the apps that make the world run. Join us at SpringOne in San Francisco, Dec 6–8. >
close

Spring Cloud Sleuth 3.1.0 is out!

With the release of the Spring Cloud 2021.0.0 (aka Jubilee) release train we’re more than happy to announce the general availability of Spring Cloud Sleuth 3.1.0. In this blog post we’ll describe the most notable released features.

Here is the list of most notable features, we’ll elaborate on them in the subsequent parts of this post.

JDBC

We’re decorating DataSources in a trace representation. We delegate actual proxying to either p6spy or datasource-proxy. In order to use this feature you need to have them on the classpath.

JDBC example

Check the docs for more details.

Here you can find a sample that depicts this integration.

Tomcat Valve

The main driver behind this change is that up till Sleuth 3.1 your Tomcat logs wouldn’t have any tracing information in it. With this change we’re instrumenting Tomcat, so we’re far earlier in the lifecycle of the request and we can instrument all possible logs with tracing information.

MVC example

Check the docs for more details.

Here you can find a sample that depicts this integration.

Spring Vault

We’re instrumenting the RestTemplate or WebClient instances used by Spring Vault to communicate with Vault.

Vault example

Check the docs for more details.

Here you can find a sample that depicts this integration for RestTemplate.

Here you can find a sample that depicts this integration for WebClient.

Automatic tag table generation for documentation

There’s nothing more frustrating in the tracing world than creating a span and not starting it, or not stopping it. We had enough of such situations… Another challenge we faced was that we didn’t even remember any longer how many spans we create, what their names are and how many tags / events are being set on them.

We’ve decided to alter the way we code things in Sleuth so that we can introduce certain automation. We are instrumenting the code once, however we are able to turn on at the test time additional assertions that verify if spans were started and stopped etc. Also at the documentation build time we parse the sources and build a table of spans together with some details.

You can check the docs to see the results of that automation.

Spring Cloud Deployer

If you have Spring Cloud Deployer running on the classpath, we wrap the AppDeployer in a trace representation. We are polling the application for its status at a default interval.

Deployer example

Check the docs for more details.

Here you can find a sample that depicts this integration.

R2DBC

If you have R2DBC Proxy on the classpath we will instrument the ConnectionFactory so that it contains a custom ProxyExecutionListener.

R2DBC example

Check the docs for more details.

Here you can find a sample that depicts this integration.

Kafka and Reactor Kafka

We decorate the Kafka clients (KafkaProducer and KafkaConsumer) to create a span for each event that is produced or consumed. We also provide TracingKafkaProducerFactory and TracingKafkaConsumerFactory to be used with the Reactor Kafka clients (KafkaSender and KafkaReceiver, respectively). Additionally, we decorate any Spring Kafka ProducerFactory and ConsumerFactory available in the context.

Kafka example

Check the docs for more details.

Here you can find a sample that depicts this integration for Kafka producer.

Here you can find a sample that depicts this integration for Kafka consumer.

Here you can find a sample that depicts this integration for Kafka Reactive producer.

Here you can find a sample that depicts this integration for Kafka Reactive consumer.

Spring TX

If you have Spring Tx on the classpath we will instrument the PlatformTransactionManager and the ReactiveTransactionManager to create a span whenever a new transaction is created.

TX example

Check the docs for more details.

Here you can find a sample that depicts this integration.

Spring Batch

If you have Spring Batch running on the classpath, we wrap the StepBuilderFactory and the JobBuilderFactory to propagate the tracing context.

Batch example

Check the docs for more details.

Here you can find a sample that depicts this integration.

RSocket

If you have Spring RSocket running on the classpath, we wrap the inbound and outbound communication to propagate the tracing context via the metadata

RSocket example

Check the docs for more details.

Here you can find a sample that depicts this integration for RSocket server.

Here you can find a sample that depicts this integration for RSocket client.

Spring Cloud Task

If you have Spring Cloud Task running on the classpath, we’re instrumenting TaskExecutionListener and CommandLineRunner and ApplicationRunner.

Task example

Here you can find a sample that depicts this integration.

Spring Cloud Config

If you have Spring Cloud Config Server running on the classpath, we will wrap the EnvironmentRepository in a span.

Config Server example

Check the docs for more details.

Here you can find a sample that depicts this integration.

Spring Cloud CircuitBreaker Reactive

If you have Spring Cloud CircuitBreaker on the classpath, we will wrap the passed command Supplier and the fallback Function in its trace representations.

CircuitBreaker Reactive example

Check the docs for more details.

Here you can find a sample that depicts this integration.

Cassandra

If you have Spring Data Cassandra on the classpath, we’re instrumenting Casandra’s CqlSession and ReactiveSession interfaces and we’re providing our own implementation of the RequestTracker.

Cassandra example

Check the docs for more details.

Here you can find a sample that depicts this integration for non reactive Cassandra.

Here you can find a sample that depicts this integration for reactive Cassandra.

Spring Session

If you have Spring Session on the classpath, we’re instrumenting the Session repositories that wraps all operations in a span.

Session example

Check the docs for more details.

Here you can find a sample that depicts this integration.

Spring Security

If you have Spring Security on the classpath, we create an implementation of SecurityContextChangedListener that annotates a current span with an event when context has changed.

Security example

Here you can find a sample that depicts this integration.

Prometheus Exemplars

Exemplars are metadata attached to metrics (see: Prometheus Exemplars), e.g.: traceId so that you can get an example traceId for your metrics.

We’re integrating Sleuth with Prometheus so that if somebody uses the Prometheus Java Client, they can get Exemplars using Sleuth. This issue is also connected to the Micrometer Exemplars Support, see.

Here you can read more about the issue.

There are a couple of notes to take into consideration with regards to this feature:

  • Micrometer does not support exemplars at the moment, we are planning to do it in our next release (you can use the Prometheus client in the meantime)
  • This is an experimental feature in Prometheus, you need to explicitly enable it with a feature flag (see: example)
  • Likewise, you need to configure it in your Grafana datasource and define the url pattern for your tracing backend (see: example with Zipkin)
  • You also need to make sure that the exemplar flag is enabled on the panel of your dashboard where you want to use exemplars (see: example Dashboard)
  • There is no configuration needed on your tracing backend (e.g.: Zipkin), you just need to know the url pattern that the backend uses to reference a traceId (see the url pattern above)

Exemplars example

Exemplars example

Spring Cloud Stream Reactive

Spring Cloud Sleuth can instrument Spring Cloud Function. Since Spring Cloud Stream uses Spring Cloud Function you will get the messaging instrumentation out of the box.

The way to achieve it is to provide a Function or Consumer or Supplier that takes in a Message as a parameter e.g. Function<Message<String>, Message<Integer>>.

If the type is not Message then instrumentation will not take place.

For a reactive Consumer<Flux<Message<?>>> remember to manually close the span and clear the context before you call .subscribe().

Stream reactive example

Here you can find a sample that depicts this integration for the producer.

Here you can find a sample that depicts this integration for the consumer.

Reactive Mongo

We’re adding command listeners that wrap all commands in a span. It works both for the Reactive and non Reactive case.

Reactive Mongo example

Here you can find a sample that depicts this integration.

Abstracted Redis instrumentation

With this PR the Redis instrumentation can work for other Tracers, such as OpenTelemetry.

Custom Actuator for storing traces

Spring Cloud Sleuth comes with a traces Actuator endpoint that can store finished spans. The endpoint can be queried either via an HTTP Get method to simply retrieve the list of stored spans or via HTTP Post method to retrieve the list and clear it.

Check the docs for more details.

Stay in touch!

This release introduces a lot of instrumentations. We would love to see your traces! You can go to our Gitter and paste a screenshot of your traces so that we can analyze how we can improve it.

In case of any questions don’t hesitate to ping us

Links

comments powered by Disqus