Skip to content

Commit 76ad931

Browse files
Refactoring modules to be consistent with Spring Boot (#1784)
# Modules * New modules: `spring-cloud-sleuth-autoconfigure`, `spring-cloud-sleuth-api`, `spring-cloud-sleuth-instrumentation` `spring-cloud-sleuth-core` removed and changed to `spring-cloud-sleuth-instrumentation` & `spring-cloud-sleuth-api` * Removed `spring-cloud-starter-sleuth-otel` To add OpenTelemetry support you need to add `spring-cloud-starter-sleuth` (adds Brave by default), exclude Brave and add `spring-cloud-sleuth-otel` dependency * Except for the tests, `spring-cloud-sleuth-autoconfigure` is the only module that can have access to `@Configuration`, `@ConfigurationProperties` classes. Tests have been added to ensure such separation. ## Package moving * `org.springframework.cloud.sleuth.api` -> `org.springframework.cloud.sleuth` * `org.springframework.cloud.sleuth.brave.autoconfig` -> `org.springframework.cloud.sleuth.autoconfig.brave` * `org.springframework.cloud.sleuth.otel.autoconfig` -> `org.springframework.cloud.sleuth.autoconfig.otel` * `org.springframework.cloud.sleuth` -> `org.springframework.cloud.sleuth` * Instrumentation: `org.springframework.cloud.sleuth.annotation` -> `org.springframework.cloud.sleuth.instrument.annotation` * All the autoconfiguration classes were moved under `org.springframework.cloud/sleuth.autoconfig` package ## Global class modifications * Any class registered as a bean is now public ## Classes * `RateLimitingSampler` constructor changed * Merged a lot of auto configuration classes into one (e.g. `BraveAutoConfiguration` now imports various other configurations) * Renamed `TraceBraveAutoConfiguration` to `BraveAutoConfiguration` * Renamed `TraceOtelAutoConfiguration` to `OtelAutoConfiguration` * Removed all `NoOp` implementations of the API
1 parent c81ee04 commit 76ad931

File tree

625 files changed

+9302
-5795
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

625 files changed

+9302
-5795
lines changed

README.adoc

+12-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,17 @@ Example of Sleuth with Brave tracer:
5454
<!--
5555
<dependency>
5656
<groupId>org.springframework.cloud</groupId>
57-
<artifactId>spring-cloud-starter-sleuth-otel</artifactId>
57+
<artifactId>spring-cloud-starter-sleuth</artifactId>
58+
<exclusions>
59+
<exclusion>
60+
<groupId>org.springframework.cloud</groupId>
61+
<artifactId>spring-cloud-sleuth-brave</artifactId>
62+
</exclusion>
63+
</exclusions>
64+
</dependency>
65+
<dependency>
66+
<groupId>org.springframework.cloud</groupId>
67+
<artifactId>spring-cloud-sleuth-otel</artifactId>
5868
</dependency>
5969
-->
6070
</dependencies>
@@ -81,7 +91,7 @@ being traced in the logs (notice the `0b6aaf642574edd3` ids).
8191

8292
[indent=0]
8393
----
84-
2020-10-21 12:01:16.285 INFO [,0b6aaf642574edd3,0b6aaf642574edd3,true] 289589 --- [nio-9000-exec-1] DemoController : Handling home!
94+
2020-10-21 12:01:16.285 INFO [,0b6aaf642574edd3,0b6aaf642574edd3,true] 289589 --- [nio-9000-exec-1] DemoController : Handling home!
8595
----
8696

8797
NOTE: Instead of logging the request in the handler explicitly, you could set `logging.level.org.springframework.web.servlet.DispatcherServlet=DEBUG`.

benchmarks/README.adoc

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ Just execute them from the root folder like this:
2424

2525
For JMH we're building a shaded JAR file that is next executed.
2626

27-
For JMeter we're running two applications, one with Sleuth, one without with Spring Boot
28-
Maven Plugin. Next a Maven JMeter plugin is executed that loads the `*.jmx` files, starts
29-
JMeter and prints out the results. At the end Spring Boot Maven Plugin stops the applications.
27+
For JMeter we're running two applications, one with Sleuth, one without with Spring Boot Maven Plugin.
28+
Next a Maven JMeter plugin is executed that loads the `*.jmx` files, starts JMeter and prints out the results.
29+
At the end Spring Boot Maven Plugin stops the applications.
3030

3131
=== What are we testing?
3232

benchmarks/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
</dependency>
7171
<dependency>
7272
<groupId>${project.groupId}</groupId>
73-
<artifactId>spring-cloud-starter-sleuth-otel</artifactId>
73+
<artifactId>spring-cloud-sleuth-otel</artifactId>
7474
</dependency>
7575
<dependency>
7676
<groupId>org.springframework.boot</groupId>

benchmarks/src/main/java/org/springframework/cloud/sleuth/benchmarks/app/mvc/SleuthBenchmarkingSpringApp.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@
3535
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
3636
import org.springframework.boot.web.servlet.context.ServletWebServerInitializedEvent;
3737
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
38+
import org.springframework.cloud.sleuth.Span;
39+
import org.springframework.cloud.sleuth.Tracer;
3840
import org.springframework.cloud.sleuth.annotation.ContinueSpan;
3941
import org.springframework.cloud.sleuth.annotation.NewSpan;
4042
import org.springframework.cloud.sleuth.annotation.SpanTag;
41-
import org.springframework.cloud.sleuth.api.Span;
42-
import org.springframework.cloud.sleuth.api.Tracer;
4343
import org.springframework.cloud.sleuth.instrument.web.SkipPatternProvider;
4444
import org.springframework.context.ApplicationListener;
4545
import org.springframework.context.annotation.Bean;

benchmarks/src/main/java/org/springframework/cloud/sleuth/benchmarks/app/stream/SleuthBenchmarkingStreamApplication.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ class SimpleFunction implements Function<String, String> {
148148

149149
@Override
150150
public String apply(String input) {
151-
// tracing works cause headers from the input message get propagated to the output message
151+
// tracing works cause headers from the input message get propagated to the output
152+
// message
152153
log.info("Hello from simple [{}]", input);
153154
return input.toUpperCase();
154155
}
@@ -185,7 +186,8 @@ public Message<String> apply(Message<String> input) {
185186
})).andThen(msg -> MessagingSleuthOperators.afterMessageHandled(this.beanFactory, msg, null))
186187
.andThen(msg -> MessagingSleuthOperators.handleOutputMessage(this.beanFactory, msg))
187188
.andThen(msg -> MessageBuilder.createMessage(msg.getPayload().toUpperCase(), msg.getHeaders()))
188-
.andThen(msg -> MessagingSleuthOperators.afterMessageHandled(this.beanFactory, msg, null)).apply(input));
189+
.andThen(msg -> MessagingSleuthOperators.afterMessageHandled(this.beanFactory, msg, null))
190+
.apply(input));
189191
}
190192

191193
}

benchmarks/src/main/java/org/springframework/cloud/sleuth/benchmarks/app/webflux/SleuthBenchmarkingSpringWebFluxApp.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import org.springframework.boot.builder.SpringApplicationBuilder;
3535
import org.springframework.boot.web.embedded.netty.NettyReactiveWebServerFactory;
3636
import org.springframework.boot.web.reactive.context.ReactiveWebServerInitializedEvent;
37-
import org.springframework.cloud.sleuth.api.TraceContext;
37+
import org.springframework.cloud.sleuth.TraceContext;
3838
import org.springframework.cloud.sleuth.instrument.web.SkipPatternProvider;
3939
import org.springframework.cloud.sleuth.instrument.web.WebFluxSleuthOperators;
4040
import org.springframework.context.ApplicationListener;

benchmarks/src/test/java/org/springframework/cloud/sleuth/benchmarks/jmh/SampleTests.java

+3
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,11 @@ private void run(BenchmarkContext.Instrumentation value) throws Exception {
7575
public static class BenchmarkContext {
7676

7777
volatile ConfigurableApplicationContext applicationContext;
78+
7879
volatile InputDestination input;
80+
7981
volatile OutputDestination output;
82+
8083
@Param
8184
private Instrumentation instrumentation;
8285

benchmarks/src/test/java/org/springframework/cloud/sleuth/benchmarks/jmh/TracerImplementation.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@
1616

1717
package org.springframework.cloud.sleuth.benchmarks.jmh;
1818

19-
import org.springframework.cloud.sleuth.brave.autoconfig.TraceBraveAutoConfiguration;
20-
import org.springframework.cloud.sleuth.otel.autoconfig.TraceOtelAutoConfiguration;
19+
import org.springframework.cloud.sleuth.autoconfig.brave.BraveAutoConfiguration;
20+
import org.springframework.cloud.sleuth.autoconfig.otel.OtelAutoConfiguration;
2121

2222
public enum TracerImplementation {
2323

24-
otel(TraceBraveAutoConfiguration.class.getCanonicalName()), brave(
25-
TraceOtelAutoConfiguration.class.getCanonicalName());
24+
otel(BraveAutoConfiguration.class.getCanonicalName()), brave(OtelAutoConfiguration.class.getCanonicalName());
2625

2726
private String key = "spring.autoconfigure.exclude";
2827

benchmarks/src/test/java/org/springframework/cloud/sleuth/benchmarks/jmh/bridge/BridgeTests.java

+5-15
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,11 @@
3232
import org.springframework.boot.SpringApplication;
3333
import org.springframework.boot.WebApplicationType;
3434
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
35-
import org.springframework.cloud.sleuth.api.Span;
36-
import org.springframework.cloud.sleuth.api.Tracer;
37-
import org.springframework.cloud.sleuth.autoconfig.TraceAutoConfiguration;
35+
import org.springframework.cloud.sleuth.Span;
36+
import org.springframework.cloud.sleuth.Tracer;
37+
import org.springframework.cloud.sleuth.autoconfig.brave.BraveAutoConfiguration;
38+
import org.springframework.cloud.sleuth.autoconfig.otel.OtelAutoConfiguration;
3839
import org.springframework.cloud.sleuth.benchmarks.jmh.TracerImplementation;
39-
import org.springframework.cloud.sleuth.brave.autoconfig.TraceBraveAutoConfiguration;
40-
import org.springframework.cloud.sleuth.brave.bridge.TraceBraveBridgeAutoConfiguation;
41-
import org.springframework.cloud.sleuth.brave.propagation.TraceBravePropagationAutoConfiguration;
42-
import org.springframework.cloud.sleuth.otel.autoconfig.TraceOtelAutoConfiguration;
43-
import org.springframework.cloud.sleuth.otel.bridge.TraceOtelBridgeAutoConfiguation;
44-
import org.springframework.cloud.sleuth.otel.log.TraceOtelLogAutoConfiguration;
45-
import org.springframework.cloud.sleuth.otel.propagation.TraceOtelPropagationAutoConfiguration;
4640
import org.springframework.context.ConfigurableApplicationContext;
4741
import org.springframework.context.annotation.Configuration;
4842

@@ -121,11 +115,7 @@ public void clean() {
121115
}
122116

123117
@Configuration(proxyBeanMethods = false)
124-
@ImportAutoConfiguration({ TraceAutoConfiguration.class, TraceBraveAutoConfiguration.class,
125-
TraceBraveBridgeAutoConfiguation.class, TraceBravePropagationAutoConfiguration.class,
126-
TraceOtelAutoConfiguration.class, TraceOtelBridgeAutoConfiguation.class,
127-
TraceOtelPropagationAutoConfiguration.class, TraceOtelLogAutoConfiguration.class,
128-
TraceOtelLogAutoConfiguration.class })
118+
@ImportAutoConfiguration({ BraveAutoConfiguration.class, OtelAutoConfiguration.class })
129119
static class TestConfiguration {
130120

131121
}

benchmarks/src/test/java/org/springframework/cloud/sleuth/benchmarks/jmh/mvc/StartupBenchmarkTests.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ public void withoutAnnotations(ApplicationState state) throws Exception {
5454

5555
@Benchmark
5656
public void withoutAsync(ApplicationState state) throws Exception {
57-
state.setExtraArgs("--spring.sleuth.async.enabled=false", "--spring.sleuth.annotation.enabled=false", state.tracerImplementation.property());
57+
state.setExtraArgs("--spring.sleuth.async.enabled=false", "--spring.sleuth.annotation.enabled=false",
58+
state.tracerImplementation.property());
5859
state.run();
5960
}
6061

@@ -68,7 +69,8 @@ public void withoutScheduled(ApplicationState state) throws Exception {
6869
@Benchmark
6970
public void withoutWeb(ApplicationState state) throws Exception {
7071
state.setExtraArgs("--spring.sleuth.web.enabled=false", "--spring.sleuth.scheduled.enabled=false",
71-
"--spring.sleuth.async.enabled=false", "--spring.sleuth.annotation.enabled=false", state.tracerImplementation.property());
72+
"--spring.sleuth.async.enabled=false", "--spring.sleuth.annotation.enabled=false",
73+
state.tracerImplementation.property());
7274
state.run();
7375
}
7476

benchmarks/src/test/java/org/springframework/cloud/sleuth/benchmarks/jmh/stream/MicroBenchmarkStreamTests.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ protected ConfigurableApplicationContext initContext() {
107107

108108
protected String[] runArgs() {
109109
List<String> strings = new ArrayList<>();
110-
strings.addAll(Arrays.asList("--spring.jmx.enabled=false",
111-
this.tracerImplementation.property(),
112-
"--spring.application.name=defaultTraceContextForStream" + instrumentation.name() + "_" + tracerImplementation.name()));
110+
strings.addAll(Arrays.asList("--spring.jmx.enabled=false", this.tracerImplementation.property(),
111+
"--spring.application.name=defaultTraceContextForStream" + instrumentation.name() + "_"
112+
+ tracerImplementation.name()));
113113
strings.addAll(instrumentation.entires.stream().map(s -> "--" + s).collect(Collectors.toList()));
114114
return strings.toArray(new String[0]);
115115
}

benchmarks/src/test/java/org/springframework/cloud/sleuth/benchmarks/jmh/webflux/MicroBenchmarkHttpTests.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ protected ConfigurableApplicationContext initContext() {
8282
}
8383

8484
protected String[] runArgs() {
85-
return new String[] { "--spring.jmx.enabled=false",
86-
tracerImplementation.property(),
87-
"--spring.application.name=defaultTraceContext" + instrumentation.name() + "_" + tracerImplementation.name(),
85+
return new String[] { "--spring.jmx.enabled=false", tracerImplementation.property(),
86+
"--spring.application.name=defaultTraceContext" + instrumentation.name() + "_"
87+
+ tracerImplementation.name(),
8888
"--" + instrumentation.key + "=" + instrumentation.value };
8989
}
9090

benchmarks/src/test/java/org/springframework/cloud/sleuth/benchmarks/jmh/webflux/SpringWebFluxBenchmarksTests.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public class SpringWebFluxBenchmarksTests {
6868
static final SpanHandler FAKE_SPAN_HANDLER = new SpanHandler() {
6969
// intentionally anonymous to prevent logging fallback on NOOP
7070
};
71+
7172
protected static TraceContext defaultTraceContext = TraceContext.newBuilder().traceIdHigh(333L).traceId(444L)
7273
.spanId(3).sampled(true).build();
7374

@@ -138,8 +139,8 @@ protected void postSetUp() {
138139
}
139140

140141
protected String[] runArgs() {
141-
return new String[] { "--spring.jmx.enabled=false", "--spring.application.name=defaultTraceContext", TracerImplementation.brave.toString(),
142-
"--spring.sleuth.enabled=true" };
142+
return new String[] { "--spring.jmx.enabled=false", "--spring.application.name=defaultTraceContext",
143+
TracerImplementation.brave.toString(), "--spring.sleuth.enabled=true" };
143144
}
144145

145146
@TearDown

benchmarks/src/test/java/org/springframework/cloud/sleuth/benchmarks/jmh/webflux/WithOutReactorSleuthSpringWebFluxBenchmarksTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ public static void main(String[] args) throws RunnerException {
4040
@Override
4141
protected String[] runArgs() {
4242
return new String[] { "--spring.jmx.enabled=false", "--spring.application.name=defaultTraceContext",
43-
TracerImplementation.brave.toString(),
44-
"--spring.sleuth.enabled=true", "--spring.sleuth.reactor.enabled=false"
43+
TracerImplementation.brave.toString(), "--spring.sleuth.enabled=true",
44+
"--spring.sleuth.reactor.enabled=false"
4545

4646
};
4747
}

benchmarks/src/test/java/org/springframework/cloud/sleuth/benchmarks/jmh/webflux/WithOutSleuthSpringWebFluxBenchmarksTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ public static void main(String[] args) throws RunnerException {
3939

4040
@Override
4141
protected String[] runArgs() {
42-
return new String[] { "--spring.jmx.enabled=false", "--spring.application.name=defaultTraceContext", TracerImplementation.brave.toString(),
43-
"--spring.sleuth.enabled=false" };
42+
return new String[] { "--spring.jmx.enabled=false", "--spring.application.name=defaultTraceContext",
43+
TracerImplementation.brave.toString(), "--spring.sleuth.enabled=false" };
4444
}
4545

4646
@Override

docs/pom.xml

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
~ See the License for the specific language governing permissions and
1515
~ limitations under the License.
1616
-->
17-
1817
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1918
xmlns="http://maven.apache.org/POM/4.0.0"
2019
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
@@ -41,7 +40,7 @@
4140
</dependency>
4241
<dependency>
4342
<groupId>${project.groupId}</groupId>
44-
<artifactId>spring-cloud-starter-sleuth-otel</artifactId>
43+
<artifactId>spring-cloud-sleuth-otel</artifactId>
4544
</dependency>
4645
<dependency>
4746
<groupId>${project.groupId}</groupId>

docs/src/main/asciidoc/README.adoc

+12-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,17 @@ Example of Sleuth with Brave tracer:
4747
<!--
4848
<dependency>
4949
<groupId>org.springframework.cloud</groupId>
50-
<artifactId>spring-cloud-starter-sleuth-otel</artifactId>
50+
<artifactId>spring-cloud-starter-sleuth</artifactId>
51+
<exclusions>
52+
<exclusion>
53+
<groupId>org.springframework.cloud</groupId>
54+
<artifactId>spring-cloud-sleuth-brave</artifactId>
55+
</exclusion>
56+
</exclusions>
57+
</dependency>
58+
<dependency>
59+
<groupId>org.springframework.cloud</groupId>
60+
<artifactId>spring-cloud-sleuth-otel</artifactId>
5161
</dependency>
5262
-->
5363
</dependencies>
@@ -74,7 +84,7 @@ being traced in the logs (notice the `0b6aaf642574edd3` ids).
7484

7585
[indent=0]
7686
----
77-
2020-10-21 12:01:16.285 INFO [,0b6aaf642574edd3,0b6aaf642574edd3,true] 289589 --- [nio-9000-exec-1] DemoController : Handling home!
87+
2020-10-21 12:01:16.285 INFO [,0b6aaf642574edd3,0b6aaf642574edd3,true] 289589 --- [nio-9000-exec-1] DemoController : Handling home!
7888
----
7989

8090
NOTE: Instead of logging the request in the handler explicitly, you could set `logging.level.org.springframework.web.servlet.DispatcherServlet=DEBUG`.

docs/src/main/asciidoc/_attributes.adoc

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
// project-specific attributes
1818
:core_path: {project-root}
1919
:docs_path: {project-root}/docs
20+
:autoconfig_path: {project-root}/spring-cloud-sleuth-autoconfigure
21+
:api_path: {project-root}/spring-cloud-sleuth-api
2022
:brave_path: {project-root}/spring-cloud-sleuth-brave
2123
:otel_path: {project-root}/spring-cloud-sleuth-otel
2224
:tests_path: {core_path}/tests

0 commit comments

Comments
 (0)