Skip to content

Commit a630baf

Browse files
committed
Start building against Micrometer Tracing 1.2.0 snapshots
See gh-37704
1 parent 993ac9c commit a630baf

File tree

6 files changed

+15
-14
lines changed

6 files changed

+15
-14
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ dependencies {
6868
optional("io.micrometer:micrometer-registry-signalfx")
6969
optional("io.micrometer:micrometer-registry-statsd")
7070
optional("io.micrometer:micrometer-registry-wavefront")
71+
optional("io.zipkin.reporter2:zipkin-reporter-brave")
7172
optional("io.zipkin.reporter2:zipkin-sender-urlconnection")
7273
optional("io.opentelemetry:opentelemetry-exporter-zipkin")
7374
optional("io.opentelemetry:opentelemetry-exporter-otlp")

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/opentelemetry/OpenTelemetryAutoConfiguration.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.springframework.boot.actuate.autoconfigure.opentelemetry;
1818

1919
import io.opentelemetry.api.OpenTelemetry;
20+
import io.opentelemetry.api.common.AttributeKey;
2021
import io.opentelemetry.api.common.Attributes;
2122
import io.opentelemetry.context.propagation.ContextPropagators;
2223
import io.opentelemetry.sdk.OpenTelemetrySdk;
@@ -52,6 +53,8 @@ public class OpenTelemetryAutoConfiguration {
5253
*/
5354
private static final String DEFAULT_APPLICATION_NAME = "application";
5455

56+
static final AttributeKey<String> ATTRIBUTE_KEY_SERVICE_NAME = AttributeKey.stringKey("service.name");
57+
5558
@Bean
5659
@ConditionalOnMissingBean(OpenTelemetry.class)
5760
OpenTelemetrySdk openTelemetry(ObjectProvider<SdkTracerProvider> tracerProvider,
@@ -67,12 +70,10 @@ OpenTelemetrySdk openTelemetry(ObjectProvider<SdkTracerProvider> tracerProvider,
6770

6871
@Bean
6972
@ConditionalOnMissingBean
70-
@SuppressWarnings("deprecation")
7173
Resource openTelemetryResource(Environment environment, OpenTelemetryProperties properties) {
7274
String applicationName = environment.getProperty("spring.application.name", DEFAULT_APPLICATION_NAME);
7375
return Resource.getDefault()
74-
.merge(Resource.create(Attributes
75-
.of(io.opentelemetry.semconv.resource.attributes.ResourceAttributes.SERVICE_NAME, applicationName)))
76+
.merge(Resource.create(Attributes.of(ATTRIBUTE_KEY_SERVICE_NAME, applicationName)))
7677
.merge(toResource(properties));
7778
}
7879

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/opentelemetry/OpenTelemetryAutoConfigurationTests.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import io.opentelemetry.sdk.metrics.SdkMeterProvider;
2525
import io.opentelemetry.sdk.resources.Resource;
2626
import io.opentelemetry.sdk.trace.SdkTracerProvider;
27+
import io.opentelemetry.semconv.ResourceAttributes;
2728
import org.junit.jupiter.api.Test;
2829

2930
import org.springframework.boot.autoconfigure.AutoConfiguration;
@@ -81,22 +82,20 @@ void backsOffOnUserSuppliedBeans() {
8182
}
8283

8384
@Test
84-
@SuppressWarnings("deprecation")
8585
void shouldApplySpringApplicationNameToResource() {
8686
this.runner.withPropertyValues("spring.application.name=my-application").run((context) -> {
8787
Resource resource = context.getBean(Resource.class);
88-
assertThat(resource.getAttributes().asMap()).contains(entry(
89-
io.opentelemetry.semconv.resource.attributes.ResourceAttributes.SERVICE_NAME, "my-application"));
88+
assertThat(resource.getAttributes().asMap())
89+
.contains(entry(ResourceAttributes.SERVICE_NAME, "my-application"));
9090
});
9191
}
9292

9393
@Test
94-
@SuppressWarnings("deprecation")
9594
void shouldFallbackToDefaultApplicationNameIfSpringApplicationNameIsNotSet() {
9695
this.runner.run((context) -> {
9796
Resource resource = context.getBean(Resource.class);
98-
assertThat(resource.getAttributes().asMap()).contains(
99-
entry(io.opentelemetry.semconv.resource.attributes.ResourceAttributes.SERVICE_NAME, "application"));
97+
assertThat(resource.getAttributes().asMap())
98+
.contains(entry(ResourceAttributes.SERVICE_NAME, "application"));
10099
});
101100
}
102101

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/tracing/OpenTelemetryAutoConfigurationTests.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import io.opentelemetry.sdk.trace.data.SpanData;
5151
import io.opentelemetry.sdk.trace.export.SpanExporter;
5252
import io.opentelemetry.sdk.trace.samplers.Sampler;
53+
import io.opentelemetry.semconv.ResourceAttributes;
5354
import org.junit.jupiter.api.Test;
5455
import org.junit.jupiter.params.ParameterizedTest;
5556
import org.junit.jupiter.params.provider.ValueSource;
@@ -169,7 +170,6 @@ void shouldBackOffOnCustomBeans() {
169170
}
170171

171172
@Test
172-
@SuppressWarnings("deprecation")
173173
void shouldSetupDefaultResourceAttributes() {
174174
this.contextRunner
175175
.withConfiguration(
@@ -182,9 +182,7 @@ void shouldSetupDefaultResourceAttributes() {
182182
exporter.await(Duration.ofSeconds(10));
183183
SpanData spanData = exporter.getExportedSpans().get(0);
184184
Map<AttributeKey<?>, Object> expectedAttributes = Resource.getDefault()
185-
.merge(Resource.create(
186-
Attributes.of(io.opentelemetry.semconv.resource.attributes.ResourceAttributes.SERVICE_NAME,
187-
"application")))
185+
.merge(Resource.create(Attributes.of(ResourceAttributes.SERVICE_NAME, "application")))
188186
.getAttributes()
189187
.asMap();
190188
assertThat(spanData.getResource().getAttributes().asMap()).isEqualTo(expectedAttributes);

spring-boot-project/spring-boot-dependencies/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ bom {
10111011
]
10121012
}
10131013
}
1014-
library("Micrometer Tracing", "1.2.0-M3") {
1014+
library("Micrometer Tracing", "1.2.0-SNAPSHOT") {
10151015
considerSnapshots()
10161016
calendarName = "Tracing"
10171017
group("io.micrometer") {

src/checkstyle/checkstyle.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
<property name="regexp" value="true" />
2525
<property name="illegalClasses"
2626
value="javax.annotation.PostConstruct, jakarta.annotation.PostConstruct"/>
27+
<property name="illegalPkgs"
28+
value="^io\.opentelemetry\.semconv.*"/>
2729
</module>
2830
<module
2931
name="com.puppycrawl.tools.checkstyle.checks.imports.ImportControlCheck">

0 commit comments

Comments
 (0)