Start building against Micrometer Tracing 1.2.0 snapshots

See gh-37704
pull/37640/head
Andy Wilkinson 1 year ago
parent 993ac9c16f
commit a630baf32a

@ -68,6 +68,7 @@ dependencies {
optional("io.micrometer:micrometer-registry-signalfx") optional("io.micrometer:micrometer-registry-signalfx")
optional("io.micrometer:micrometer-registry-statsd") optional("io.micrometer:micrometer-registry-statsd")
optional("io.micrometer:micrometer-registry-wavefront") optional("io.micrometer:micrometer-registry-wavefront")
optional("io.zipkin.reporter2:zipkin-reporter-brave")
optional("io.zipkin.reporter2:zipkin-sender-urlconnection") optional("io.zipkin.reporter2:zipkin-sender-urlconnection")
optional("io.opentelemetry:opentelemetry-exporter-zipkin") optional("io.opentelemetry:opentelemetry-exporter-zipkin")
optional("io.opentelemetry:opentelemetry-exporter-otlp") optional("io.opentelemetry:opentelemetry-exporter-otlp")

@ -17,6 +17,7 @@
package org.springframework.boot.actuate.autoconfigure.opentelemetry; package org.springframework.boot.actuate.autoconfigure.opentelemetry;
import io.opentelemetry.api.OpenTelemetry; import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.context.propagation.ContextPropagators; import io.opentelemetry.context.propagation.ContextPropagators;
import io.opentelemetry.sdk.OpenTelemetrySdk; import io.opentelemetry.sdk.OpenTelemetrySdk;
@ -52,6 +53,8 @@ public class OpenTelemetryAutoConfiguration {
*/ */
private static final String DEFAULT_APPLICATION_NAME = "application"; private static final String DEFAULT_APPLICATION_NAME = "application";
static final AttributeKey<String> ATTRIBUTE_KEY_SERVICE_NAME = AttributeKey.stringKey("service.name");
@Bean @Bean
@ConditionalOnMissingBean(OpenTelemetry.class) @ConditionalOnMissingBean(OpenTelemetry.class)
OpenTelemetrySdk openTelemetry(ObjectProvider<SdkTracerProvider> tracerProvider, OpenTelemetrySdk openTelemetry(ObjectProvider<SdkTracerProvider> tracerProvider,
@ -67,12 +70,10 @@ public class OpenTelemetryAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
@SuppressWarnings("deprecation")
Resource openTelemetryResource(Environment environment, OpenTelemetryProperties properties) { Resource openTelemetryResource(Environment environment, OpenTelemetryProperties properties) {
String applicationName = environment.getProperty("spring.application.name", DEFAULT_APPLICATION_NAME); String applicationName = environment.getProperty("spring.application.name", DEFAULT_APPLICATION_NAME);
return Resource.getDefault() return Resource.getDefault()
.merge(Resource.create(Attributes .merge(Resource.create(Attributes.of(ATTRIBUTE_KEY_SERVICE_NAME, applicationName)))
.of(io.opentelemetry.semconv.resource.attributes.ResourceAttributes.SERVICE_NAME, applicationName)))
.merge(toResource(properties)); .merge(toResource(properties));
} }

@ -24,6 +24,7 @@ import io.opentelemetry.sdk.logs.SdkLoggerProvider;
import io.opentelemetry.sdk.metrics.SdkMeterProvider; import io.opentelemetry.sdk.metrics.SdkMeterProvider;
import io.opentelemetry.sdk.resources.Resource; import io.opentelemetry.sdk.resources.Resource;
import io.opentelemetry.sdk.trace.SdkTracerProvider; import io.opentelemetry.sdk.trace.SdkTracerProvider;
import io.opentelemetry.semconv.ResourceAttributes;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfiguration;
@ -81,22 +82,20 @@ class OpenTelemetryAutoConfigurationTests {
} }
@Test @Test
@SuppressWarnings("deprecation")
void shouldApplySpringApplicationNameToResource() { void shouldApplySpringApplicationNameToResource() {
this.runner.withPropertyValues("spring.application.name=my-application").run((context) -> { this.runner.withPropertyValues("spring.application.name=my-application").run((context) -> {
Resource resource = context.getBean(Resource.class); Resource resource = context.getBean(Resource.class);
assertThat(resource.getAttributes().asMap()).contains(entry( assertThat(resource.getAttributes().asMap())
io.opentelemetry.semconv.resource.attributes.ResourceAttributes.SERVICE_NAME, "my-application")); .contains(entry(ResourceAttributes.SERVICE_NAME, "my-application"));
}); });
} }
@Test @Test
@SuppressWarnings("deprecation")
void shouldFallbackToDefaultApplicationNameIfSpringApplicationNameIsNotSet() { void shouldFallbackToDefaultApplicationNameIfSpringApplicationNameIsNotSet() {
this.runner.run((context) -> { this.runner.run((context) -> {
Resource resource = context.getBean(Resource.class); Resource resource = context.getBean(Resource.class);
assertThat(resource.getAttributes().asMap()).contains( assertThat(resource.getAttributes().asMap())
entry(io.opentelemetry.semconv.resource.attributes.ResourceAttributes.SERVICE_NAME, "application")); .contains(entry(ResourceAttributes.SERVICE_NAME, "application"));
}); });
} }

@ -50,6 +50,7 @@ import io.opentelemetry.sdk.trace.SpanProcessor;
import io.opentelemetry.sdk.trace.data.SpanData; import io.opentelemetry.sdk.trace.data.SpanData;
import io.opentelemetry.sdk.trace.export.SpanExporter; import io.opentelemetry.sdk.trace.export.SpanExporter;
import io.opentelemetry.sdk.trace.samplers.Sampler; import io.opentelemetry.sdk.trace.samplers.Sampler;
import io.opentelemetry.semconv.ResourceAttributes;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource; import org.junit.jupiter.params.provider.ValueSource;
@ -169,7 +170,6 @@ class OpenTelemetryAutoConfigurationTests {
} }
@Test @Test
@SuppressWarnings("deprecation")
void shouldSetupDefaultResourceAttributes() { void shouldSetupDefaultResourceAttributes() {
this.contextRunner this.contextRunner
.withConfiguration( .withConfiguration(
@ -182,9 +182,7 @@ class OpenTelemetryAutoConfigurationTests {
exporter.await(Duration.ofSeconds(10)); exporter.await(Duration.ofSeconds(10));
SpanData spanData = exporter.getExportedSpans().get(0); SpanData spanData = exporter.getExportedSpans().get(0);
Map<AttributeKey<?>, Object> expectedAttributes = Resource.getDefault() Map<AttributeKey<?>, Object> expectedAttributes = Resource.getDefault()
.merge(Resource.create( .merge(Resource.create(Attributes.of(ResourceAttributes.SERVICE_NAME, "application")))
Attributes.of(io.opentelemetry.semconv.resource.attributes.ResourceAttributes.SERVICE_NAME,
"application")))
.getAttributes() .getAttributes()
.asMap(); .asMap();
assertThat(spanData.getResource().getAttributes().asMap()).isEqualTo(expectedAttributes); assertThat(spanData.getResource().getAttributes().asMap()).isEqualTo(expectedAttributes);

@ -1011,7 +1011,7 @@ bom {
] ]
} }
} }
library("Micrometer Tracing", "1.2.0-M3") { library("Micrometer Tracing", "1.2.0-SNAPSHOT") {
considerSnapshots() considerSnapshots()
calendarName = "Tracing" calendarName = "Tracing"
group("io.micrometer") { group("io.micrometer") {

@ -24,6 +24,8 @@
<property name="regexp" value="true" /> <property name="regexp" value="true" />
<property name="illegalClasses" <property name="illegalClasses"
value="javax.annotation.PostConstruct, jakarta.annotation.PostConstruct"/> value="javax.annotation.PostConstruct, jakarta.annotation.PostConstruct"/>
<property name="illegalPkgs"
value="^io\.opentelemetry\.semconv.*"/>
</module> </module>
<module <module
name="com.puppycrawl.tools.checkstyle.checks.imports.ImportControlCheck"> name="com.puppycrawl.tools.checkstyle.checks.imports.ImportControlCheck">

Loading…
Cancel
Save