Skip to content

Incorrect exec time for child spans when using completable future in spring controller #7825

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

Closed
VasaviMadhurima opened this issue Oct 22, 2024 · 3 comments
Assignees
Labels
inst: spring Spring instrumentation
Milestone

Comments

@VasaviMadhurima
Copy link

Hi,

When diagnosing some performance issues, I noticed that the execution times for child spans in traces are incorrect for APIs that are implemented using Spring Async controller feature with Completable futures.

Here is a sample trace:
Image
Image

Take S3.HeadBucket child span for example - the waterfall view clearly shows that the exec time is 223ms. However, in the span summary we see that exec time is reported as 111ms (exactly half).

Below is a sample code to show how we use the Completable futures:

@GetMapping("/my-service-path")
public CompletableFuture<ResponseEntity<MyResponseObject>> getSomeInfo() {
    return CompletableFuture.supplyAsync(
        TracedSupplier.from(() -> {
            //internalServicelogic
         }),
    executorService
  );
}

Annoyances:

We extensively use Completable futures in spring controller for all our java services. Given this issue, the time spent charts incorrectly represent the time spent in the service v/s the downstream components. This defeats the purpose of using APM tracing to a large extent for us.

@VasaviMadhurima
Copy link
Author

I can confirm that if we remove the Completable future and make the API implementation synchronous, the exec times of child spans look alright.

@amarziali amarziali self-assigned this Apr 1, 2025
@amarziali amarziali added the inst: spring Spring instrumentation label Apr 1, 2025
@amarziali amarziali added this to the 1.48.0 milestone Apr 2, 2025
@amarziali
Copy link
Collaborator

👋 @VasaviMadhurima thanks for having opened that issue and sorry for the long wait. It should be fixed on 1.48.0 out early next week

Copy link
Contributor

github-actions bot commented Apr 9, 2025

🤖 This issue has been addressed in the latest release. Check full details in the Release Notes.

@github-actions github-actions bot closed this as completed Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inst: spring Spring instrumentation
Projects
None yet
Development

No branches or pull requests

2 participants