/// <summary> /// Constructor used to initialize the class /// </summary> /// <param name="traceSource">The source that we are tracing through as part of this scope</param> /// <param name="activityName">The name of the activity that this scope represents</param> public TraceTransferScope(TraceSource traceSource, string activityName) { if (traceSource == null) { throw new ArgumentNullException("traceSource"); } if (string.IsNullOrEmpty(activityName)) { throw new ArgumentNullException("activityName"); } _traceSource = traceSource; _oldActivityId = Trace.CorrelationManager.ActivityId; _activityName = activityName; _newActivityId = Guid.NewGuid(); if (_oldActivityId != Guid.Empty) { // transfer to activity _traceSource.TraceTransfer(0, string.Format(CultureInfo.CurrentCulture, "TRANSFER ==> {0} ===", _activityName), _newActivityId); } Trace.CorrelationManager.ActivityId = _newActivityId; _traceSource.Start(_activityName); }
/// <summary> /// Constructor used to initialize the class /// </summary> /// <param name="traceSource">The source that we are tracing through as part of this scope</param> /// <param name="logicalName">The name of the logical block that this scope represents</param> public TraceLogicalScope(TraceSource traceSource, string logicalName) { if (traceSource == null) { throw new ArgumentNullException("traceSource"); } if (string.IsNullOrEmpty(logicalName)) { throw new ArgumentNullException("logicalName"); } _traceSource = traceSource; _logicalName = logicalName; if (Trace.CorrelationManager.ActivityId.Equals(Guid.Empty)) Trace.CorrelationManager.ActivityId = Guid.NewGuid(); // _traceSource.TraceInformation("REQUEST === {0}", _logicalName); _traceSource.Start("BEGIN === {0} (ActivityId: {1}) ===", _logicalName, Trace.CorrelationManager.ActivityId); }