Skip to content
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

Duration of request is wrong if method returns Mono (spring webflux controller) #4334

Closed
lmolkova opened this issue Oct 8, 2021 · 4 comments · Fixed by #4339
Closed

Duration of request is wrong if method returns Mono (spring webflux controller) #4334

lmolkova opened this issue Oct 8, 2021 · 4 comments · Fixed by #4339
Labels
bug Something isn't working

Comments

@lmolkova
Copy link
Contributor

lmolkova commented Oct 8, 2021

Describe the bug
When Spring WebFlux controller returns Mono, the span for request ends immediately, but deferred/delayed mono still runs.

Steps to reproduce
Create a simple weblux app, here's controller code, full example:
mono-duration-bug.zip

@RestController
@RequestMapping("/hello")
public class HelloController {

    @GetMapping("/messages")
    public Mono<ResponseEntity<String>> get() {
        return Mono.delay(Duration.ofMillis(100)).then(Mono.just(ResponseEntity.ok("Hello")));
    }
}

What did you expect to see?
duration of hello/messages is longer - span ends after deferred mono ends.

What did you see instead?
image

What version are you using?
opentelemetry-javaagent - version: 1.6.2

Environment
Compiler: AdoptOpenJDK 16.0.1
OS: win10

@lmolkova lmolkova added the bug Something isn't working label Oct 8, 2021
@lmolkova lmolkova changed the title Duration of request if wrong if method returns Mono (spring webflux controller) Duration of request is wrong if method returns Mono (spring webflux controller) Oct 8, 2021
@trask
Copy link
Member

trask commented Oct 10, 2021

on the downside, this looks like a regression introduced in 1.6.0

on the (small) upside, it only seems to be a problem when pulling in both spring-boot-starter-webflux and spring-boot-starter-web

EDIT: the duplicate HelloController.get seems to exist even before 1.6.0 (and is also only triggered when pulling in both starters)

EDIT: the regression appears to be from #4078

EDIT: the regression appears to be coming from the tomcat instrumentation (or at least disabling the tomcat instrumentation makes the regression issue go away)

@iNikem
Copy link
Contributor

iNikem commented Oct 11, 2021

Just to confirm, @lmolkova : do you want for Mono span to be a child of /hello/messages and a sibling of HelloControll.get controller span?

@lmolkova
Copy link
Contributor Author

@iNikem

Just to confirm, @lmolkova : do you want for Mono span to be a child of /hello/messages and a sibling of HelloControll.get controller span?

I expect controller span to be a child of Server of /hello/messages. I don't have a mono span. ​And I just realized that I have two controller spans on my screenshot, but as you can see, I don't have anything beyond auto-instrumentation.

In a more complicated example, where I noticed the issue, I have correct nesting, wrong duration and still 2 controller spans

image

@trask
Copy link
Member

trask commented Oct 12, 2021

I split out the duplicate controller span issue into #4360 so that I could mark PR #4339 as resolving this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants