From 5a14ffd957594728a8c7a17c4f7c5d32e49f6702 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Fri, 5 Oct 2018 11:33:53 +0200 Subject: [PATCH] Return span id from a controller, not from a deferred result --- .../annotation/SleuthSpanCreatorAspectWebFluxTests.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/annotation/SleuthSpanCreatorAspectWebFluxTests.java b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/annotation/SleuthSpanCreatorAspectWebFluxTests.java index 4fb052e9a..012f8ae8d 100644 --- a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/annotation/SleuthSpanCreatorAspectWebFluxTests.java +++ b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/annotation/SleuthSpanCreatorAspectWebFluxTests.java @@ -323,23 +323,26 @@ public class SleuthSpanCreatorAspectWebFluxTests { @ContinueSpan public Mono continueSpanInTraceContext() { log.info("Continue"); - return Mono.defer(() -> Mono.just(tracer.currentSpan().context().spanId())); + Long span = tracer.currentSpan().context().spanId(); + return Mono.defer(() -> Mono.just(span)); } @NewSpan(name = "newSpanInTraceContext") public Mono newSpanInTraceContext() { log.info("New Span in Trace Context"); - return Mono.defer(() -> Mono.just(tracer.currentSpan().context().spanId())); + Long span = tracer.currentSpan().context().spanId(); + return Mono.defer(() -> Mono.just(span)); } @NewSpan(name = "newSpanInSubscriberContext") public Mono newSpanInSubscriberContext() { log.info("New Span in Subscriber Context"); + Long span = tracer.currentSpan().context().spanId(); return Mono.subscriberContext() .doOnSuccess( context -> log.info("New Span in deferred Trace Context")) .flatMap(context -> Mono.defer( - () -> Mono.just(tracer.currentSpan().context().spanId()))); + () -> Mono.just(span))); } }