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:
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.