Determining the Relationships Between Events

   

Events such as function call and return, database query send and result, and transaction start and commit are related to each other because they show both the client and server interaction. Showing these relationships to the Visual Studio Analyzer user assists in analyzing performance and isolating faults. The CorrelationID and CausalityID event parameters contain strings that you can match so that the Visual Studio Analyzer user will see related events properly.

A typical function call and return scenario generates four events in the sequence shown in the following illustrated:

  1. The first event contains the event parameters and is generated just before a call to a function actually occurs.

  2. The second event, identical to the first except for the timestamp, is generated when the call arrives at the called function (this is the Enter event).

  3. The third event (Leave) is generated as the call leaves the called function.

  4. The fourth event is generated when the call returns, and contains the ReturnValue parameter.

Often you will have only the Call and Return events, not the Call, Enter, Leave, and Return events. If you do have all four events, you should provide the same CorrelationID value for all four of these events so that they can be matched. The Source and Target event parameters should be the same for both the call and return events: that is, if A calls B, and then B returns to A, the Source parameter is A in both cases, and the Target parameter is B.

If it is not feasible to provide identical CorrelationID values for all four events, then at a minimum you should provide the same CorrelationID value for the Enter/Leave event pair and for the Call/Return pair. If it is not feasible to provide identical CorrelationID values for even the Enter/Leave or Call/Return pairs, at minimum you should provide the events with identical CausalityID values.