Polish Micrometer tracing changes

See gh-32627
pull/32399/head
Johnny Lim 2 years ago committed by Andy Wilkinson
parent e4544c1785
commit 1032f8cc94

@ -236,7 +236,7 @@ public class BraveAutoConfiguration {
CorrelationScopeDecorator.Builder mdcCorrelationScopeDecoratorBuilder(
ObjectProvider<CorrelationScopeCustomizer> correlationScopeCustomizers) {
CorrelationScopeDecorator.Builder builder = MDCScopeDecorator.newBuilder();
correlationScopeCustomizers.forEach((customizer) -> customizer.customize(builder));
correlationScopeCustomizers.orderedStream().forEach((customizer) -> customizer.customize(builder));
return builder;
}

@ -166,7 +166,7 @@ public class TracingProperties {
public static class Propagation {
/**
* Tracing context propagation types.
* Tracing context propagation type.
*/
private PropagationType type = PropagationType.W3C;

@ -93,7 +93,7 @@ class BaggagePropagationIntegrationTests {
try (Tracer.SpanInScope scope2 = tracer.withSpan(null)) {
assertThatMdcContainsUnsetTraceId();
assertThat(MDC.get(COUNTRY_CODE)).isNullOrEmpty();
assertThat(MDC.get(COUNTRY_CODE)).isNull();
}
assertThat(MDC.get("traceId")).isEqualTo(span.context().traceId());
@ -103,7 +103,7 @@ class BaggagePropagationIntegrationTests {
span.end();
}
assertThatMdcContainsUnsetTraceId();
assertThat(MDC.get(COUNTRY_CODE)).isNullOrEmpty();
assertThat(MDC.get(COUNTRY_CODE)).isNull();
});
}

@ -171,8 +171,11 @@ class BraveAutoConfigurationTests {
@Test
void shouldSupplyW3CWithoutBaggageByDefaultIfBaggageDisabled() {
this.contextRunner.withPropertyValues("management.tracing.baggage.enabled=false")
.run((context) -> assertThat(context).hasSingleBean(W3CPropagation.class));
this.contextRunner.withPropertyValues("management.tracing.baggage.enabled=false").run((context) -> {
assertThat(context).hasBean("propagationFactory");
assertThat(context).hasSingleBean(W3CPropagation.class);
assertThat(context).doesNotHaveBean(BaggagePropagation.FactoryBuilder.class);
});
}
@Test
@ -181,6 +184,7 @@ class BraveAutoConfigurationTests {
"management.tracing.propagation.type=B3").run((context) -> {
assertThat(context).hasBean("propagationFactory");
assertThat(context.getBean(Factory.class).toString()).isEqualTo("B3Propagation");
assertThat(context).doesNotHaveBean(BaggagePropagation.FactoryBuilder.class);
});
}
@ -196,7 +200,7 @@ class BraveAutoConfigurationTests {
}
@Test
void shouldNotApplyCorrelationFieldsIfBaggageCorrelationEnabled() {
void shouldApplyCorrelationFieldsIfBaggageCorrelationEnabled() {
this.contextRunner.withPropertyValues("management.tracing.baggage.correlation.enabled=true",
"management.tracing.baggage.correlation.fields=alpha,bravo").run((context) -> {
ScopeDecorator scopeDecorator = context.getBean(ScopeDecorator.class);

@ -38,7 +38,6 @@ import io.opentelemetry.sdk.trace.samplers.Sampler;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.mockito.Answers;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.FilteredClassLoader;
@ -152,7 +151,7 @@ class OpenTelemetryAutoConfigurationTests {
}
@Test
void shouldNotSupplySlf4jBaggageEventListenerBaggageCorrelationDisabled() {
void shouldNotSupplySlf4jBaggageEventListenerWhenBaggageCorrelationDisabled() {
this.contextRunner.withPropertyValues("management.tracing.baggage.correlation.enabled=false")
.run((context) -> assertThat(context).doesNotHaveBean(Slf4JBaggageEventListener.class));
}
@ -192,16 +191,6 @@ class OpenTelemetryAutoConfigurationTests {
.run((context) -> assertThat(context).hasBean("w3cTextMapPropagatorWithoutBaggage"));
}
@Test
void shouldSupplyB3PropagationWithoutBaggageWhenBaggageDisabledAndB3PropagationEnabled() {
this.contextRunner.withPropertyValues("management.tracing.baggage.enabled=false",
"management.tracing.propagation.type=B3").run((context) -> {
assertThat(context).hasBean("b3TextMapPropagator");
assertThat(context).hasSingleBean(B3Propagator.class);
assertThat(context).doesNotHaveBean("w3cTextMapPropagatorWithoutBaggage");
});
}
@Configuration(proxyBeanMethods = false)
private static class CustomConfiguration {
@ -282,34 +271,4 @@ class OpenTelemetryAutoConfigurationTests {
}
@Configuration(proxyBeanMethods = false)
private static class OpenTelemetryConfiguration {
@Bean
OpenTelemetry openTelemetry() {
return mock(OpenTelemetry.class, Answers.RETURNS_MOCKS);
}
}
@Configuration(proxyBeanMethods = false)
private static class ContextPropagatorsConfiguration {
@Bean
ContextPropagators contextPropagators() {
return mock(ContextPropagators.class, Answers.RETURNS_MOCKS);
}
}
@Configuration(proxyBeanMethods = false)
private static class CustomFactoryConfiguration {
@Bean
TextMapPropagator customPropagationFactory() {
return mock(TextMapPropagator.class);
}
}
}

Loading…
Cancel
Save