Skip to content

Commit e9172d9

Browse files
committed
Split spring-boot-micrometer-tracing into Brave and OpenTelemetry specific module
Closes gh-47953
1 parent a1aec94 commit e9172d9

File tree

84 files changed

+1067
-688
lines changed

Some content is hidden

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

84 files changed

+1067
-688
lines changed

configuration-metadata/spring-boot-configuration-metadata-changelog-generator/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ def dependenciesOf(String version) {
104104
"spring-boot-micrometer-metrics-test",
105105
"spring-boot-micrometer-observation",
106106
"spring-boot-micrometer-tracing",
107+
"spring-boot-micrometer-tracing-brave",
108+
"spring-boot-micrometer-tracing-opentelemetry",
107109
"spring-boot-micrometer-tracing-test",
108110
"spring-boot-mongodb",
109111
"spring-boot-mustache",

documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/actuator/tracing.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ Tracing with OpenTelemetry and reporting using OTLP requires the following depen
136136
* `io.micrometer:micrometer-tracing-bridge-otel` - bridges the Micrometer Observation API to OpenTelemetry.
137137
* `io.opentelemetry:opentelemetry-exporter-otlp` - reports traces to a collector that can accept OTLP.
138138

139-
Use the `management.otlp.tracing.*` configuration properties to configure reporting using OTLP.
139+
Use the `management.opentelemetry.tracing.export.otlp.*` configuration properties to configure reporting using OTLP.
140140

141-
NOTE: If you need to apply advanced customizations to OTLP span exporters, consider registering javadoc:org.springframework.boot.micrometer.tracing.autoconfigure.otlp.OtlpHttpSpanExporterBuilderCustomizer[] or javadoc:org.springframework.boot.micrometer.tracing.autoconfigure.otlp.OtlpGrpcSpanExporterBuilderCustomizer[] beans.
141+
NOTE: If you need to apply advanced customizations to OTLP span exporters, consider registering javadoc:org.springframework.boot.micrometer.tracing.opentelemetry.autoconfigure.otlp.OtlpHttpSpanExporterBuilderCustomizer[] or javadoc:org.springframework.boot.micrometer.tracing.opentelemetry.autoconfigure.otlp.OtlpGrpcSpanExporterBuilderCustomizer[] beans.
142142
These will be invoked before the creation of the `OtlpHttpSpanExporter` or `OtlpGrpcSpanExporter`.
143143
The customizers take precedence over anything applied by the auto-configuration.
144144

documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/features/dev-services.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ The following service connections are currently supported:
116116
| javadoc:org.springframework.boot.micrometer.metrics.autoconfigure.export.otlp.OtlpMetricsConnectionDetails[]
117117
| Containers named "otel/opentelemetry-collector-contrib", "grafana/otel-lgtm"
118118

119-
| javadoc:org.springframework.boot.micrometer.tracing.autoconfigure.otlp.OtlpTracingConnectionDetails[]
119+
| javadoc:org.springframework.boot.micrometer.tracing.opentelemetry.autoconfigure.otlp.OtlpTracingConnectionDetails[]
120120
| Containers named "otel/opentelemetry-collector-contrib", "grafana/otel-lgtm"
121121

122122
| javadoc:org.springframework.boot.pulsar.autoconfigure.PulsarConnectionDetails[]

documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/testcontainers.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ The following service connection factories are provided in the `spring-boot-test
161161
| javadoc:org.springframework.boot.micrometer.metrics.autoconfigure.export.otlp.OtlpMetricsConnectionDetails[]
162162
| Containers named "otel/opentelemetry-collector-contrib" or of type javadoc:org.testcontainers.grafana.LgtmStackContainer[]
163163

164-
| javadoc:org.springframework.boot.micrometer.tracing.autoconfigure.otlp.OtlpTracingConnectionDetails[]
164+
| javadoc:org.springframework.boot.micrometer.tracing.opentelemetry.autoconfigure.otlp.OtlpTracingConnectionDetails[]
165165
| Containers named "otel/opentelemetry-collector-contrib" or of type javadoc:org.testcontainers.grafana.LgtmStackContainer[]
166166

167167
| javadoc:org.springframework.boot.pulsar.autoconfigure.PulsarConnectionDetails[]

module/spring-boot-autoconfigure-classic-modules/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,12 @@ dependencies {
175175
api(project(":module:spring-boot-micrometer-tracing")) {
176176
transitive = false
177177
}
178+
api(project(":module:spring-boot-micrometer-tracing-brave")) {
179+
transitive = false
180+
}
181+
api(project(":module:spring-boot-micrometer-tracing-opentelemetry")) {
182+
transitive = false
183+
}
178184
api(project(":module:spring-boot-mongodb")) {
179185
transitive = false
180186
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright 2012-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the License);
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
plugins {
18+
id "java-library"
19+
id "org.springframework.boot.auto-configuration"
20+
id "org.springframework.boot.configuration-properties"
21+
id "org.springframework.boot.deployed"
22+
id "org.springframework.boot.docker-test"
23+
id "org.springframework.boot.optional-dependencies"
24+
}
25+
26+
description = "Spring Boot Tracing Brave"
27+
28+
dependencies {
29+
api(project(":core:spring-boot"))
30+
api(project(":module:spring-boot-micrometer-observation"))
31+
api(project(":module:spring-boot-micrometer-tracing"))
32+
api("io.micrometer:micrometer-tracing") {
33+
exclude(group: "aopalliance", module: "aopalliance")
34+
}
35+
optional(project(":core:spring-boot-autoconfigure"))
36+
optional(project(":module:spring-boot-zipkin"))
37+
optional("io.micrometer:micrometer-tracing-bridge-brave")
38+
optional("io.zipkin.reporter2:zipkin-reporter-brave")
39+
40+
testImplementation(project(":core:spring-boot-test"))
41+
testImplementation(project(":test-support:spring-boot-test-support"))
42+
testImplementation(project(":module:spring-boot-micrometer-metrics"))
43+
testImplementation("io.micrometer:micrometer-registry-prometheus")
44+
testImplementation("io.prometheus:prometheus-metrics-exposition-formats")
45+
46+
testRuntimeOnly("ch.qos.logback:logback-classic")
47+
}
48+
49+
tasks.named("compileTestJava") {
50+
options.nullability.checking = "tests"
51+
}
52+
53+
tasks.named("compileDockerTestJava") {
54+
options.nullability.checking = "tests"
55+
}
Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.micrometer.tracing.autoconfigure;
17+
package org.springframework.boot.micrometer.tracing.brave.autoconfigure;
1818

1919
import java.util.List;
2020

@@ -47,6 +47,9 @@
4747
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
4848
import org.springframework.boot.context.properties.EnableConfigurationProperties;
4949
import org.springframework.boot.context.properties.IncompatibleConfigurationException;
50+
import org.springframework.boot.micrometer.tracing.autoconfigure.MicrometerTracingAutoConfiguration;
51+
import org.springframework.boot.micrometer.tracing.autoconfigure.NoopTracerAutoConfiguration;
52+
import org.springframework.boot.micrometer.tracing.autoconfigure.TracingProperties;
5053
import org.springframework.boot.micrometer.tracing.autoconfigure.TracingProperties.Propagation.PropagationType;
5154
import org.springframework.context.annotation.Bean;
5255
import org.springframework.context.annotation.Import;
@@ -64,7 +67,7 @@
6467
*/
6568
@AutoConfiguration(before = { MicrometerTracingAutoConfiguration.class, NoopTracerAutoConfiguration.class })
6669
@ConditionalOnClass({ Tracer.class, BraveTracer.class })
67-
@EnableConfigurationProperties(TracingProperties.class)
70+
@EnableConfigurationProperties({ TracingProperties.class, BraveTracingProperties.class })
6871
@Import({ BravePropagationConfigurations.PropagationWithoutBaggage.class,
6972
BravePropagationConfigurations.PropagationWithBaggage.class,
7073
BravePropagationConfigurations.NoPropagation.class })
@@ -77,8 +80,11 @@ public final class BraveAutoConfiguration {
7780

7881
private final TracingProperties tracingProperties;
7982

80-
BraveAutoConfiguration(TracingProperties tracingProperties) {
83+
private final BraveTracingProperties braveTracingProperties;
84+
85+
BraveAutoConfiguration(TracingProperties tracingProperties, BraveTracingProperties braveTracingProperties) {
8186
this.tracingProperties = tracingProperties;
87+
this.braveTracingProperties = braveTracingProperties;
8288
}
8389

8490
@Bean
@@ -95,28 +101,28 @@ CompositeSpanHandler compositeSpanHandler(ObjectProvider<SpanExportingPredicate>
95101
Tracing braveTracing(Environment environment, List<SpanHandler> spanHandlers,
96102
List<TracingCustomizer> tracingCustomizers, CurrentTraceContext currentTraceContext,
97103
Factory propagationFactory, Sampler sampler) {
98-
if (this.tracingProperties.getBrave().isSpanJoiningSupported()) {
104+
if (this.braveTracingProperties.isSpanJoiningSupported()) {
99105
if (this.tracingProperties.getPropagation().getType() != null
100106
&& this.tracingProperties.getPropagation().getType().contains(PropagationType.W3C)) {
101107
throw new IncompatibleConfigurationException("management.tracing.propagation.type",
102-
"management.tracing.brave.span-joining-supported");
108+
"management.brave.tracing.span-joining-supported");
103109
}
104110
if (this.tracingProperties.getPropagation().getType() == null
105111
&& this.tracingProperties.getPropagation().getProduce().contains(PropagationType.W3C)) {
106112
throw new IncompatibleConfigurationException("management.tracing.propagation.produce",
107-
"management.tracing.brave.span-joining-supported");
113+
"management.brave.tracing.span-joining-supported");
108114
}
109115
if (this.tracingProperties.getPropagation().getType() == null
110116
&& this.tracingProperties.getPropagation().getConsume().contains(PropagationType.W3C)) {
111117
throw new IncompatibleConfigurationException("management.tracing.propagation.consume",
112-
"management.tracing.brave.span-joining-supported");
118+
"management.brave.tracing.span-joining-supported");
113119
}
114120
}
115121
String applicationName = environment.getProperty("spring.application.name", DEFAULT_APPLICATION_NAME);
116122
Builder builder = Tracing.newBuilder()
117123
.currentTraceContext(currentTraceContext)
118124
.traceId128Bit(true)
119-
.supportsJoin(this.tracingProperties.getBrave().isSpanJoiningSupported())
125+
.supportsJoin(this.braveTracingProperties.isSpanJoiningSupported())
120126
.propagationFactory(propagationFactory)
121127
.sampler(sampler)
122128
.localServiceName(applicationName);
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.micrometer.tracing.autoconfigure;
17+
package org.springframework.boot.micrometer.tracing.brave.autoconfigure;
1818

1919
import java.util.List;
2020

@@ -37,6 +37,8 @@
3737
import org.springframework.boot.autoconfigure.condition.ConditionalOnBooleanProperty;
3838
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
3939
import org.springframework.boot.context.properties.EnableConfigurationProperties;
40+
import org.springframework.boot.micrometer.tracing.autoconfigure.ConditionalOnEnabledTracingExport;
41+
import org.springframework.boot.micrometer.tracing.autoconfigure.TracingProperties;
4042
import org.springframework.boot.micrometer.tracing.autoconfigure.TracingProperties.Baggage.Correlation;
4143
import org.springframework.context.annotation.Bean;
4244
import org.springframework.context.annotation.Configuration;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright 2012-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.micrometer.tracing.brave.autoconfigure;
18+
19+
import org.springframework.boot.context.properties.ConfigurationProperties;
20+
21+
/**
22+
* Configuration properties for tracing with Brave.
23+
*
24+
* @author Moritz Halbritter
25+
* @since 4.0.0
26+
*/
27+
@ConfigurationProperties("management.brave.tracing")
28+
public class BraveTracingProperties {
29+
30+
/**
31+
* Whether the propagation type and tracing backend support sharing the span ID
32+
* between client and server spans. Requires B3 propagation and a compatible backend.
33+
*/
34+
private boolean spanJoiningSupported = false;
35+
36+
public boolean isSpanJoiningSupported() {
37+
return this.spanJoiningSupported;
38+
}
39+
40+
public void setSpanJoiningSupported(boolean spanJoiningSupported) {
41+
this.spanJoiningSupported = spanJoiningSupported;
42+
}
43+
44+
}
Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.micrometer.tracing.autoconfigure;
17+
package org.springframework.boot.micrometer.tracing.brave.autoconfigure;
1818

1919
import java.util.Collection;
2020
import java.util.Collections;
@@ -30,6 +30,7 @@
3030
import io.micrometer.tracing.brave.bridge.W3CPropagation;
3131
import org.jspecify.annotations.Nullable;
3232

33+
import org.springframework.boot.micrometer.tracing.autoconfigure.TracingProperties;
3334
import org.springframework.boot.micrometer.tracing.autoconfigure.TracingProperties.Propagation.PropagationType;
3435

3536
/**
@@ -118,11 +119,19 @@ static CompositePropagationFactory create(TracingProperties.Propagation properti
118119
static CompositePropagationFactory create(TracingProperties.Propagation properties,
119120
@Nullable BaggageManager baggageManager, @Nullable LocalBaggageFields localFields) {
120121
PropagationFactoryMapper mapper = new PropagationFactoryMapper(baggageManager, localFields);
121-
List<Factory> injectors = properties.getEffectiveProducedTypes().stream().map(mapper::map).toList();
122-
List<Factory> extractors = properties.getEffectiveConsumedTypes().stream().map(mapper::map).toList();
122+
List<Factory> injectors = getEffectiveProducedTypes(properties).stream().map(mapper::map).toList();
123+
List<Factory> extractors = getEffectiveConsumedTypes(properties).stream().map(mapper::map).toList();
123124
return new CompositePropagationFactory(injectors, extractors);
124125
}
125126

127+
private static List<PropagationType> getEffectiveConsumedTypes(TracingProperties.Propagation properties) {
128+
return (properties.getType() != null) ? properties.getType() : properties.getConsume();
129+
}
130+
131+
private static List<PropagationType> getEffectiveProducedTypes(TracingProperties.Propagation properties) {
132+
return (properties.getType() != null) ? properties.getType() : properties.getProduce();
133+
}
134+
126135
/**
127136
* Mapper used to create a {@link brave.propagation.Propagation.Factory Propagation
128137
* factory} from a {@link PropagationType}.

0 commit comments

Comments
 (0)