locked
Using the CLR Profiler API to trace database calls RRS feed

  • Question

  • I've put together a basic profiler which I would like to extend to time db calls.  

    If possible I would also like to retrieve and log the stored procedure name or TSQL if generated by an ORM.

    I know this is possible, I've seen other profilers do it but I don't know where to start.  

    Can anyone point me in the right direction?


    Here to stay

    Wednesday, May 3, 2017 2:21 PM

All replies

  • I know I have seen this same question asked here before, but can't seem to find it. In short, yes, it comes down to using IL rewriting to instrument various sql methods to capture the desired information and pass it down to the profiler.

    Wednesday, May 3, 2017 10:08 PM
  • Thanks for your reply. 

    I will checkout the archived forums.  I was hoping for a bit more tbh, an example or resource.


    Here to stay

    Thursday, May 4, 2017 8:35 AM
  • Yeah, I was a bit pressed for time when I wrote that. Figured that a vague pointer might be better than nothing :)

    I think the question I remembered was Profiling ADO.NET calls - Connection String , Command and Execution Time

    The link to the object tracking article is dead now, but older versions are still alive.

    Thursday, May 4, 2017 10:14 PM
  • Thanks Cole, sorry for sounding like I was criticising your answer.  It was more frustration with the lack of resources I could find on the subject.

    I found a couple of articles on il rewriting, whilst not specific to ado.net etc might be useful for someone else.

    This is an old article, not sure if still relevant but im working through it.

    https://www.codeproject.com/Articles/17275/Really-Easy-Logging-using-IL-Rewriting-and-the-NET

    An article is referenced above but the link provided is out of date, so this is a cached version of the referenced article.

    http://www.cnblogs.com/WCFGROUP/p/5136703.html


    Here to stay


    Friday, May 5, 2017 1:52 PM
  • Hi Steves0,

    I am glad to know that you resolve the issue, and share the solution to us. please mark it as answer, it will be beneficial to other communities who have the similar issue.

    Best regards,

    Cole Wu


    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.

    Thursday, May 18, 2017 7:24 AM