Polish "Upgrade to Micrometer Tracing 1.0.10"

See gh-37345
pull/37462/head
Stephane Nicoll 1 year ago
parent 11940f8fec
commit 7df79432eb

@ -18,6 +18,7 @@ package org.springframework.boot.actuate.autoconfigure.tracing;
import java.util.function.Supplier;
import io.micrometer.tracing.BaggageInScope;
import io.micrometer.tracing.BaggageManager;
import io.micrometer.tracing.Span;
import io.micrometer.tracing.Tracer;
@ -60,11 +61,16 @@ class BaggagePropagationIntegrationTests {
assertThatTracingContextIsInitialized(autoConfig);
try (Tracer.SpanInScope scope = tracer.withSpan(span.start())) {
BaggageManager baggageManager = context.getBean(BaggageManager.class);
baggageManager.createBaggage(COUNTRY_CODE).set(span.context(), "FO");
baggageManager.createBaggage(BUSINESS_PROCESS).set(span.context(), "ALM");
assertThat(MDC.get("traceId")).isEqualTo(span.context().traceId());
assertThat(MDC.get(COUNTRY_CODE)).isEqualTo("FO");
assertThat(MDC.get(BUSINESS_PROCESS)).isEqualTo("ALM");
try (BaggageInScope fo = baggageManager.createBaggage(COUNTRY_CODE)
.set(span.context(), "FO")
.makeCurrent();
BaggageInScope alm = baggageManager.createBaggage(BUSINESS_PROCESS)
.set(span.context(), "ALM")
.makeCurrent()) {
assertThat(MDC.get("traceId")).isEqualTo(span.context().traceId());
assertThat(MDC.get(COUNTRY_CODE)).isEqualTo("FO");
assertThat(MDC.get(BUSINESS_PROCESS)).isEqualTo("ALM");
}
}
finally {
span.end();
@ -84,17 +90,21 @@ class BaggagePropagationIntegrationTests {
Span span = createSpan(tracer);
assertThatTracingContextIsInitialized(autoConfig);
try (Tracer.SpanInScope scope = tracer.withSpan(span.start())) {
context.getBean(BaggageManager.class).createBaggage(COUNTRY_CODE).set(span.context(), "FO");
assertThat(MDC.get("traceId")).isEqualTo(span.context().traceId());
assertThat(MDC.get(COUNTRY_CODE)).isEqualTo("FO");
try (Tracer.SpanInScope scope2 = tracer.withSpan(null)) {
assertThatMdcContainsUnsetTraceId();
assertThat(MDC.get(COUNTRY_CODE)).isNull();
try (BaggageInScope fo = context.getBean(BaggageManager.class)
.createBaggage(COUNTRY_CODE)
.set(span.context(), "FO")
.makeCurrent()) {
assertThat(MDC.get("traceId")).isEqualTo(span.context().traceId());
assertThat(MDC.get(COUNTRY_CODE)).isEqualTo("FO");
try (Tracer.SpanInScope scope2 = tracer.withSpan(null)) {
assertThatMdcContainsUnsetTraceId();
assertThat(MDC.get(COUNTRY_CODE)).isNull();
}
assertThat(MDC.get("traceId")).isEqualTo(span.context().traceId());
assertThat(MDC.get(COUNTRY_CODE)).isEqualTo("FO");
}
assertThat(MDC.get("traceId")).isEqualTo(span.context().traceId());
assertThat(MDC.get(COUNTRY_CODE)).isEqualTo("FO");
}
finally {
span.end();

Loading…
Cancel
Save