/// <summary> /// Remove the correction Id at the end of the request /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <remarks>Worth noting that this method fires even when an exception occurs in the page (pretty cool!)</remarks> protected void RemoveRequestionInstrumentationCorrelation(object sender, EventArgs e) { GlobalApplicationTraceSource.Information("End Request" + CurrentRequest.RawUrl); //-- Note if StopLogicalOperation fails, there's something wrong with some code in between StartLogicalOperation //-- and here and we want it to throw an exception so we become aware and can debug the problem. Also never use Pop() //-- to get a correlationID because that removes the logical operation (causing an exception on this line). //-- Instead use Peak() try { Trace.CorrelationManager.StopLogicalOperation(); } catch { } }
/// <summary> /// Set the correction Id at the beginning of the request /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SetRequestionInstrumentationCorrelation(object sender, EventArgs e) { Trace.CorrelationManager.StartLogicalOperation(GenerateCorrelationReferenceString()); GlobalApplicationTraceSource.Information("Begin Request " + CurrentRequest.RawUrl); }