locked
Keeping track of Tasks Call Graph - .Net Profiling RRS feed

  • Question

  • In my .NET instrumentation profiler i am extending support to get the call graph of Tasks and threads (async operations).

    I had used threadstatic variables to differentiate between each transaction's data. Whereas in case of Tasks it wont work out. 

    How can i keep track of the data of asynchronous operations call graph.? Is there any way to identify if a method's execution is of a particular task or some async operation?


    Friday, January 5, 2018 12:07 PM

Answers

  • If you target .NET 4.6+ then you could replace your thread static field with AsyncLocal<T>, otherwise you could use the LogicalCallContext (not available in .NET Core).

    Other possibilities include checking Task.Id and Task.CurrentId, but I don't know how useful that would be to you if people start using non-Task-based async methods.

    • Marked as answer by Selva VS Wednesday, January 10, 2018 5:36 AM
    Saturday, January 6, 2018 2:39 AM

All replies

  • If you target .NET 4.6+ then you could replace your thread static field with AsyncLocal<T>, otherwise you could use the LogicalCallContext (not available in .NET Core).

    Other possibilities include checking Task.Id and Task.CurrentId, but I don't know how useful that would be to you if people start using non-Task-based async methods.

    • Marked as answer by Selva VS Wednesday, January 10, 2018 5:36 AM
    Saturday, January 6, 2018 2:39 AM
  • Hi Selva VS,

    For your question, you could try to use NDepend or SequenceViz.

    NDepend

    https://www.ndepend.com/Features/

    SequenceViz

    http://sequenceviz.codeplex.com/

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, January 10, 2018 1:21 AM