-
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] Incorrectly linked spans, incorrect durations when Coroutine Dispatchers are used #6502
Comments
cc @trask since I saw you looking a similar Kotlin / broken traces issue when I was spelunking through the issues, trying to find something similar. |
hi @andrewlouis93! since folks here are not primarily Kotlin devs, could you create a standalone repository with your repro, along with instructions how to build/run it from the command line? I think that would have the most luck of getting someone to try to dig in to see what's going on. |
@trask Done, here you go: https://github.com/andrewlouis93/otel-auto-sandbox Keep me posted if y'all run into issues running it - I don't anticipate any problems. |
@trask Just wanted to share something I found that may be helpful; The Apache Skywalking autoinstrumentation was also similarly broken with suspending code - see here (particularly the The fix was shipped as an optional plugin: apache/skywalking#4165 (comment); perhaps we can draw inspiration from their implementation principle |
@andrewlouis93 the way I see it there are 2 problems. Firstly using |
This would be brilliant, if this was intact - we would at least be able to build a reliable API. The link is interesting as well - thank you for sharing. I came across some other similar tracing specific abstractions as well. - manual tracing was still unreliable where I created this ticket because it did seem like it could be solved in the OTEL Java Agent so autoinstrumentation could actually work for coroutines based how Apache Skywalking patched their own Java Agent (I linked over here) But yes - at the very minimum if we could build a reliable tracing API, we'd have a path forwards. |
@laurit Hello, wondering if you were able to give it a stab at fixing |
I'm also interested to hear if there has been any traction on this? |
@andrewlouis93 sorry for the late reply. If I remember correctly after further testing I realized that there seemed to be a problem with |
Describe the bug
When using the Java Agent & annotation driven auto-instrumentation with Kotlin - and the Coroutine Dispatcher is used (to dispatch some Coroutines outside of the main thread); we see broken traces consistently. Here's how the traces appear to be broken:
Steps to reproduce
A minimal reproducible example below.
What did you expect to see?
breakingSpans
trace per run.fetchUpstreamResource
,usingIOPool
andblockingWork
in the same trace.What did you see instead?
breakingSpans
breakingSpans
->blockingWork
(surprisingly and not the focus of this post since this is not Dispatched work butblockingWork
's duration is also inaccurate)breakingSpans
->usingIOPool
(but duration ofusingIOPool
is inaccurate)fetchUpstreamResource
(but duration offetchUpstreamResource
is inaccurate)Some pictures below to see how this looks; but also see the the Logs all the way at the end.
What version are you using?
opentelemetry-javaagent - version: 1.15.0
Environment
Compiler: Azul (OpenJDK) 16.0.2
OS: MacOS Monterey
Additional context
The logs are quite interesting as well, and show the 3 traces being emitted:
The text was updated successfully, but these errors were encountered: