# Stack trace for async methods

**URL:** <https://discuss.elastic.co/t/stack-trace-for-async-methods/333846>\
**Category:** APM\
**Tags:** dotnet\
**Created:** [May 19, 2023, 7:00am UTC](https://discuss.elastic.co/t/stack-trace-for-async-methods/333846 "2023-05-19T07:00:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AbhijithCV](https://avatars.discourse-cdn.com/v4/letter/a/ed655f/32.png) [@AbhijithCV](https://discuss.elastic.co/u/AbhijithCV)\
**Post date:** [May 19, 2023, 7:00am UTC](https://discuss.elastic.co/t/stack-trace-for-async-methods/333846/1 "2023-05-19T07:00:49Z")

</div>

Hi,  
I am trying to figure out how to trace async methods for a particular transaction.  
Currently I am not able to get the stack traces for end-to-end flow of the transaction.  
Could you please help me understand how the agent keeps track of spans occurring in different threads?  
Is it possible that I can make changes in the agent code so as to get all the stack traces for an async flow which also include custom methods that only does simple business logic(no DB call or external API calls).

Please help me with this query, I have been looking for a solution for a long time.

Thank you  
Abhijith C V

---

<div class="post-metadata">

**Author:** ![Sylvain\_Juge](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sylvain_juge/32/55521_2.png) [@Sylvain\_Juge](https://discuss.elastic.co/u/Sylvain_Juge)\
**Post date:** [May 22, 2023, 1:07pm UTC](https://discuss.elastic.co/t/stack-trace-for-async-methods/333846/2 "2023-05-22T13:07:58Z")

</div>

Hi !

I think the implementation in dotnet is quite close to the Java instrumentation, with the difference that it's dotnet CLR and not Java bytecode that gets instrumented.

If you need to track custom code with async delegation, this would be a case where modifying your code and use a tracing API explicitly would be relevant, see [docs] for details ([Public API | APM .NET Agent Reference [1.x] | Elastic](https://www.elastic.co/guide/en/apm/agent/dotnet/current/public-api.html#api-tracer-api)).

(disclamer: I'm not an expert of the dotnet instrumentation technical details)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 12, 2023, 9:08am UTC](https://discuss.elastic.co/t/stack-trace-for-async-methods/333846/3 "2023-06-12T09:08:58Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
