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-statsd")
optional("io.micrometer:micrometer-registry-wavefront")
optional("io.zipkin.reporter2:zipkin-reporter-brave")
optional("io.zipkin.reporter2:zipkin-sender-urlconnection")
optional("io.opentelemetry:opentelemetry-exporter-zipkin")
optional("io.opentelemetry:opentelemetry-exporter-otlp")

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

@ -24,6 +24,7 @@ import io.opentelemetry.sdk.logs.SdkLoggerProvider;
import io.opentelemetry.sdk.metrics.SdkMeterProvider;
import io.opentelemetry.sdk.resources.Resource;
import io.opentelemetry.sdk.trace.SdkTracerProvider;
import io.opentelemetry.semconv.ResourceAttributes;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfiguration;
@ -81,22 +82,20 @@ class OpenTelemetryAutoConfigurationTests {
}
@Test
@SuppressWarnings("deprecation")
void shouldApplySpringApplicationNameToResource() {
this.runner.withPropertyValues("spring.application.name=my-application").run((context) -> {
Resource resource = context.getBean(Resource.class);
assertThat(resource.getAttributes().asMap()).contains(entry(
io.opentelemetry.semconv.resource.attributes.ResourceAttributes.SERVICE_NAME, "my-application"));
assertThat(resource.getAttributes().asMap())
.contains(entry(ResourceAttributes.SERVICE_NAME, "my-application"));
});
}
@Test
@SuppressWarnings("deprecation")
void shouldFallbackToDefaultApplicationNameIfSpringApplicationNameIsNotSet() {
this.runner.run((context) -> {
Resource resource = context.getBean(Resource.class);
assertThat(resource.getAttributes().asMap()).contains(
entry(io.opentelemetry.semconv.resource.attributes.ResourceAttributes.SERVICE_NAME, "application"));
assertThat(resource.getAttributes().asMap())
.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.export.SpanExporter;
import io.opentelemetry.sdk.trace.samplers.Sampler;
import io.opentelemetry.semconv.ResourceAttributes;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
@ -169,7 +170,6 @@ class OpenTelemetryAutoConfigurationTests {
}
@Test
@SuppressWarnings("deprecation")
void shouldSetupDefaultResourceAttributes() {
this.contextRunner
.withConfiguration(
@ -182,9 +182,7 @@ class OpenTelemetryAutoConfigurationTests {
exporter.await(Duration.ofSeconds(10));
SpanData spanData = exporter.getExportedSpans().get(0);
Map<AttributeKey<?>, Object> expectedAttributes = Resource.getDefault()
.merge(Resource.create(
Attributes.of(io.opentelemetry.semconv.resource.attributes.ResourceAttributes.SERVICE_NAME,
"application")))
.merge(Resource.create(Attributes.of(ResourceAttributes.SERVICE_NAME, "application")))
.getAttributes()
.asMap();
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()
calendarName = "Tracing"
group("io.micrometer") {

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

Loading…
Cancel
Save