-
Notifications
You must be signed in to change notification settings - Fork 879
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
Kotlin Coroutine Flow not tracked correctly if it emits more that 1 item and takes time #8812
Comments
@YuliaMittova |
@laurit , I tried the manual approach and mentioned it in this issue: https://github.com/open-telemetry/opentelemetry-java/issues/5543
and to use it you need to wrap every function call you want to be tracked the following way:
This approach needs lots of changes and makes code harder to read. |
@mateuszrzeszutek @laurit I have noticed that the PR above is not reviewed yet. What is the average time from the PR opened to merged? Do you think I can help somehow with it? |
That one particular PR is just super extra complex -- I'm planning to review it myself, but it might take me a while because it contains some really crazy arcane bytecode wizardry 🧙 |
Thank you so much! |
Describe the bug
This bug was originally created here: open-telemetry/opentelemetry-java#5543
Sample project is here: https://github.com/YuliaMittova/opentelemetry_issue_5543
Problem: If the function returns Flow containing more than one item, and this function takes time (like a typical DB operation), all spans will be broken: context propagation and measurement.
If you check the project above and try to fetch one student (there will be one item in the Flow without any delays), then the report will look correct:
But if you try to fetch all students (in this case, Flow will have several items with delays between them. Please check function StudentEntityRepositoryImpl.findAll for code), the report will be broken: spans will have wrong parents and not measured correctly:
Steps to reproduce
Create a project which will use coroutines Flow, and this flow will return more than one item with delays. The sample project is here: https://github.com/YuliaMittova/opentelemetry_issue_5543
What did you expect to see?
All spans have correct parents and are measured correctly (parents are not finishing before the children). Please check the picture below:
What did you see instead?
The report is broken: spans have incorrect parent, not measure correctly:
What version are you using?
Environment
Docker, locally
Additional context
Looks like not only I have this problem. I guess this issue might be related: #8659
The text was updated successfully, but these errors were encountered: