|
|
|
@ -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,12 +61,17 @@ 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");
|
|
|
|
|
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,7 +90,10 @@ 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");
|
|
|
|
|
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");
|
|
|
|
|
|
|
|
|
@ -96,6 +105,7 @@ class BaggagePropagationIntegrationTests {
|
|
|
|
|
assertThat(MDC.get("traceId")).isEqualTo(span.context().traceId());
|
|
|
|
|
assertThat(MDC.get(COUNTRY_CODE)).isEqualTo("FO");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
finally {
|
|
|
|
|
span.end();
|
|
|
|
|
}
|
|
|
|
|