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

Unlinked span for mysql plugin when use Promise.all function #940

Closed
wdalmut opened this issue Apr 7, 2020 · 4 comments
Closed

Unlinked span for mysql plugin when use Promise.all function #940

wdalmut opened this issue Apr 7, 2020 · 4 comments
Labels
bug Something isn't working

Comments

@wdalmut
Copy link

wdalmut commented Apr 7, 2020

Please answer these questions before submitting a bug report.

What version of OpenTelemetry are you using?

0.6.0

What version of Node are you using?

v12.11.1

What did you do?

When i use a Promise.all function in combination with a traced function i will not found any query span in Jaeger but i found two completely separated spansI

Jaeger UI (2)

It is very simple to test, for example using knex over mysql

const span = provider.getTracer('default').startSpan('test span');   
provider.getTracer('default').withSpan(span, () => {
  Promise.all(knex('table').query(), knex('table').query()]).then(() => {
    span.end()

    // get all spans
   const spans = memoryExporter.getFinishedSpans()

   // get correctly 3 spans but spanContext.traceId is not aligned between those spans 
  })

What did you expect to see?

I am expecting that those two traces should be places under the main application span

What did you see instead?

I get totally separated spans

Additional context

I am trying this structure using a base express application (hello world + mysql using knex as query build)

@vmarchaud
Copy link
Member

Thats because you are using with which is only synchronous with async code (Promise.all). A PR is open at #926 to add a withAsync function that should solves your case

@Flarna
Copy link
Member

Flarna commented Apr 7, 2020

Could be also related to knex. As far as I know knex uses thenables and they are currently not supported by async-hooks/v8 PromiseHooks. see nodejs/node#22360

@wdalmut
Copy link
Author

wdalmut commented Apr 13, 2020

i can confirm that this issue is related to the "thenables" structure of Knex...

@itsjwala
Copy link

hey Folks, was there a workaround that could work here?

I see this issue closed, I'm still facing the issue of unlinked span with no parent

knex@3.0.1
opentelemetry-core@1.19.0

let me know if you need additional details.

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

No branches or pull requests

5 participants