diff --git a/build.gradle.kts b/build.gradle.kts index 68213fd..0c2d03c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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", diff --git a/datasource-decorator-spring-boot-autoconfigure/build.gradle.kts b/datasource-decorator-spring-boot-autoconfigure/build.gradle.kts index 56f733f..e8303a7 100644 --- a/datasource-decorator-spring-boot-autoconfigure/build.gradle.kts +++ b/datasource-decorator-spring-boot-autoconfigure/build.gradle.kts @@ -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"]}") @@ -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") diff --git a/datasource-decorator-spring-boot-autoconfigure/src/main/java/com/github/gavlyukovskiy/cloud/sleuth/SleuthListenerAutoConfiguration.java b/datasource-decorator-spring-boot-autoconfigure/src/main/java/com/github/gavlyukovskiy/cloud/sleuth/SleuthListenerAutoConfiguration.java index dd5057d..3d116ce 100644 --- a/datasource-decorator-spring-boot-autoconfigure/src/main/java/com/github/gavlyukovskiy/cloud/sleuth/SleuthListenerAutoConfiguration.java +++ b/datasource-decorator-spring-boot-autoconfigure/src/main/java/com/github/gavlyukovskiy/cloud/sleuth/SleuthListenerAutoConfiguration.java @@ -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; @@ -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"; diff --git a/datasource-decorator-spring-boot-autoconfigure/src/test/java/com/github/gavlyukovskiy/cloud/sleuth/SleuthP6SpyListenerAutoConfigurationTests.java b/datasource-decorator-spring-boot-autoconfigure/src/test/java/com/github/gavlyukovskiy/cloud/sleuth/SleuthP6SpyListenerAutoConfigurationTests.java index 2b76d7c..2835765 100644 --- a/datasource-decorator-spring-boot-autoconfigure/src/test/java/com/github/gavlyukovskiy/cloud/sleuth/SleuthP6SpyListenerAutoConfigurationTests.java +++ b/datasource-decorator-spring-boot-autoconfigure/src/test/java/com/github/gavlyukovskiy/cloud/sleuth/SleuthP6SpyListenerAutoConfigurationTests.java @@ -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; @@ -38,8 +37,7 @@ class SleuthP6SpyListenerAutoConfigurationTests { .withConfiguration(AutoConfigurations.of( DataSourceAutoConfiguration.class, DataSourceDecoratorAutoConfiguration.class, - TraceAutoConfiguration.class, - SleuthLogAutoConfiguration.class, + BraveAutoConfiguration.class, SleuthListenerAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class )) diff --git a/datasource-decorator-spring-boot-autoconfigure/src/test/java/com/github/gavlyukovskiy/cloud/sleuth/SleuthProxyDataSourceListenerAutoConfigurationTests.java b/datasource-decorator-spring-boot-autoconfigure/src/test/java/com/github/gavlyukovskiy/cloud/sleuth/SleuthProxyDataSourceListenerAutoConfigurationTests.java index 3f24a82..a95465e 100644 --- a/datasource-decorator-spring-boot-autoconfigure/src/test/java/com/github/gavlyukovskiy/cloud/sleuth/SleuthProxyDataSourceListenerAutoConfigurationTests.java +++ b/datasource-decorator-spring-boot-autoconfigure/src/test/java/com/github/gavlyukovskiy/cloud/sleuth/SleuthProxyDataSourceListenerAutoConfigurationTests.java @@ -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; @@ -41,8 +40,7 @@ class SleuthProxyDataSourceListenerAutoConfigurationTests { .withConfiguration(AutoConfigurations.of( DataSourceAutoConfiguration.class, DataSourceDecoratorAutoConfiguration.class, - TraceAutoConfiguration.class, - SleuthLogAutoConfiguration.class, + BraveAutoConfiguration.class, SleuthListenerAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class )) diff --git a/datasource-decorator-spring-boot-autoconfigure/src/test/java/com/github/gavlyukovskiy/cloud/sleuth/SavingSpanReporterConfiguration.java b/datasource-decorator-spring-boot-autoconfigure/src/test/java/com/github/gavlyukovskiy/cloud/sleuth/TestSpanHandlerConfiguration.java similarity index 82% rename from datasource-decorator-spring-boot-autoconfigure/src/test/java/com/github/gavlyukovskiy/cloud/sleuth/SavingSpanReporterConfiguration.java rename to datasource-decorator-spring-boot-autoconfigure/src/test/java/com/github/gavlyukovskiy/cloud/sleuth/TestSpanHandlerConfiguration.java index 2a2415b..d279c15 100644 --- a/datasource-decorator-spring-boot-autoconfigure/src/test/java/com/github/gavlyukovskiy/cloud/sleuth/SavingSpanReporterConfiguration.java +++ b/datasource-decorator-spring-boot-autoconfigure/src/test/java/com/github/gavlyukovskiy/cloud/sleuth/TestSpanHandlerConfiguration.java @@ -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 diff --git a/datasource-decorator-spring-boot-autoconfigure/src/test/java/com/github/gavlyukovskiy/cloud/sleuth/TracingJdbcEventListenerTests.java b/datasource-decorator-spring-boot-autoconfigure/src/test/java/com/github/gavlyukovskiy/cloud/sleuth/TracingJdbcEventListenerTests.java index 3b54080..e29a433 100644 --- a/datasource-decorator-spring-boot-autoconfigure/src/test/java/com/github/gavlyukovskiy/cloud/sleuth/TracingJdbcEventListenerTests.java +++ b/datasource-decorator-spring-boot-autoconfigure/src/test/java/com/github/gavlyukovskiy/cloud/sleuth/TracingJdbcEventListenerTests.java @@ -16,6 +16,8 @@ package com.github.gavlyukovskiy.cloud.sleuth; +import brave.handler.MutableSpan; +import brave.test.TestSpanHandler; import com.github.gavlyukovskiy.boot.jdbc.decorator.DataSourceDecoratorAutoConfiguration; import com.github.gavlyukovskiy.boot.jdbc.decorator.HidePackagesClassLoader; import org.junit.jupiter.api.Test; @@ -23,10 +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.util.ArrayListSpanReporter; -import zipkin2.Span; +import org.springframework.cloud.sleuth.autoconfig.brave.BraveAutoConfiguration; import javax.sql.DataSource; @@ -49,10 +48,9 @@ class TracingJdbcEventListenerTests { .withConfiguration(AutoConfigurations.of( DataSourceAutoConfiguration.class, DataSourceDecoratorAutoConfiguration.class, - TraceAutoConfiguration.class, - SleuthLogAutoConfiguration.class, + BraveAutoConfiguration.class, SleuthListenerAutoConfiguration.class, - SavingSpanReporterConfiguration.class, + TestSpanHandlerConfiguration.class, PropertyPlaceholderAutoConfiguration.class )) .withPropertyValues("spring.datasource.initialization-mode=never", @@ -64,15 +62,15 @@ class TracingJdbcEventListenerTests { void testShouldAddSpanForConnection() { contextRunner.run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); connection.commit(); connection.rollback(); connection.close(); - assertThat(spanReporter.getSpans()).hasSize(1); - Span connectionSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(1); + MutableSpan connectionSpan = spanReporter.spans().get(0); assertThat(connectionSpan.name()).isEqualTo("jdbc:/test/connection"); assertThat(connectionSpan.annotations()).extracting("value").contains("commit"); assertThat(connectionSpan.annotations()).extracting("value").contains("rollback"); @@ -83,15 +81,15 @@ void testShouldAddSpanForConnection() { void testShouldAddSpanForPreparedStatementExecute() { contextRunner.run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); connection.prepareStatement("SELECT NOW()").execute(); connection.close(); - assertThat(spanReporter.getSpans()).hasSize(2); - Span connectionSpan = spanReporter.getSpans().get(1); - Span statementSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(2); + MutableSpan connectionSpan = spanReporter.spans().get(1); + MutableSpan statementSpan = spanReporter.spans().get(0); assertThat(connectionSpan.name()).isEqualTo("jdbc:/test/connection"); assertThat(statementSpan.name()).isEqualTo("jdbc:/test/query"); assertThat(statementSpan.tags()).containsEntry(SleuthListenerAutoConfiguration.SPAN_SQL_QUERY_TAG_NAME, "SELECT NOW()"); @@ -102,15 +100,15 @@ void testShouldAddSpanForPreparedStatementExecute() { void testShouldAddSpanForPreparedStatementExecuteUpdate() { contextRunner.run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); connection.prepareStatement("UPDATE INFORMATION_SCHEMA.TABLES SET table_Name = '' WHERE 0 = 1").executeUpdate(); connection.close(); - assertThat(spanReporter.getSpans()).hasSize(2); - Span connectionSpan = spanReporter.getSpans().get(1); - Span statementSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(2); + MutableSpan connectionSpan = spanReporter.spans().get(1); + MutableSpan statementSpan = spanReporter.spans().get(0); assertThat(connectionSpan.name()).isEqualTo("jdbc:/test/connection"); assertThat(statementSpan.name()).isEqualTo("jdbc:/test/query"); assertThat(statementSpan.tags()).containsEntry(SleuthListenerAutoConfiguration.SPAN_SQL_QUERY_TAG_NAME, @@ -124,7 +122,7 @@ void testShouldUsePlaceholderInSqlTagOfSpansForPreparedStatementIfIncludeParamet contextRunner.withPropertyValues("decorator.datasource.p6spy.tracing.include-parameter-values=false") .run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); PreparedStatement preparedStatement = connection.prepareStatement("UPDATE INFORMATION_SCHEMA.TABLES SET table_Name = ? WHERE 0 = ?"); @@ -133,9 +131,9 @@ void testShouldUsePlaceholderInSqlTagOfSpansForPreparedStatementIfIncludeParamet preparedStatement.executeUpdate(); connection.close(); - assertThat(spanReporter.getSpans()).hasSize(2); - Span connectionSpan = spanReporter.getSpans().get(1); - Span statementSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(2); + MutableSpan connectionSpan = spanReporter.spans().get(1); + MutableSpan statementSpan = spanReporter.spans().get(0); assertThat(connectionSpan.name()).isEqualTo("jdbc:/test/connection"); assertThat(statementSpan.name()).isEqualTo("jdbc:/test/query"); assertThat(statementSpan.tags()).containsEntry(SleuthListenerAutoConfiguration.SPAN_SQL_QUERY_TAG_NAME, @@ -148,15 +146,15 @@ void testShouldUsePlaceholderInSqlTagOfSpansForPreparedStatementIfIncludeParamet void testShouldAddSpanForStatementExecuteUpdate() { contextRunner.run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); connection.createStatement().executeUpdate("UPDATE INFORMATION_SCHEMA.TABLES SET table_Name = '' WHERE 0 = 1"); connection.close(); - assertThat(spanReporter.getSpans()).hasSize(2); - Span connectionSpan = spanReporter.getSpans().get(1); - Span statementSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(2); + MutableSpan connectionSpan = spanReporter.spans().get(1); + MutableSpan statementSpan = spanReporter.spans().get(0); assertThat(connectionSpan.name()).isEqualTo("jdbc:/test/connection"); assertThat(statementSpan.name()).isEqualTo("jdbc:/test/query"); assertThat(statementSpan.tags()).containsEntry(SleuthListenerAutoConfiguration.SPAN_SQL_QUERY_TAG_NAME, @@ -169,7 +167,7 @@ void testShouldAddSpanForStatementExecuteUpdate() { void testShouldAddSpanForPreparedStatementExecuteQueryIncludingTimeToCloseResultSet() { contextRunner.run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); ResultSet resultSet = connection.prepareStatement("SELECT NOW() UNION ALL SELECT NOW()").executeQuery(); @@ -178,10 +176,10 @@ void testShouldAddSpanForPreparedStatementExecuteQueryIncludingTimeToCloseResult resultSet.close(); connection.close(); - assertThat(spanReporter.getSpans()).hasSize(3); - Span connectionSpan = spanReporter.getSpans().get(2); - Span resultSetSpan = spanReporter.getSpans().get(1); - Span statementSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(3); + MutableSpan connectionSpan = spanReporter.spans().get(2); + MutableSpan resultSetSpan = spanReporter.spans().get(1); + MutableSpan statementSpan = spanReporter.spans().get(0); assertThat(connectionSpan.name()).isEqualTo("jdbc:/test/connection"); assertThat(statementSpan.name()).isEqualTo("jdbc:/test/query"); assertThat(resultSetSpan.name()).isEqualTo("jdbc:/test/fetch"); @@ -194,7 +192,7 @@ void testShouldAddSpanForPreparedStatementExecuteQueryIncludingTimeToCloseResult void testShouldAddSpanForStatementAndResultSet() { contextRunner.run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); ResultSet resultSet = connection.createStatement().executeQuery("SELECT NOW()"); @@ -203,10 +201,10 @@ void testShouldAddSpanForStatementAndResultSet() { resultSet.close(); connection.close(); - assertThat(spanReporter.getSpans()).hasSize(3); - Span connectionSpan = spanReporter.getSpans().get(2); - Span resultSetSpan = spanReporter.getSpans().get(1); - Span statementSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(3); + MutableSpan connectionSpan = spanReporter.spans().get(2); + MutableSpan resultSetSpan = spanReporter.spans().get(1); + MutableSpan statementSpan = spanReporter.spans().get(0); assertThat(connectionSpan.name()).isEqualTo("jdbc:/test/connection"); assertThat(statementSpan.name()).isEqualTo("jdbc:/test/query"); assertThat(resultSetSpan.name()).isEqualTo("jdbc:/test/fetch"); @@ -219,7 +217,7 @@ void testShouldAddSpanForStatementAndResultSet() { void testShouldNotFailWhenStatementIsClosedWihoutResultSet() { contextRunner.run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); Statement statement = connection.createStatement(); @@ -228,10 +226,10 @@ void testShouldNotFailWhenStatementIsClosedWihoutResultSet() { statement.close(); connection.close(); - assertThat(spanReporter.getSpans()).hasSize(3); - Span connectionSpan = spanReporter.getSpans().get(2); - Span resultSetSpan = spanReporter.getSpans().get(1); - Span statementSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(3); + MutableSpan connectionSpan = spanReporter.spans().get(2); + MutableSpan resultSetSpan = spanReporter.spans().get(1); + MutableSpan statementSpan = spanReporter.spans().get(0); assertThat(connectionSpan.name()).isEqualTo("jdbc:/test/connection"); assertThat(statementSpan.name()).isEqualTo("jdbc:/test/query"); assertThat(resultSetSpan.name()).isEqualTo("jdbc:/test/fetch"); @@ -243,7 +241,7 @@ void testShouldNotFailWhenStatementIsClosedWihoutResultSet() { void testShouldNotFailWhenConnectionIsClosedWihoutResultSet() { contextRunner.run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); Statement statement = connection.createStatement(); @@ -251,10 +249,10 @@ void testShouldNotFailWhenConnectionIsClosedWihoutResultSet() { resultSet.next(); connection.close(); - assertThat(spanReporter.getSpans()).hasSize(3); - Span connectionSpan = spanReporter.getSpans().get(2); - Span resultSetSpan = spanReporter.getSpans().get(1); - Span statementSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(3); + MutableSpan connectionSpan = spanReporter.spans().get(2); + MutableSpan resultSetSpan = spanReporter.spans().get(1); + MutableSpan statementSpan = spanReporter.spans().get(0); assertThat(connectionSpan.name()).isEqualTo("jdbc:/test/connection"); assertThat(statementSpan.name()).isEqualTo("jdbc:/test/query"); assertThat(resultSetSpan.name()).isEqualTo("jdbc:/test/fetch"); @@ -266,7 +264,7 @@ void testShouldNotFailWhenConnectionIsClosedWihoutResultSet() { void testShouldNotFailWhenResultSetNextWasNotCalled() { contextRunner.run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); Statement statement = connection.createStatement(); @@ -276,10 +274,10 @@ void testShouldNotFailWhenResultSetNextWasNotCalled() { statement.close(); connection.close(); - assertThat(spanReporter.getSpans()).hasSize(3); - Span connectionSpan = spanReporter.getSpans().get(2); - Span resultSetSpan = spanReporter.getSpans().get(1); - Span statementSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(3); + MutableSpan connectionSpan = spanReporter.spans().get(2); + MutableSpan resultSetSpan = spanReporter.spans().get(1); + MutableSpan statementSpan = spanReporter.spans().get(0); assertThat(connectionSpan.name()).isEqualTo("jdbc:/test/connection"); assertThat(statementSpan.name()).isEqualTo("jdbc:/test/query"); assertThat(resultSetSpan.name()).isEqualTo("jdbc:/test/fetch"); @@ -291,7 +289,7 @@ void testShouldNotFailWhenResultSetNextWasNotCalled() { void testShouldNotFailWhenResourceIsAlreadyClosed() { contextRunner.run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); Statement statement = connection.createStatement(); @@ -304,10 +302,10 @@ void testShouldNotFailWhenResourceIsAlreadyClosed() { connection.close(); connection.close(); - assertThat(spanReporter.getSpans()).hasSize(3); - Span connectionSpan = spanReporter.getSpans().get(2); - Span resultSetSpan = spanReporter.getSpans().get(1); - Span statementSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(3); + MutableSpan connectionSpan = spanReporter.spans().get(2); + MutableSpan resultSetSpan = spanReporter.spans().get(1); + MutableSpan statementSpan = spanReporter.spans().get(0); assertThat(connectionSpan.name()).isEqualTo("jdbc:/test/connection"); assertThat(statementSpan.name()).isEqualTo("jdbc:/test/query"); assertThat(resultSetSpan.name()).isEqualTo("jdbc:/test/fetch"); @@ -319,7 +317,7 @@ void testShouldNotFailWhenResourceIsAlreadyClosed() { void testShouldNotFailWhenResourceIsAlreadyClosed2() { contextRunner.run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); try { @@ -330,8 +328,8 @@ void testShouldNotFailWhenResourceIsAlreadyClosed2() { catch (SQLException expected) { } - assertThat(spanReporter.getSpans()).hasSize(1); - Span connectionSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(1); + MutableSpan connectionSpan = spanReporter.spans().get(0); assertThat(connectionSpan.name()).isEqualTo("jdbc:/test/connection"); }); } @@ -340,16 +338,16 @@ void testShouldNotFailWhenResourceIsAlreadyClosed2() { void testShouldNotFailToCloseSpanForTwoConsecutiveConnections() { contextRunner.run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection1 = dataSource.getConnection(); Connection connection2 = dataSource.getConnection(); connection1.close(); connection2.close(); - assertThat(spanReporter.getSpans()).hasSize(2); - Span connection1Span = spanReporter.getSpans().get(0); - Span connection2Span = spanReporter.getSpans().get(1); + assertThat(spanReporter.spans()).hasSize(2); + MutableSpan connection1Span = spanReporter.spans().get(0); + MutableSpan connection2Span = spanReporter.spans().get(1); assertThat(connection1Span.name()).isEqualTo("jdbc:/test/connection"); assertThat(connection2Span.name()).isEqualTo("jdbc:/test/connection"); }); @@ -359,7 +357,7 @@ void testShouldNotFailToCloseSpanForTwoConsecutiveConnections() { void testShouldNotFailWhenClosedInReversedOrder() { contextRunner.run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); Statement statement = connection.createStatement(); @@ -369,10 +367,10 @@ void testShouldNotFailWhenClosedInReversedOrder() { statement.close(); resultSet.close(); - assertThat(spanReporter.getSpans()).hasSize(3); - Span connectionSpan = spanReporter.getSpans().get(2); - Span resultSetSpan = spanReporter.getSpans().get(1); - Span statementSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(3); + MutableSpan connectionSpan = spanReporter.spans().get(2); + MutableSpan resultSetSpan = spanReporter.spans().get(1); + MutableSpan statementSpan = spanReporter.spans().get(0); assertThat(connectionSpan.name()).isEqualTo("jdbc:/test/connection"); assertThat(statementSpan.name()).isEqualTo("jdbc:/test/query"); assertThat(resultSetSpan.name()).isEqualTo("jdbc:/test/fetch"); @@ -384,7 +382,7 @@ void testShouldNotFailWhenClosedInReversedOrder() { void testSingleConnectionAcrossMultipleThreads() { contextRunner.run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); IntStream.range(0, 5) @@ -404,8 +402,8 @@ void testSingleConnectionAcrossMultipleThreads() { .forEach(CompletableFuture::join); connection.close(); - assertThat(spanReporter.getSpans()).hasSize(1 + 2 * 5); - assertThat(spanReporter.getSpans()).extracting("name") + assertThat(spanReporter.spans()).hasSize(1 + 2 * 5); + assertThat(spanReporter.spans()).extracting("name") .contains("jdbc:/test/query", "jdbc:/test/fetch", "jdbc:/test/connection"); }); } @@ -414,7 +412,7 @@ void testSingleConnectionAcrossMultipleThreads() { void testShouldIncludeOnlyConnectionTraces() { contextRunner.withPropertyValues("decorator.datasource.sleuth.include: connection").run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); Statement statement = connection.createStatement(); @@ -424,8 +422,8 @@ void testShouldIncludeOnlyConnectionTraces() { statement.close(); connection.close(); - assertThat(spanReporter.getSpans()).hasSize(1); - Span connectionSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(1); + MutableSpan connectionSpan = spanReporter.spans().get(0); assertThat(connectionSpan.name()).isEqualTo("jdbc:/test/connection"); }); } @@ -434,7 +432,7 @@ void testShouldIncludeOnlyConnectionTraces() { void testShouldIncludeOnlyQueryTraces() { contextRunner.withPropertyValues("decorator.datasource.sleuth.include: query").run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); Statement statement = connection.createStatement(); @@ -444,8 +442,8 @@ void testShouldIncludeOnlyQueryTraces() { statement.close(); connection.close(); - assertThat(spanReporter.getSpans()).hasSize(1); - Span statementSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(1); + MutableSpan statementSpan = spanReporter.spans().get(0); assertThat(statementSpan.name()).isEqualTo("jdbc:/test/query"); }); } @@ -454,7 +452,7 @@ void testShouldIncludeOnlyQueryTraces() { void testShouldIncludeOnlyFetchTraces() { contextRunner.withPropertyValues("decorator.datasource.sleuth.include: fetch").run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); Statement statement = connection.createStatement(); @@ -464,8 +462,8 @@ void testShouldIncludeOnlyFetchTraces() { statement.close(); connection.close(); - assertThat(spanReporter.getSpans()).hasSize(1); - Span resultSetSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(1); + MutableSpan resultSetSpan = spanReporter.spans().get(0); assertThat(resultSetSpan.name()).isEqualTo("jdbc:/test/fetch"); }); } @@ -474,7 +472,7 @@ void testShouldIncludeOnlyFetchTraces() { void testShouldIncludeOnlyConnectionAndQueryTraces() { contextRunner.withPropertyValues("decorator.datasource.sleuth.include: connection, query").run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); Statement statement = connection.createStatement(); @@ -484,9 +482,9 @@ void testShouldIncludeOnlyConnectionAndQueryTraces() { statement.close(); connection.close(); - assertThat(spanReporter.getSpans()).hasSize(2); - Span connectionSpan = spanReporter.getSpans().get(1); - Span statementSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(2); + MutableSpan connectionSpan = spanReporter.spans().get(1); + MutableSpan statementSpan = spanReporter.spans().get(0); assertThat(connectionSpan.name()).isEqualTo("jdbc:/test/connection"); assertThat(statementSpan.name()).isEqualTo("jdbc:/test/query"); }); @@ -496,7 +494,7 @@ void testShouldIncludeOnlyConnectionAndQueryTraces() { void testShouldIncludeOnlyConnectionAndFetchTraces() { contextRunner.withPropertyValues("decorator.datasource.sleuth.include: connection, fetch").run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); Statement statement = connection.createStatement(); @@ -506,9 +504,9 @@ void testShouldIncludeOnlyConnectionAndFetchTraces() { statement.close(); connection.close(); - assertThat(spanReporter.getSpans()).hasSize(2); - Span connectionSpan = spanReporter.getSpans().get(1); - Span resultSetSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(2); + MutableSpan connectionSpan = spanReporter.spans().get(1); + MutableSpan resultSetSpan = spanReporter.spans().get(0); assertThat(connectionSpan.name()).isEqualTo("jdbc:/test/connection"); assertThat(resultSetSpan.name()).isEqualTo("jdbc:/test/fetch"); }); @@ -518,7 +516,7 @@ void testShouldIncludeOnlyConnectionAndFetchTraces() { void testShouldIncludeOnlyQueryAndFetchTraces() { contextRunner.withPropertyValues("decorator.datasource.sleuth.include: query, fetch").run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); Statement statement = connection.createStatement(); @@ -528,9 +526,9 @@ void testShouldIncludeOnlyQueryAndFetchTraces() { statement.close(); connection.close(); - assertThat(spanReporter.getSpans()).hasSize(2); - Span resultSetSpan = spanReporter.getSpans().get(1); - Span statementSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(2); + MutableSpan resultSetSpan = spanReporter.spans().get(1); + MutableSpan statementSpan = spanReporter.spans().get(0); assertThat(statementSpan.name()).isEqualTo("jdbc:/test/query"); assertThat(resultSetSpan.name()).isEqualTo("jdbc:/test/fetch"); }); @@ -540,7 +538,7 @@ void testShouldIncludeOnlyQueryAndFetchTraces() { void testShouldNotOverrideExceptionWhenConnectionWasClosedBeforeExecutingQuery() { contextRunner.run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT NOW()"); @@ -552,8 +550,8 @@ void testShouldNotOverrideExceptionWhenConnectionWasClosedBeforeExecutingQuery() catch (SQLException expected) { } - assertThat(spanReporter.getSpans()).hasSize(1); - Span connectionSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(1); + MutableSpan connectionSpan = spanReporter.spans().get(0); assertThat(connectionSpan.name()).isEqualTo("jdbc:/test/connection"); }); } @@ -562,7 +560,7 @@ void testShouldNotOverrideExceptionWhenConnectionWasClosedBeforeExecutingQuery() void testShouldNotOverrideExceptionWhenStatementWasClosedBeforeExecutingQuery() { contextRunner.run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT NOW()"); @@ -575,9 +573,9 @@ void testShouldNotOverrideExceptionWhenStatementWasClosedBeforeExecutingQuery() } connection.close(); - assertThat(spanReporter.getSpans()).hasSize(2); - Span connectionSpan = spanReporter.getSpans().get(1); - Span statementSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(2); + MutableSpan connectionSpan = spanReporter.spans().get(1); + MutableSpan statementSpan = spanReporter.spans().get(0); assertThat(connectionSpan.name()).isEqualTo("jdbc:/test/connection"); assertThat(statementSpan.name()).isEqualTo("jdbc:/test/query"); }); @@ -587,7 +585,7 @@ void testShouldNotOverrideExceptionWhenStatementWasClosedBeforeExecutingQuery() void testShouldNotOverrideExceptionWhenResultSetWasClosedBeforeNext() { contextRunner.run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); Statement statement = connection.createStatement(); @@ -602,10 +600,10 @@ void testShouldNotOverrideExceptionWhenResultSetWasClosedBeforeNext() { statement.close(); connection.close(); - assertThat(spanReporter.getSpans()).hasSize(3); - Span connectionSpan = spanReporter.getSpans().get(2); - Span resultSetSpan = spanReporter.getSpans().get(1); - Span statementSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(3); + MutableSpan connectionSpan = spanReporter.spans().get(2); + MutableSpan resultSetSpan = spanReporter.spans().get(1); + MutableSpan statementSpan = spanReporter.spans().get(0); assertThat(connectionSpan.name()).isEqualTo("jdbc:/test/connection"); assertThat(statementSpan.name()).isEqualTo("jdbc:/test/query"); assertThat(resultSetSpan.name()).isEqualTo("jdbc:/test/fetch"); diff --git a/datasource-decorator-spring-boot-autoconfigure/src/test/java/com/github/gavlyukovskiy/cloud/sleuth/TracingQueryExecutionListenerTests.java b/datasource-decorator-spring-boot-autoconfigure/src/test/java/com/github/gavlyukovskiy/cloud/sleuth/TracingQueryExecutionListenerTests.java index 022a23c..c47a82d 100644 --- a/datasource-decorator-spring-boot-autoconfigure/src/test/java/com/github/gavlyukovskiy/cloud/sleuth/TracingQueryExecutionListenerTests.java +++ b/datasource-decorator-spring-boot-autoconfigure/src/test/java/com/github/gavlyukovskiy/cloud/sleuth/TracingQueryExecutionListenerTests.java @@ -17,24 +17,21 @@ package com.github.gavlyukovskiy.cloud.sleuth; +import brave.handler.MutableSpan; +import brave.test.TestSpanHandler; import com.github.gavlyukovskiy.boot.jdbc.decorator.DataSourceDecoratorAutoConfiguration; import com.github.gavlyukovskiy.boot.jdbc.decorator.HidePackagesClassLoader; -import com.github.gavlyukovskiy.boot.jdbc.decorator.dsproxy.ConnectionIdManagerProvider; import com.zaxxer.hikari.HikariDataSource; import net.ttddyy.dsproxy.ExecutionInfo; import net.ttddyy.dsproxy.QueryInfo; import net.ttddyy.dsproxy.listener.QueryExecutionListener; -import net.ttddyy.dsproxy.proxy.DefaultConnectionIdManager; import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.AutoConfigurations; 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.util.ArrayListSpanReporter; +import org.springframework.cloud.sleuth.autoconfig.brave.BraveAutoConfiguration; import org.springframework.context.annotation.Bean; -import zipkin2.Span; import javax.sql.DataSource; import java.sql.Connection; @@ -56,10 +53,9 @@ class TracingQueryExecutionListenerTests { .withConfiguration(AutoConfigurations.of( DataSourceAutoConfiguration.class, DataSourceDecoratorAutoConfiguration.class, - TraceAutoConfiguration.class, - SleuthLogAutoConfiguration.class, + BraveAutoConfiguration.class, SleuthListenerAutoConfiguration.class, - SavingSpanReporterConfiguration.class, + TestSpanHandlerConfiguration.class, PropertyPlaceholderAutoConfiguration.class )) .withPropertyValues("spring.datasource.initialization-mode=never", @@ -71,15 +67,15 @@ class TracingQueryExecutionListenerTests { void testShouldAddSpanForConnection() { contextRunner.run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); connection.commit(); connection.rollback(); connection.close(); - assertThat(spanReporter.getSpans()).hasSize(1); - Span connectionSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(1); + MutableSpan connectionSpan = spanReporter.spans().get(0); assertThat(connectionSpan.name()).isEqualTo("jdbc:/test/connection"); assertThat(connectionSpan.annotations()).extracting("value").contains("commit"); assertThat(connectionSpan.annotations()).extracting("value").contains("rollback"); @@ -90,15 +86,15 @@ void testShouldAddSpanForConnection() { void testShouldAddSpanForPreparedStatementExecute() { contextRunner.run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); connection.prepareStatement("SELECT NOW()").execute(); connection.close(); - assertThat(spanReporter.getSpans()).hasSize(2); - Span connectionSpan = spanReporter.getSpans().get(1); - Span statementSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(2); + MutableSpan connectionSpan = spanReporter.spans().get(1); + MutableSpan statementSpan = spanReporter.spans().get(0); assertThat(connectionSpan.name()).isEqualTo("jdbc:/test/connection"); assertThat(statementSpan.name()).isEqualTo("jdbc:/test/query"); assertThat(statementSpan.tags()).containsEntry(SleuthListenerAutoConfiguration.SPAN_SQL_QUERY_TAG_NAME, "SELECT NOW()"); @@ -109,15 +105,15 @@ void testShouldAddSpanForPreparedStatementExecute() { void testShouldAddSpanForPreparedStatementExecuteUpdate() { contextRunner.run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); connection.prepareStatement("UPDATE INFORMATION_SCHEMA.TABLES SET table_Name = '' WHERE 0 = 1").executeUpdate(); connection.close(); - assertThat(spanReporter.getSpans()).hasSize(2); - Span connectionSpan = spanReporter.getSpans().get(1); - Span statementSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(2); + MutableSpan connectionSpan = spanReporter.spans().get(1); + MutableSpan statementSpan = spanReporter.spans().get(0); assertThat(connectionSpan.name()).isEqualTo("jdbc:/test/connection"); assertThat(statementSpan.name()).isEqualTo("jdbc:/test/query"); assertThat(statementSpan.tags()).containsEntry(SleuthListenerAutoConfiguration.SPAN_SQL_QUERY_TAG_NAME, @@ -130,15 +126,15 @@ void testShouldAddSpanForPreparedStatementExecuteUpdate() { void testShouldAddSpanForStatementExecuteUpdate() { contextRunner.run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); connection.createStatement().executeUpdate("UPDATE INFORMATION_SCHEMA.TABLES SET table_Name = '' WHERE 0 = 1"); connection.close(); - assertThat(spanReporter.getSpans()).hasSize(2); - Span connectionSpan = spanReporter.getSpans().get(1); - Span statementSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(2); + MutableSpan connectionSpan = spanReporter.spans().get(1); + MutableSpan statementSpan = spanReporter.spans().get(0); assertThat(connectionSpan.name()).isEqualTo("jdbc:/test/connection"); assertThat(statementSpan.name()).isEqualTo("jdbc:/test/query"); assertThat(statementSpan.tags()).containsEntry(SleuthListenerAutoConfiguration.SPAN_SQL_QUERY_TAG_NAME, @@ -150,7 +146,7 @@ void testShouldAddSpanForStatementExecuteUpdate() { void testShouldAddSpanForPreparedStatementExecuteQueryIncludingTimeToCloseResultSet() { contextRunner.run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); ResultSet resultSet = connection.prepareStatement("SELECT NOW() UNION ALL SELECT NOW()").executeQuery(); @@ -159,10 +155,10 @@ void testShouldAddSpanForPreparedStatementExecuteQueryIncludingTimeToCloseResult resultSet.close(); connection.close(); - assertThat(spanReporter.getSpans()).hasSize(3); - Span connectionSpan = spanReporter.getSpans().get(2); - Span resultSetSpan = spanReporter.getSpans().get(1); - Span statementSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(3); + MutableSpan connectionSpan = spanReporter.spans().get(2); + MutableSpan resultSetSpan = spanReporter.spans().get(1); + MutableSpan statementSpan = spanReporter.spans().get(0); assertThat(connectionSpan.name()).isEqualTo("jdbc:/test/connection"); assertThat(statementSpan.name()).isEqualTo("jdbc:/test/query"); assertThat(resultSetSpan.name()).isEqualTo("jdbc:/test/fetch"); @@ -174,7 +170,7 @@ void testShouldAddSpanForPreparedStatementExecuteQueryIncludingTimeToCloseResult void testShouldAddSpanForStatementAndResultSet() { contextRunner.run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); ResultSet resultSet = connection.createStatement().executeQuery("SELECT NOW()"); @@ -183,10 +179,10 @@ void testShouldAddSpanForStatementAndResultSet() { resultSet.close(); connection.close(); - assertThat(spanReporter.getSpans()).hasSize(3); - Span connectionSpan = spanReporter.getSpans().get(2); - Span resultSetSpan = spanReporter.getSpans().get(1); - Span statementSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(3); + MutableSpan connectionSpan = spanReporter.spans().get(2); + MutableSpan resultSetSpan = spanReporter.spans().get(1); + MutableSpan statementSpan = spanReporter.spans().get(0); assertThat(connectionSpan.name()).isEqualTo("jdbc:/test/connection"); assertThat(statementSpan.name()).isEqualTo("jdbc:/test/query"); assertThat(resultSetSpan.name()).isEqualTo("jdbc:/test/fetch"); @@ -198,7 +194,7 @@ void testShouldAddSpanForStatementAndResultSet() { void testShouldNotFailWhenStatementIsClosedWihoutResultSet() { contextRunner.run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); Statement statement = connection.createStatement(); @@ -207,10 +203,10 @@ void testShouldNotFailWhenStatementIsClosedWihoutResultSet() { statement.close(); connection.close(); - assertThat(spanReporter.getSpans()).hasSize(3); - Span connectionSpan = spanReporter.getSpans().get(2); - Span resultSetSpan = spanReporter.getSpans().get(1); - Span statementSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(3); + MutableSpan connectionSpan = spanReporter.spans().get(2); + MutableSpan resultSetSpan = spanReporter.spans().get(1); + MutableSpan statementSpan = spanReporter.spans().get(0); assertThat(connectionSpan.name()).isEqualTo("jdbc:/test/connection"); assertThat(statementSpan.name()).isEqualTo("jdbc:/test/query"); assertThat(resultSetSpan.name()).isEqualTo("jdbc:/test/fetch"); @@ -222,7 +218,7 @@ void testShouldNotFailWhenStatementIsClosedWihoutResultSet() { void testShouldNotFailWhenConnectionIsClosedWihoutResultSet() { contextRunner.run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); Statement statement = connection.createStatement(); @@ -230,10 +226,10 @@ void testShouldNotFailWhenConnectionIsClosedWihoutResultSet() { resultSet.next(); connection.close(); - assertThat(spanReporter.getSpans()).hasSize(3); - Span connectionSpan = spanReporter.getSpans().get(2); - Span resultSetSpan = spanReporter.getSpans().get(1); - Span statementSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(3); + MutableSpan connectionSpan = spanReporter.spans().get(2); + MutableSpan resultSetSpan = spanReporter.spans().get(1); + MutableSpan statementSpan = spanReporter.spans().get(0); assertThat(connectionSpan.name()).isEqualTo("jdbc:/test/connection"); assertThat(statementSpan.name()).isEqualTo("jdbc:/test/query"); assertThat(resultSetSpan.name()).isEqualTo("jdbc:/test/fetch"); @@ -245,7 +241,7 @@ void testShouldNotFailWhenConnectionIsClosedWihoutResultSet() { void testShouldNotFailWhenResultSetNextWasNotCalled() { contextRunner.run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); Statement statement = connection.createStatement(); @@ -255,10 +251,10 @@ void testShouldNotFailWhenResultSetNextWasNotCalled() { statement.close(); connection.close(); - assertThat(spanReporter.getSpans()).hasSize(3); - Span connectionSpan = spanReporter.getSpans().get(2); - Span resultSetSpan = spanReporter.getSpans().get(1); - Span statementSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(3); + MutableSpan connectionSpan = spanReporter.spans().get(2); + MutableSpan resultSetSpan = spanReporter.spans().get(1); + MutableSpan statementSpan = spanReporter.spans().get(0); assertThat(connectionSpan.name()).isEqualTo("jdbc:/test/connection"); assertThat(statementSpan.name()).isEqualTo("jdbc:/test/query"); assertThat(resultSetSpan.name()).isEqualTo("jdbc:/test/fetch"); @@ -270,7 +266,7 @@ void testShouldNotFailWhenResultSetNextWasNotCalled() { void testShouldNotFailWhenResourceIsAlreadyClosed() { contextRunner.run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); Statement statement = connection.createStatement(); @@ -283,10 +279,10 @@ void testShouldNotFailWhenResourceIsAlreadyClosed() { connection.close(); connection.close(); - assertThat(spanReporter.getSpans()).hasSize(3); - Span connectionSpan = spanReporter.getSpans().get(2); - Span resultSetSpan = spanReporter.getSpans().get(1); - Span statementSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(3); + MutableSpan connectionSpan = spanReporter.spans().get(2); + MutableSpan resultSetSpan = spanReporter.spans().get(1); + MutableSpan statementSpan = spanReporter.spans().get(0); assertThat(connectionSpan.name()).isEqualTo("jdbc:/test/connection"); assertThat(statementSpan.name()).isEqualTo("jdbc:/test/query"); assertThat(resultSetSpan.name()).isEqualTo("jdbc:/test/fetch"); @@ -352,16 +348,16 @@ void testShouldNotFailWhenResourceIsAlreadyClosed4() { void testShouldNotFailToCloseSpanForTwoConsecutiveConnections() { contextRunner.run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection1 = dataSource.getConnection(); Connection connection2 = dataSource.getConnection(); connection1.close(); connection2.close(); - assertThat(spanReporter.getSpans()).hasSize(2); - Span connection1Span = spanReporter.getSpans().get(0); - Span connection2Span = spanReporter.getSpans().get(1); + assertThat(spanReporter.spans()).hasSize(2); + MutableSpan connection1Span = spanReporter.spans().get(0); + MutableSpan connection2Span = spanReporter.spans().get(1); assertThat(connection1Span.name()).isEqualTo("jdbc:/test/connection"); assertThat(connection2Span.name()).isEqualTo("jdbc:/test/connection"); }); @@ -371,7 +367,7 @@ void testShouldNotFailToCloseSpanForTwoConsecutiveConnections() { void testShouldNotFailWhenClosedInReversedOrder() { contextRunner.run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); Statement statement = connection.createStatement(); @@ -381,10 +377,10 @@ void testShouldNotFailWhenClosedInReversedOrder() { statement.close(); resultSet.close(); - assertThat(spanReporter.getSpans()).hasSize(3); - Span connectionSpan = spanReporter.getSpans().get(2); - Span resultSetSpan = spanReporter.getSpans().get(1); - Span statementSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(3); + MutableSpan connectionSpan = spanReporter.spans().get(2); + MutableSpan resultSetSpan = spanReporter.spans().get(1); + MutableSpan statementSpan = spanReporter.spans().get(0); assertThat(connectionSpan.name()).isEqualTo("jdbc:/test/connection"); assertThat(statementSpan.name()).isEqualTo("jdbc:/test/query"); assertThat(resultSetSpan.name()).isEqualTo("jdbc:/test/fetch"); @@ -418,7 +414,7 @@ void testShouldNotCauseMemoryLeak() { void testShouldIncludeOnlyConnectionTraces() { contextRunner.withPropertyValues("decorator.datasource.sleuth.include: connection").run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); Statement statement = connection.createStatement(); @@ -428,8 +424,8 @@ void testShouldIncludeOnlyConnectionTraces() { statement.close(); connection.close(); - assertThat(spanReporter.getSpans()).hasSize(1); - Span connectionSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(1); + MutableSpan connectionSpan = spanReporter.spans().get(0); assertThat(connectionSpan.name()).isEqualTo("jdbc:/test/connection"); }); } @@ -438,7 +434,7 @@ void testShouldIncludeOnlyConnectionTraces() { void testShouldIncludeOnlyQueryTraces() { contextRunner.withPropertyValues("decorator.datasource.sleuth.include: query").run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); Statement statement = connection.createStatement(); @@ -448,8 +444,8 @@ void testShouldIncludeOnlyQueryTraces() { statement.close(); connection.close(); - assertThat(spanReporter.getSpans()).hasSize(1); - Span statementSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(1); + MutableSpan statementSpan = spanReporter.spans().get(0); assertThat(statementSpan.name()).isEqualTo("jdbc:/test/query"); }); } @@ -458,7 +454,7 @@ void testShouldIncludeOnlyQueryTraces() { void testShouldIncludeOnlyFetchTraces() { contextRunner.withPropertyValues("decorator.datasource.sleuth.include: fetch").run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); Statement statement = connection.createStatement(); @@ -468,8 +464,8 @@ void testShouldIncludeOnlyFetchTraces() { statement.close(); connection.close(); - assertThat(spanReporter.getSpans()).hasSize(1); - Span resultSetSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(1); + MutableSpan resultSetSpan = spanReporter.spans().get(0); assertThat(resultSetSpan.name()).isEqualTo("jdbc:/test/fetch"); }); } @@ -478,7 +474,7 @@ void testShouldIncludeOnlyFetchTraces() { void testShouldIncludeOnlyConnectionAndQueryTraces() { contextRunner.withPropertyValues("decorator.datasource.sleuth.include: connection, query").run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); Statement statement = connection.createStatement(); @@ -488,9 +484,9 @@ void testShouldIncludeOnlyConnectionAndQueryTraces() { statement.close(); connection.close(); - assertThat(spanReporter.getSpans()).hasSize(2); - Span connectionSpan = spanReporter.getSpans().get(1); - Span statementSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(2); + MutableSpan connectionSpan = spanReporter.spans().get(1); + MutableSpan statementSpan = spanReporter.spans().get(0); assertThat(connectionSpan.name()).isEqualTo("jdbc:/test/connection"); assertThat(statementSpan.name()).isEqualTo("jdbc:/test/query"); }); @@ -500,7 +496,7 @@ void testShouldIncludeOnlyConnectionAndQueryTraces() { void testShouldIncludeOnlyConnectionAndFetchTraces() { contextRunner.withPropertyValues("decorator.datasource.sleuth.include: connection, fetch").run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); Statement statement = connection.createStatement(); @@ -510,9 +506,9 @@ void testShouldIncludeOnlyConnectionAndFetchTraces() { statement.close(); connection.close(); - assertThat(spanReporter.getSpans()).hasSize(2); - Span connectionSpan = spanReporter.getSpans().get(1); - Span resultSetSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(2); + MutableSpan connectionSpan = spanReporter.spans().get(1); + MutableSpan resultSetSpan = spanReporter.spans().get(0); assertThat(connectionSpan.name()).isEqualTo("jdbc:/test/connection"); assertThat(resultSetSpan.name()).isEqualTo("jdbc:/test/fetch"); }); @@ -522,7 +518,7 @@ void testShouldIncludeOnlyConnectionAndFetchTraces() { void testShouldIncludeOnlyQueryAndFetchTraces() { contextRunner.withPropertyValues("decorator.datasource.sleuth.include: query, fetch").run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); Statement statement = connection.createStatement(); @@ -532,9 +528,9 @@ void testShouldIncludeOnlyQueryAndFetchTraces() { statement.close(); connection.close(); - assertThat(spanReporter.getSpans()).hasSize(2); - Span resultSetSpan = spanReporter.getSpans().get(1); - Span statementSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(2); + MutableSpan resultSetSpan = spanReporter.spans().get(1); + MutableSpan statementSpan = spanReporter.spans().get(0); assertThat(statementSpan.name()).isEqualTo("jdbc:/test/query"); assertThat(resultSetSpan.name()).isEqualTo("jdbc:/test/fetch"); }); @@ -544,7 +540,7 @@ void testShouldIncludeOnlyQueryAndFetchTraces() { void testShouldNotOverrideExceptionWhenConnectionWasClosedBeforeExecutingQuery() { contextRunner.run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT NOW()"); @@ -556,8 +552,8 @@ void testShouldNotOverrideExceptionWhenConnectionWasClosedBeforeExecutingQuery() catch (SQLException expected) { } - assertThat(spanReporter.getSpans()).hasSize(1); - Span connectionSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(1); + MutableSpan connectionSpan = spanReporter.spans().get(0); assertThat(connectionSpan.name()).isEqualTo("jdbc:/test/connection"); }); } @@ -566,7 +562,7 @@ void testShouldNotOverrideExceptionWhenConnectionWasClosedBeforeExecutingQuery() void testShouldNotOverrideExceptionWhenStatementWasClosedBeforeExecutingQuery() { contextRunner.run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT NOW()"); @@ -579,9 +575,9 @@ void testShouldNotOverrideExceptionWhenStatementWasClosedBeforeExecutingQuery() } connection.close(); - assertThat(spanReporter.getSpans()).hasSize(2); - Span connectionSpan = spanReporter.getSpans().get(1); - Span statementSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(2); + MutableSpan connectionSpan = spanReporter.spans().get(1); + MutableSpan statementSpan = spanReporter.spans().get(0); assertThat(connectionSpan.name()).isEqualTo("jdbc:/test/connection"); assertThat(statementSpan.name()).isEqualTo("jdbc:/test/query"); }); @@ -591,7 +587,7 @@ void testShouldNotOverrideExceptionWhenStatementWasClosedBeforeExecutingQuery() void testShouldNotOverrideExceptionWhenResultSetWasClosedBeforeNext() { contextRunner.run(context -> { DataSource dataSource = context.getBean(DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); Connection connection = dataSource.getConnection(); Statement statement = connection.createStatement(); @@ -606,10 +602,10 @@ void testShouldNotOverrideExceptionWhenResultSetWasClosedBeforeNext() { statement.close(); connection.close(); - assertThat(spanReporter.getSpans()).hasSize(3); - Span connectionSpan = spanReporter.getSpans().get(2); - Span resultSetSpan = spanReporter.getSpans().get(1); - Span statementSpan = spanReporter.getSpans().get(0); + assertThat(spanReporter.spans()).hasSize(3); + MutableSpan connectionSpan = spanReporter.spans().get(2); + MutableSpan resultSetSpan = spanReporter.spans().get(1); + MutableSpan statementSpan = spanReporter.spans().get(0); assertThat(connectionSpan.name()).isEqualTo("jdbc:/test/connection"); assertThat(statementSpan.name()).isEqualTo("jdbc:/test/query"); assertThat(resultSetSpan.name()).isEqualTo("jdbc:/test/fetch"); @@ -624,7 +620,7 @@ void testShouldNotFailWhenClosingConnectionFromDifferentDataSource() { contextRunner.run(context -> { DataSource dataSource1 = context.getBean("test1", DataSource.class); DataSource dataSource2 = context.getBean("test2", DataSource.class); - ArrayListSpanReporter spanReporter = context.getBean(ArrayListSpanReporter.class); + TestSpanHandler spanReporter = context.getBean(TestSpanHandler.class); dataSource1.getConnection().close(); dataSource2.getConnection().close(); diff --git a/samples/README.md b/samples/README.md index 29cff6c..982df5e 100644 --- a/samples/README.md +++ b/samples/README.md @@ -10,21 +10,20 @@ Run sample application on port 8081 with next endpoints: **P6Spy** ``` -gradlew :samples:p6spy-sample:bootRun +./gradlew :samples:p6spy-sample:bootRun ``` -add `-Pzipkin` if you have [Zipkin](https://github.com/openzipkin/zipkin) running on port 9411 - +add `--args='--spring.profiles.active=zipkin'` if you have [Zipkin](https://github.com/openzipkin/zipkin) running on port 9411 (e.g via `docker run -p 9411:9411 openzipkin/zipkin`) **Datasource Proxy** ``` -gradlew :samples:datasource-proxy-sample:bootRun +./gradlew :samples:datasource-proxy-sample:bootRun ``` -add `-Pzipkin` if you have [Zipkin](https://github.com/openzipkin/zipkin) running on port 9411 +add `--args='--spring.profiles.active=zipkin'` if you have [Zipkin](https://github.com/openzipkin/zipkin) running on port 9411 **FlexyPool** ``` -gradlew :samples:flexy-pool-sample:bootRun +./gradlew :samples:flexy-pool-sample:bootRun ``` diff --git a/samples/datasource-proxy-sample/build.gradle.kts b/samples/datasource-proxy-sample/build.gradle.kts index 574aa90..78078e1 100644 --- a/samples/datasource-proxy-sample/build.gradle.kts +++ b/samples/datasource-proxy-sample/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - id("org.springframework.boot").version("2.3.1.RELEASE") + id("org.springframework.boot").version("2.4.3") } repositories { @@ -21,32 +21,17 @@ dependencies { implementation("org.springframework.boot:spring-boot-starter-jdbc") implementation("org.springframework.boot:spring-boot-starter-aop") - implementation("org.springframework.cloud:spring-cloud-sleuth-core:2.2.3.RELEASE") - implementation("org.springframework.cloud:spring-cloud-sleuth-zipkin:2.2.3.RELEASE") + implementation("org.springframework.cloud:spring-cloud-starter-sleuth:3.0.1") + implementation("org.springframework.cloud:spring-cloud-sleuth-zipkin:3.0.1") implementation("com.h2database:h2") implementation("org.apache.commons:commons-io:1.3.2") testImplementation("org.springframework.boot:spring-boot-starter-test") - testImplementation("org.junit.jupiter:junit-jupiter:5.6.2") } tasks { - bootRun { - val args = args!! - if (project.hasProperty("zipkin")) { - args.add("--spring.zipkin.enabled=true") - args.add("--spring.sleuth.enabled=true") - } - if (project.hasProperty("args")) { - val userArgs = project.findProperty("args") as String - userArgs.split(" ").forEach { args.add(it) } - } - } - test { useJUnitPlatform() } } - - diff --git a/samples/datasource-proxy-sample/src/main/resources/application-zipkin.yml b/samples/datasource-proxy-sample/src/main/resources/application-zipkin.yml new file mode 100644 index 0000000..788c4bd --- /dev/null +++ b/samples/datasource-proxy-sample/src/main/resources/application-zipkin.yml @@ -0,0 +1,5 @@ +spring: + sleuth: + enabled: true + zipkin: + enabled: true diff --git a/samples/flexy-pool-sample/build.gradle.kts b/samples/flexy-pool-sample/build.gradle.kts index afcd3c5..ac48e2f 100644 --- a/samples/flexy-pool-sample/build.gradle.kts +++ b/samples/flexy-pool-sample/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - id("org.springframework.boot").version("2.3.1.RELEASE") + id("org.springframework.boot").version("2.4.3") } repositories { @@ -25,18 +25,9 @@ dependencies { implementation("org.apache.commons:commons-io:1.3.2") testImplementation("org.springframework.boot:spring-boot-starter-test") - testImplementation("org.junit.jupiter:junit-jupiter:5.6.2") } tasks { - bootRun { - val args = args!! - if (project.hasProperty("args")) { - val userArgs = project.findProperty("args") as String - userArgs.split(" ").forEach { args.add(it) } - } - } - test { useJUnitPlatform() } diff --git a/samples/p6spy-sample/build.gradle.kts b/samples/p6spy-sample/build.gradle.kts index b6b0507..4f9472f 100644 --- a/samples/p6spy-sample/build.gradle.kts +++ b/samples/p6spy-sample/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - id("org.springframework.boot").version("2.3.1.RELEASE") + id("org.springframework.boot").version("2.4.3") } repositories { @@ -21,32 +21,17 @@ dependencies { implementation("org.springframework.boot:spring-boot-starter-jdbc") implementation("org.springframework.boot:spring-boot-starter-aop") - implementation("org.springframework.cloud:spring-cloud-sleuth-core:2.2.3.RELEASE") - implementation("org.springframework.cloud:spring-cloud-sleuth-zipkin:2.2.3.RELEASE") + implementation("org.springframework.cloud:spring-cloud-starter-sleuth:3.0.1") + implementation("org.springframework.cloud:spring-cloud-sleuth-zipkin:3.0.1") implementation("com.h2database:h2") implementation("org.apache.commons:commons-io:1.3.2") testImplementation("org.springframework.boot:spring-boot-starter-test") - testImplementation("org.junit.jupiter:junit-jupiter:5.6.2") } tasks { - bootRun { - val args = args!! - if (project.hasProperty("zipkin")) { - args.add("--spring.zipkin.enabled=true") - args.add("--spring.sleuth.enabled=true") - } - if (project.hasProperty("args")) { - val userArgs = project.findProperty("args") as String - userArgs.split(" ").forEach { args.add(it) } - } - } - test { useJUnitPlatform() } } - - diff --git a/samples/p6spy-sample/src/main/resources/application-zipkin.yml b/samples/p6spy-sample/src/main/resources/application-zipkin.yml new file mode 100644 index 0000000..788c4bd --- /dev/null +++ b/samples/p6spy-sample/src/main/resources/application-zipkin.yml @@ -0,0 +1,5 @@ +spring: + sleuth: + enabled: true + zipkin: + enabled: true