internal static Guid ExtractActivityId(Message message) { if (TraceUtility.MessageFlowTracingOnly) { return(ActivityIdHeader.ExtractActivityId(message)); } ServiceModelActivity activity = ExtractActivity(message); return(activity == null ? Guid.Empty : activity.Id); }
internal static void TransferFromTransport(Message message) { if (message != null && DiagnosticUtility.ShouldUseActivity) { Guid guid = Guid.Empty; // Only look if we are allowing user propagation if (TraceUtility.ShouldPropagateActivity) { guid = ActivityIdHeader.ExtractActivityId(message); } if (guid == Guid.Empty) { guid = Guid.NewGuid(); } ServiceModelActivity activity = null; bool emitStart = true; if (ServiceModelActivity.Current != null) { if ((ServiceModelActivity.Current.Id == guid) || (ServiceModelActivity.Current.ActivityType == ActivityType.ProcessAction)) { activity = ServiceModelActivity.Current; emitStart = false; } else if (ServiceModelActivity.Current.PreviousActivity != null && ServiceModelActivity.Current.PreviousActivity.Id == guid) { activity = ServiceModelActivity.Current.PreviousActivity; emitStart = false; } } if (activity == null) { activity = ServiceModelActivity.CreateActivity(guid); } if (DiagnosticUtility.ShouldUseActivity) { if (emitStart) { if (null != FxTrace.Trace) { FxTrace.Trace.TraceTransfer(guid); } ServiceModelActivity.Start(activity, SR.Format(SR.ActivityProcessAction, message.Headers.Action), ActivityType.ProcessAction); } } message.Properties[TraceUtility.ActivityIdKey] = activity; } }