-
Notifications
You must be signed in to change notification settings - Fork 782
-
Notifications
You must be signed in to change notification settings - Fork 782
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Backfill test about reactor edge case #1570
Comments
We also need a test case for onNext code that might issue a cancel after its first element. #1572 (review) |
another note about empty source #1572 (comment) |
TODO: also make a test that shows if possible spans are not started until the mono representing the call is subscribed to. There was a bug around this recently. |
Scope decoration seems to be order dependent if using Project reactors recommended approach to blocking calls. It seems that everything below .subscribeOn(Schedulers.boundedElastic()) in the chain will have MDC decorated while for everything above it will be empty.
Since MDC eventually is decorated, I believe the context is passed correctly, it is just a question of when decoration is and when it should be triggered. |
related question about how to continue a trace in reactor. In this case, they are trying to do this.. Single<MyObject> methohThaCallAnotherRemoteService() {
return Single.fromCallable( () -> { ...
final ResponseEntity<MyObject> response = restTemplate.postForEntity...
return response.getBody();
})
.subscribeOn(Schedulers.io()); // to be run on separate threads / https://stackoverflow.com/questions/61659898/make-spring-sleuth-not-to-create-a-new-trace-id-span-for-new-thread |
@simonbasle @robotmrv can you review the various problems and give some advice maybe? we're getting killed in support about various continuity problems in reactive commands and since there are so many ways to do things, it might be nice to have a suggestion we can put into docs |
@adriancole that stackoverflow question is using RxJava |
With the spring.sleuth.baggage.remote-fields=test-key
spring.sleuth.reactor.instrumentation-type=manual code package com.example.demo;
import brave.baggage.BaggageField;
import brave.propagation.TraceContext;
import reactor.core.publisher.Mono;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.sleuth.instrument.web.WebFluxSleuthOperators;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.server.ServerWebExchange;
import static reactor.core.scheduler.Schedulers.boundedElastic;
@RestController
@SpringBootApplication
public class DemoApplication2 {
public static void main(String... args) {
SpringApplication.run(DemoApplication2.class, args);
}
@GetMapping("/test")
Mono<ResponseEntity<String>> test(ServerWebExchange exchange){
return Mono.fromSupplier(() -> getExtraField(exchange))
.subscribeOn(boundedElastic())
.map(ResponseEntity::ok);
}
private String getExtraField(ServerWebExchange exchange) {
TraceContext traceContext = WebFluxSleuthOperators.currentTraceContext(exchange);
String value = BaggageField.getByName(traceContext, "test-key").getValue(traceContext);
return value != null ? value : "no value for key";
}
} |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue. |
From #1562 (comment)
When you look at the
Flux
orMono
level, not theSubscriber
level, pipelines which end results appear empty are not that uncommon. Any reactive method that returns aMono<Void>
for instance...That said, Sleuth works by wrapping
Subscriber
s, which are the steps in one activation of the pipeline. The cases where such a step is empty are probably fewer. For instance, theSubscriber
generated byignoreElements()
, despite producing aFlux
that appears empty to the end consumer, still seesonNext()
calls from its source. It just doesn't propagate them. If there is another operator after that, itsSubscriber
will only see anonComplete()
.Another way of triggering this code path is by having an empty source:
Hope this helps improving the tests/understanding when
onComplete
might matter...It is probably true that the vast majority of
Subscriber
s will notonComplete()
without anonNext()
, but when one considers the whole sequence (ie. theFlux
orMono
) this cannot be considered an edge case. All MonThe text was updated successfully, but these errors were encountered: