Question

I have been looking into using Extended Events in a full end-to-end tracing scenario. I am especially interested in the XEvent's activity id that helps follow event execution sequence for a given activity.

You will have guessed, my event session in SQL Server 2008 has the following option set:

TRACK_CAUSALITY = ON

My question to you is, when executing SQL queries from C# code (Linq, Entity Framework, etc...), is it possible to infer the activity id that will be traced by the extended events in SQL Server?

For instance, I would like to be able to propagate the CorrelationManager.ActivityId guid of my executing thread to SQL Server for XEvent tracing.

Many thanks

Was it helpful?

Solution

Extended Events doesn't track the activity_id for anything outside of SQL Server currently. TRACK_CAUSALITY is only for tracking what event in SQL Server lead to another event in SQL Server, for example a sql_statement_starting event would have a specific activity_id and seq number 1, then a subsequent file_read event would have the same activity_id and a seq of 2, a wait_info event for PAGEIOLATCH_SH would have the same activity_id and seq of 3, and so on until you got to sql_statement_completed with a final seq number for the activity_id. You find plenty of examples showing this on my blog posts about Extended Events:

http://sqlskills.com/blogs/jonathan/category/Extended-Events.aspx

If you dumped the data into the ETW target, you can merge it with an ETW trace of your application and draw loose correlations of the events based on occurence, but there is causality tracking between the two possible.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top