Skip to content

Commit

Permalink
Add support for Spring Boot 2.4 with Spring Cloud Sleuth 3 (#57)
Browse files Browse the repository at this point in the history
* Support Sleuth 3.x (while remaining backward auto-configuration compatibility with Sleuth 2.x)

* Change samples to be against Spring Boot 2.4.x and Sleuth 3.x

* Use Spring profiles to provider easy way to enable Zipkin; as opposed to Gradle hijinx
  • Loading branch information
chadlwilson authored Mar 14, 2021
1 parent 502cd58 commit b83f62d
Show file tree
Hide file tree
Showing 14 changed files with 236 additions and 273 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ version = scmVersion.version
subprojects {
apply(plugin = "java")

extra["springBootVersion"] = "2.3.1.RELEASE"
extra["springBootVersion"] = "2.4.3"
extra["p6SpyVersion"] = "3.9.0"
extra["datasourceProxyVersion"] = "1.7"
extra["flexyPoolVersion"] = "2.2.1"
extra["sleuthVersion"] = "2.2.1.RELEASE"
extra["sleuthVersion"] = "3.0.1"

extra["release"] = listOf(
"datasource-decorator-spring-boot-autoconfigure",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ dependencies {
compileOnly("com.vladmihalcea.flexy-pool:flexy-micrometer-metrics:${project.extra["flexyPoolVersion"]}")

compileOnly("org.springframework.boot:spring-boot-starter-actuator:${project.extra["springBootVersion"]}")
compileOnly("org.springframework.cloud:spring-cloud-sleuth-core:${project.extra["sleuthVersion"]}")
compileOnly("org.springframework.cloud:spring-cloud-starter-sleuth:${project.extra["sleuthVersion"]}")

testImplementation("org.junit.jupiter:junit-jupiter:5.6.2")
testImplementation("com.h2database:h2:1.4.199")
testImplementation("org.assertj:assertj-core:3.12.2")
testImplementation("org.springframework.boot:spring-boot-starter-test:${project.extra["springBootVersion"]}")

testImplementation("p6spy:p6spy:${project.extra["p6SpyVersion"]}")
Expand All @@ -39,7 +37,8 @@ dependencies {
testImplementation("com.vladmihalcea.flexy-pool:flexy-tomcatcp:${project.extra["flexyPoolVersion"]}")
testImplementation("com.vladmihalcea.flexy-pool:flexy-micrometer-metrics:${project.extra["flexyPoolVersion"]}")

testImplementation("org.springframework.cloud:spring-cloud-sleuth-core:${project.extra["sleuthVersion"]}")
testImplementation("org.springframework.cloud:spring-cloud-starter-sleuth:${project.extra["sleuthVersion"]}")
testImplementation("io.zipkin.brave:brave-tests:5.13.3")

testImplementation("commons-dbcp:commons-dbcp:1.4")
testImplementation("org.apache.commons:commons-dbcp2:2.6.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.cloud.sleuth.autoconfig.TraceAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

Expand All @@ -45,7 +44,12 @@
@ConditionalOnClass(Tracer.class)
@ConditionalOnBean(Tracer.class)
@ConditionalOnProperty(name = "decorator.datasource.sleuth.enabled", havingValue = "true", matchIfMissing = true)
@AutoConfigureAfter({ TraceAutoConfiguration.class, DataSourceDecoratorAutoConfiguration.class })
@AutoConfigureAfter(
value = DataSourceDecoratorAutoConfiguration.class,
name = {
"org.springframework.cloud.sleuth.autoconfig.brave.BraveAutoConfiguration",
"org.springframework.cloud.sleuth.autoconfig.TraceAutoConfiguration"
})
public class SleuthListenerAutoConfiguration {

public static final String SPAN_SQL_QUERY_TAG_NAME = "sql";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.cloud.sleuth.autoconfig.TraceAutoConfiguration;
import org.springframework.cloud.sleuth.log.SleuthLogAutoConfiguration;
import org.springframework.cloud.sleuth.autoconfig.brave.BraveAutoConfiguration;

import java.util.concurrent.ThreadLocalRandom;

Expand All @@ -38,8 +37,7 @@ class SleuthP6SpyListenerAutoConfigurationTests {
.withConfiguration(AutoConfigurations.of(
DataSourceAutoConfiguration.class,
DataSourceDecoratorAutoConfiguration.class,
TraceAutoConfiguration.class,
SleuthLogAutoConfiguration.class,
BraveAutoConfiguration.class,
SleuthListenerAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.cloud.sleuth.autoconfig.TraceAutoConfiguration;
import org.springframework.cloud.sleuth.log.SleuthLogAutoConfiguration;
import org.springframework.cloud.sleuth.autoconfig.brave.BraveAutoConfiguration;

import javax.sql.DataSource;

Expand All @@ -41,8 +40,7 @@ class SleuthProxyDataSourceListenerAutoConfigurationTests {
.withConfiguration(AutoConfigurations.of(
DataSourceAutoConfiguration.class,
DataSourceDecoratorAutoConfiguration.class,
TraceAutoConfiguration.class,
SleuthLogAutoConfiguration.class,
BraveAutoConfiguration.class,
SleuthListenerAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
package com.github.gavlyukovskiy.cloud.sleuth;

import brave.sampler.Sampler;
import org.springframework.cloud.sleuth.util.ArrayListSpanReporter;
import brave.test.TestSpanHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
class SavingSpanReporterConfiguration {
class TestSpanHandlerConfiguration {

@Bean
public ArrayListSpanReporter spanReporter() {
return new ArrayListSpanReporter();
public TestSpanHandler spanHandler() {
return new TestSpanHandler();
}

@Bean
Expand Down
Loading

0 comments on commit b83f62d

Please sign in to comment.