private void GetActivityInfo(ref ServiceModelActivity activity, ref Activity boundOperation) { if (TraceUtility.MessageFlowTracingOnly) { if (OperationContext.Current != null) { Guid receivedActivityId = TraceUtility.GetReceivedActivityId(OperationContext.Current); if (receivedActivityId != Guid.Empty) { DiagnosticTrace.ActivityId = receivedActivityId; } } } else if (DiagnosticUtility.ShouldUseActivity || TraceUtility.ShouldPropagateActivity) { object obj2 = TraceUtility.ExtractAsyncOperationContextActivity(); if (obj2 != null) { if (DiagnosticUtility.ShouldUseActivity) { activity = obj2 as ServiceModelActivity; boundOperation = ServiceModelActivity.BoundOperation(activity, true); } else if (TraceUtility.ShouldPropagateActivity && (obj2 is Guid)) { Guid activityId = (Guid) obj2; boundOperation = Activity.CreateActivity(activityId); } } } }
static internal void Stop(ServiceModelActivity activity) { if (activity != null) { activity.Stop(); } }
public void Dispose() { if (!_disposed) { _disposed = true; try { if (_activity != null) { _activity.Dispose(); } if (_autoStop) { this.Stop(); } if (_autoResume && ServiceModelActivity.Current != null) { ServiceModelActivity.Current.Resume(); } } finally { ServiceModelActivity.Current = _previousActivity; GC.SuppressFinalize(this); } } }
internal static void CreateActivityInfo(ref ServiceModelActivity activity, ref Activity boundActivity) { if (DiagnosticUtility.ShouldUseActivity) { activity = ServiceModelActivity.CreateAsyncActivity(); TraceUtility.UpdateAsyncOperationContextWithActivity(activity); boundActivity = ServiceModelActivity.BoundOperation(activity, true); } else if (TraceUtility.MessageFlowTracingOnly) { Guid activityId = TraceUtility.GetReceivedActivityId(OperationContext.Current); if (activityId != Guid.Empty) { DiagnosticTraceBase.ActivityId = activityId; } } else if (TraceUtility.ShouldPropagateActivity) { //Message flow tracing only scenarios use a light-weight ActivityID management logic Guid activityId = ActivityIdHeader.ExtractActivityId(OperationContext.Current.IncomingMessage); if (activityId != Guid.Empty) { boundActivity = Activity.CreateActivity(activityId); } TraceUtility.UpdateAsyncOperationContextWithActivity(activityId); } }
internal static void ProcessIncomingMessage(Message message, EventTraceActivity eventTraceActivity) { ServiceModelActivity activity = ServiceModelActivity.Current; if (activity != null && DiagnosticUtility.ShouldUseActivity) { ServiceModelActivity incomingActivity = TraceUtility.ExtractActivity(message); if (null != incomingActivity && incomingActivity.Id != activity.Id) { using (ServiceModelActivity.BoundOperation(incomingActivity)) { if (null != FxTrace.Trace) { FxTrace.Trace.TraceTransfer(activity.Id); } } } TraceUtility.SetActivity(message, activity); } TraceUtility.MessageFlowAtMessageReceived(message, null, eventTraceActivity, true); if (MessageLogger.LogMessagesAtServiceLevel) { MessageLogger.LogMessage(ref message, MessageLoggingSource.ServiceLevelReceiveReply | MessageLoggingSource.LastChance); } }
private void CreateActivityInfo(ref ServiceModelActivity activity, ref Activity boundActivity) { if (DiagnosticUtility.ShouldUseActivity) { activity = ServiceModelActivity.CreateAsyncActivity(); TraceUtility.UpdateAsyncOperationContextWithActivity(activity); boundActivity = ServiceModelActivity.BoundOperation(activity, true); } else if (TraceUtility.MessageFlowTracingOnly) { Guid receivedActivityId = TraceUtility.GetReceivedActivityId(OperationContext.Current); if (receivedActivityId != Guid.Empty) { DiagnosticTrace.ActivityId = receivedActivityId; } } else if (TraceUtility.ShouldPropagateActivity) { Guid activityId = ActivityIdHeader.ExtractActivityId(OperationContext.Current.IncomingMessage); if (activityId != Guid.Empty) { boundActivity = Activity.CreateActivity(activityId); } TraceUtility.UpdateAsyncOperationContextWithActivity(activityId); } }
internal static void SetActivity(Message message, ServiceModelActivity activity) { if (DiagnosticUtility.ShouldUseActivity && message != null && message.State != MessageState.Closed) { message.Properties[TraceUtility.ActivityIdKey] = activity; } }
static internal Activity BoundOperation(ServiceModelActivity activity) { if (!DiagnosticUtility.ShouldUseActivity) { return(null); } return(ServiceModelActivity.BoundOperation(activity, false)); }
static internal Activity BoundOperation(ServiceModelActivity activity) { if (!DiagnosticUtility.ShouldUseActivity) { return null; } return ServiceModelActivity.BoundOperation(activity, false); }
internal static Activity BoundOperation(ServiceModelActivity activity, bool addTransfer) { if (activity != null) { return BoundOperationCore(activity, addTransfer); } return null; }
private void ExecuteUserCode(IAsyncResult result) { using (ServiceModelActivity activity = ServiceModelActivity.CreateBoundedActivity()) { ServiceModelActivity.Start(activity, SR.ActivityCallback, ActivityType.ExecuteUserCode); this._callback(result); } }
public TracingConnection(IConnection connection, bool inheritCurrentActivity) : base(connection) { this.activity = inheritCurrentActivity ? ServiceModelActivity.CreateActivity(DiagnosticTrace.ActivityId, false) : ServiceModelActivity.CreateActivity(); if ((DiagnosticUtility.ShouldUseActivity && !inheritCurrentActivity) && (FxTrace.Trace != null)) { FxTrace.Trace.TraceTransfer(this.activity.Id); } }
internal static Activity BoundOperation(ServiceModelActivity activity, bool addTransfer) { if (activity != null) { return(BoundOperationCore(activity, addTransfer)); } return(null); }
internal static ServiceModelActivity CreateActivity() { if (!DiagnosticUtility.ShouldUseActivity) { return(null); } return(ServiceModelActivity.CreateActivity(Guid.NewGuid(), true)); }
static internal void Start(ServiceModelActivity activity, string activityName, ActivityType activityType) { if (activity != null && activity.LastState == ActivityState.Unknown) { activity.LastState = ActivityState.Start; activity._name = activityName; activity._activityType = activityType; } }
static internal void Start(ServiceModelActivity activity, string activityName, ActivityType activityType) { if (activity != null && activity.LastState == ActivityState.Unknown) { activity.LastState = ActivityState.Start; activity.name = activityName; activity.activityType = activityType; activity.TraceMilestone(TraceEventType.Start); } }
internal static void Start(ServiceModelActivity activity, string activityName, System.ServiceModel.Diagnostics.ActivityType activityType) { if ((activity != null) && (activity.LastState == ActivityState.Unknown)) { activity.LastState = ActivityState.Start; activity.name = activityName; activity.activityType = activityType; activity.TraceMilestone(TraceEventType.Start); } }
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 ServiceModelActivity CreateActivity(bool autoStop, string activityName, ActivityType activityType) { if (!DiagnosticUtility.ShouldUseActivity) { return(null); } ServiceModelActivity activity = ServiceModelActivity.CreateActivity(autoStop); ServiceModelActivity.Start(activity, activityName, activityType); return(activity); }
internal static ServiceModelActivity ExtractAndRemoveActivity(Message message) { ServiceModelActivity retval = TraceUtility.ExtractActivity(message); if (retval != null) { // If the property is just removed, the item is disposed and we don't want the thing // to be disposed of. message.Properties[TraceUtility.ActivityIdKey] = false; } return(retval); }
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; } }
internal static ServiceModelActivity CreateActivity(Guid activityId, bool autoStop) { if (!DiagnosticUtility.ShouldUseActivity) { return(null); } ServiceModelActivity retval = ServiceModelActivity.CreateActivity(activityId); if (retval != null) { retval._autoStop = autoStop; } return(retval); }
internal static ServiceModelActivity CreateActivity(Guid activityId, bool autoStop) { if (!DiagnosticUtility.ShouldUseActivity) { return(null); } ServiceModelActivity activity = CreateActivity(activityId); if (activity != null) { activity.autoStop = autoStop; } return(activity); }
internal static ServiceModelActivity CreateActivity(bool autoStop) { if (!DiagnosticUtility.ShouldUseActivity) { return(null); } ServiceModelActivity activity = ServiceModelActivity.CreateActivity(Guid.NewGuid(), true); if (activity != null) { activity._autoStop = autoStop; } return(activity); }
internal static ServiceModelActivity CreateAsyncActivity() { if (!DiagnosticUtility.ShouldUseActivity) { return(null); } ServiceModelActivity activity = ServiceModelActivity.CreateActivity(true); if (activity != null) { activity._isAsync = true; } return(activity); }
internal static ServiceModelActivity CreateBoundedActivity(Guid activityId) { if (!DiagnosticUtility.ShouldUseActivity) { return(null); } ServiceModelActivity activity = CreateActivity(activityId, true); if (activity != null) { activity.activity = (TransferActivity)BoundOperation(activity, true); } return(activity); }
internal static ServiceModelActivity CreateBoundedActivity(Guid activityId) { if (!DiagnosticUtility.ShouldUseActivity) { return(null); } ServiceModelActivity retval = ServiceModelActivity.CreateActivity(activityId, true); if (retval != null) { retval._activity = (TransferActivity)ServiceModelActivity.BoundOperation(retval, true); } return(retval); }
public TracingConnection(IConnection connection, bool inheritCurrentActivity) : base(connection) { this.activity = inheritCurrentActivity ? ServiceModelActivity.CreateActivity(DiagnosticTraceBase.ActivityId, false) : ServiceModelActivity.CreateActivity(); Fx.Assert(this.activity != null, ""); if (DiagnosticUtility.ShouldUseActivity && !inheritCurrentActivity) { if (null != FxTrace.Trace) { FxTrace.Trace.TraceTransfer(this.activity.Id); } } }
internal ProxyRpc(ServiceChannel channel, ProxyOperationRuntime operation, string action, object[] inputs, TimeSpan timeout) { this.Action = action; this.Activity = null; this.Channel = channel; this.Correlation = EmptyArray.Allocate(operation.Parent.CorrelationCount); this.InputParameters = inputs; this.Operation = operation; this.OutputParameters = null; this.Request = null; this.Reply = null; this.ActivityId = Guid.Empty; this.ReturnValue = null; this.MessageVersion = channel.MessageVersion; this.TimeoutHelper = new System.Runtime.TimeoutHelper(timeout); }
protected TraceAsyncResult(AsyncCallback callback, object state) : base(callback, state) { if (TraceUtility.MessageFlowTracingOnly) { this.CallbackActivity = ServiceModelActivity.CreateLightWeightAsyncActivity(Trace.CorrelationManager.ActivityId); base.VirtualCallback = waitResultCallback; } else if (DiagnosticUtility.ShouldUseActivity) { this.CallbackActivity = ServiceModelActivity.Current; if (this.CallbackActivity != null) { base.VirtualCallback = waitResultCallback; } } }
private static void DoCallback(AsyncCallback callback, IAsyncResult result) { if (result is TraceAsyncResult) { TraceAsyncResult result2 = result as TraceAsyncResult; if (TraceUtility.MessageFlowTracingOnly) { Trace.CorrelationManager.ActivityId = result2.CallbackActivity.Id; result2.CallbackActivity = null; } using (ServiceModelActivity.BoundOperation(result2.CallbackActivity)) { callback(result); } } }
internal static ServiceModelActivity ExtractActivity(Message message) { ServiceModelActivity retval = null; if ((DiagnosticUtility.ShouldUseActivity || TraceUtility.ShouldPropagateActivityGlobal) && (message != null) && (message.State != MessageState.Closed)) { object property; if (message.Properties.TryGetValue(TraceUtility.ActivityIdKey, out property)) { retval = property as ServiceModelActivity; } } return(retval); }
private static void DoCallback(AsyncCallback callback, IAsyncResult result) { if (result is TraceAsyncResult) { TraceAsyncResult thisPtr = result as TraceAsyncResult; Fx.Assert(thisPtr.CallbackActivity != null, "this shouldn't be hooked up if we don't have a CallbackActivity"); if (TraceUtility.MessageFlowTracingOnly) { thisPtr.CallbackActivity = null; } using (ServiceModelActivity.BoundOperation(thisPtr.CallbackActivity)) { callback(result); } } }
internal static ServiceModelActivity CreateActivity(Guid activityId) { if (!DiagnosticUtility.ShouldUseActivity) { return(null); } ServiceModelActivity activity = null; if (activityId != Guid.Empty) { activity = new ServiceModelActivity(activityId); } if (activity != null) { Current = activity; } return(activity); }
private static void LogMessageImpl(ref Message message, XmlReader reader, MessageLoggingSource source) { ServiceModelActivity activity = DiagnosticUtility.ShouldUseActivity ? TraceUtility.ExtractActivity(message) : null; using (ServiceModelActivity.BoundOperation(activity)) { if (ShouldLogMessages(source) && ((numberOfMessagesToLog > 0) || (numberOfMessagesToLog == -1))) { bool flag = ((source & MessageLoggingSource.LastChance) != MessageLoggingSource.None) || ((source & MessageLoggingSource.TransportSend) != MessageLoggingSource.None); source &= ~MessageLoggingSource.LastChance; if (((flag || (message is NullMessage)) || (message.Version.Addressing != AddressingVersion.None)) && (MatchFilters(message, source) && ((numberOfMessagesToLog == -1) || (numberOfMessagesToLog > 0)))) { MessageLogTraceRecord record = new MessageLogTraceRecord(ref message, reader, source, LogMessageBody); LogInternal(record); } } } }
private static Activity BoundOperationCore(ServiceModelActivity activity, bool addTransfer) { if (!DiagnosticUtility.ShouldUseActivity) { return null; } TransferActivity activity2 = null; if (activity != null) { activity2 = TransferActivity.CreateActivity(activity.activityId, addTransfer); if (activity2 != null) { activity2.SetPreviousServiceModelActivity(Current); } Current = activity; } return activity2; }
internal static Action <AsyncCallback, IAsyncResult> CallbackGenerator() { if (DiagnosticUtility.ShouldUseActivity) { ServiceModelActivity callbackActivity = ServiceModelActivity.Current; if (callbackActivity != null) { return(delegate(AsyncCallback callback, IAsyncResult result) { using (ServiceModelActivity.BoundOperation(callbackActivity)) { callback(result); } }); } } return(null); }
internal static ServiceModelActivity CreateActivity(Guid activityId) { if (!DiagnosticUtility.ShouldUseActivity) { return(null); } ServiceModelActivity retval = null; if (activityId != Guid.Empty) { retval = new ServiceModelActivity(activityId); } if (retval != null) { ServiceModelActivity.Current = retval; } return(retval); }
private static Activity BoundOperationCore(ServiceModelActivity activity, bool addTransfer) { if (!DiagnosticUtility.ShouldUseActivity) { return(null); } TransferActivity retval = null; if (activity != null) { retval = TransferActivity.CreateActivity(activity._activityId, addTransfer); if (retval != null) { retval.SetPreviousServiceModelActivity(ServiceModelActivity.Current); } ServiceModelActivity.Current = activity; } return(retval); }
internal TracingConnectionListener(IConnectionListener listener, string traceStartInfo, bool newActivity) { this.listener = listener; if (newActivity) { this.activity = ServiceModelActivity.CreateActivity(); if (DiagnosticUtility.ShouldUseActivity) { if (FxTrace.Trace != null) { FxTrace.Trace.TraceTransfer(this.activity.Id); } ServiceModelActivity.Start(this.activity, System.ServiceModel.SR.GetString("ActivityListenAt", new object[] { traceStartInfo }), ActivityType.ListenAt); } } else { this.activity = ServiceModelActivity.CreateActivity(DiagnosticTrace.ActivityId, false); if (this.activity != null) { this.activity.Name = traceStartInfo; } } }
internal void Open() { this.activity = MsmqDiagnostics.StartListenAtActivity(this); using (MsmqDiagnostics.BoundOpenOperation(this)) { this.queue.EnsureOpen(); this.poisonHandler.Open(); } }
static Activity BoundOperationCore(ServiceModelActivity activity, bool addTransfer) { if (!DiagnosticUtility.ShouldUseActivity) { return null; } TransferActivity retval = null; if (activity != null) { retval = TransferActivity.CreateActivity(activity.activityId, addTransfer); if (retval != null) { retval.SetPreviousServiceModelActivity(ServiceModelActivity.Current); } ServiceModelActivity.Current = activity; } return retval; }
internal static void GetActivityInfo(ref ServiceModelActivity activity, ref Activity boundOperation) { if (TraceUtility.MessageFlowTracingOnly) { if (null != OperationContext.Current) { Guid activityId = TraceUtility.GetReceivedActivityId(OperationContext.Current); if (activityId != Guid.Empty) { DiagnosticTraceBase.ActivityId = activityId; } } } else if (DiagnosticUtility.ShouldUseActivity || TraceUtility.ShouldPropagateActivity) { object activityInfo = TraceUtility.ExtractAsyncOperationContextActivity(); if (activityInfo != null) { if (DiagnosticUtility.ShouldUseActivity) { activity = activityInfo as ServiceModelActivity; boundOperation = ServiceModelActivity.BoundOperation(activity, true); } else if (TraceUtility.ShouldPropagateActivity) { if (activityInfo is Guid) { Guid activityId = (Guid)activityInfo; boundOperation = Activity.CreateActivity(activityId); } } } } }
protected void StartReceiveBytesActivity(ServiceModelActivity activity, Uri requestUri) { ServiceModelActivity.Start(activity, System.ServiceModel.SR.GetString("ActivityReceiveBytes", new object[] { requestUri.ToString() }), ActivityType.ReceiveBytes); }
public SecurityProtocolCorrelationState(SecurityToken token) { this.token = token; this.activity = DiagnosticUtility.ShouldUseActivity ? ServiceModelActivity.Current : null; }
static internal Activity BoundOperation(ServiceModelActivity activity, bool addTransfer) { return activity == null ? null : ServiceModelActivity.BoundOperationCore(activity, addTransfer); }
internal MessageRpc(RequestContext requestContext, Message request, DispatchOperationRuntime operation, ServiceChannel channel, ServiceHostBase host, ChannelHandler channelHandler, bool cleanThread, OperationContext operationContext, InstanceContext instanceContext, EventTraceActivity eventTraceActivity) { Fx.Assert((operationContext != null), "System.ServiceModel.Dispatcher.MessageRpc.MessageRpc(), operationContext == null"); Fx.Assert(channelHandler != null, "System.ServiceModel.Dispatcher.MessageRpc.MessageRpc(), channelHandler == null"); this.Activity = null; this.EventTraceActivity = eventTraceActivity; this.AsyncResult = null; this.CanSendReply = true; this.Channel = channel; this.channelHandler = channelHandler; this.Correlation = EmptyArray.Allocate(operation.Parent.CorrelationCount); this.CorrelationCallback = null; this.DidDeserializeRequestBody = false; this.TransactionMessageProperty = null; this.TransactedBatchContext = null; this.Error = null; this.ErrorProcessor = null; this.FaultInfo = new ErrorHandlerFaultInfo(request.Version.Addressing.DefaultFaultAction); this.HasSecurityContext = false; this.Host = host; this.Instance = null; this.MessageRpcOwnsInstanceContextThrottle = false; this.NextProcessor = null; this.NotUnderstoodHeaders = null; this.Operation = operation; this.OperationContext = operationContext; this.paused = false; this.ParametersDisposed = false; this.ReceiveContext = null; this.Request = request; this.RequestContext = requestContext; this.RequestContextThrewOnReply = false; this.SuccessfullySendReply = false; this.RequestVersion = request.Version; this.Reply = null; this.ReplyTimeoutHelper = new TimeoutHelper(); this.SecurityContext = null; this.InstanceContext = instanceContext; this.SuccessfullyBoundInstance = false; this.SuccessfullyIncrementedActivity = false; this.SuccessfullyLockedInstance = false; this.switchedThreads = !cleanThread; this.transaction = null; this.InputParameters = null; this.OutputParameters = null; this.ReturnParameter = null; this.isInstanceContextSingleton = InstanceContextProviderBase.IsProviderSingleton(this.Channel.DispatchRuntime.InstanceContextProvider); this.invokeContinueGate = null; if (!operation.IsOneWay && !operation.Parent.ManualAddressing) { this.RequestID = request.Headers.MessageId; this.ReplyToInfo = new RequestReplyCorrelator.ReplyToInfo(request); } else { this.RequestID = null; this.ReplyToInfo = new RequestReplyCorrelator.ReplyToInfo(); } this.HostingProperty = AspNetEnvironment.Current.GetHostingProperty(request, true); if (DiagnosticUtility.ShouldUseActivity) { this.Activity = TraceUtility.ExtractActivity(this.Request); } if (DiagnosticUtility.ShouldUseActivity || TraceUtility.ShouldPropagateActivity) { this.ResponseActivityId = ActivityIdHeader.ExtractActivityId(this.Request); } else { this.ResponseActivityId = Guid.Empty; } this.InvokeNotification = new MessageRpcInvokeNotification(this.Activity, this.channelHandler); if (this.EventTraceActivity == null && FxTrace.Trace.IsEnd2EndActivityTracingEnabled) { if (this.Request != null) { this.EventTraceActivity = EventTraceActivityHelper.TryExtractActivity(this.Request, true); } } }
public TracingConnection(IConnection connection, ServiceModelActivity activity) : base(connection) { this.activity = activity; }
internal static ServiceModelActivity CreateActivity(Guid activityId) { if (!DiagnosticUtility.ShouldUseActivity) { return null; } ServiceModelActivity retval = null; if (activityId != Guid.Empty) { retval = new ServiceModelActivity(activityId); } if (retval != null) { ServiceModelActivity.Current = retval; } return retval; }
public void Dispose() { if (!this.disposed) { this.disposed = true; try { if (this.activity != null) { this.activity.Dispose(); } if (this.autoStop) { this.Stop(); } if (this.autoResume && ServiceModelActivity.Current != null) { ServiceModelActivity.Current.Resume(); } } finally { ServiceModelActivity.Current = this.previousActivity; GC.SuppressFinalize(this); } } }
internal void SetPreviousServiceModelActivity(ServiceModelActivity previous) { this.previousActivity = previous; this.changeCurrentServiceModelActivity = true; }
public MessageRpcInvokeNotification(ServiceModelActivity activity, ChannelHandler handler) { this.activity = activity; this.handler = handler; }
internal TracingConnectionState(WaitCallback callback, ServiceModelActivity activity, object state) { this.activity = activity; this.callback = callback; this.state = state; }
internal TracingConnectionListener(IConnectionListener listener) { this.listener = listener; this.activity = ServiceModelActivity.CreateActivity(DiagnosticTrace.ActivityId, false); }
internal TracingConnectionInitiator(IConnectionInitiator connectionInitiator, bool isClient) { this.connectionInitiator = connectionInitiator; this.activity = ServiceModelActivity.CreateActivity(DiagnosticTraceBase.ActivityId); this.isClient = isClient; }
ServiceModelActivity(Guid activityId) { this.activityId = activityId; this.previousActivity = ServiceModelActivity.Current; }