question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Transactions aren't capturing async child spans

See original GitHub issue

Package + Version

  • @sentry/node

Version:

6.5.1

Description

const transaction = Sentry.startTransaction({
					op: encodedApiFunctionToRealName[finalPublicMethodName],
					name: encodedApiFunctionToRealName[finalPublicMethodName],
				});

				try {
					const result = await auth(accessToken);
transaction.finish();
}
})

In the above code, many mysql functions are running, but none of the spans are showing up in the log. I breakpointed inside @sentry/tracing/dist/integrations/mysql.js, and the problem seems to be this code is failing:

const parentSpan = scope?.getSpan();

getSpan() returns undefined.

The transaction logic doesn’t seem to be very ‘smart’, it’s not propagating the scope properly via the stack.

This is a big problem for our business, we want to switch to your product from Elastic APM but this makes that untenable.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
jpike88commented, Jun 9, 2021

Yeah weird. With elastic-apm-node I just had an init call, and a simple one liner in the block of interest, no need to finish it or call any weird methods:

apm.setTransactionName('blah');

I hope this lib can learn from the others and implement a simpler approach.

0reactions
AdriVanHoudtcommented, Jun 9, 2021

My guess would be that you need to do this for your ‘root’ transaction but startTransaction doesn’t know if it is the ‘root’ one so it can’t do it automatically. But no clue if that is actually the reason 😄 Glad it works now for you.

Since you’re switching you might run into https://github.com/getsentry/sentry-javascript/issues/3660 as well btw.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Guidelines for Performance Monitoring
The startChild method should respect the maxSpans limit, and once the limit is reached the SDK should not create new child spans for...
Read more >
Span in tracing::span - Rust - Docs.rs
Constructs a new Span as child of the given parent span, with the given ... use tracing::Instrument; async fn my_async_function() { let span...
Read more >
Distributed Tracing - Sentry Documentation
Because of the possibility of asynchronous processes, child transactions may outlive the transactions containing their parent spans, sometimes by many orders of ...
Read more >
Understand and use the distributed tracing UI
Distributed tracing reports on two types of data: transaction events and spans. When you select an attribute in the filter, the data type...
Read more >
Can jaeger be used to trace an end-to-end transaction with ...
I'm a newbie on Jaeger and would like to know if I could trace an end-to-end transaction with a parent span & child...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found