Transactions aren't capturing async child spans
See original GitHub issue- Review the documentation: https://docs.sentry.io/
- Search for existing issues: https://github.com/getsentry/sentry-javascript/issues
- Use the latest release: https://github.com/getsentry/sentry-javascript/releases
- Provide a link to the affected event from your Sentry account
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:
- Created 2 years ago
- Comments:7
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
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.