internal static IActivityScope GetActivityScope(Guid key) { IActivityScope activityScope = null; ActivityScopeImpl activityScopeImpl = null; try { ActivityScopeImpl.scopeCacheLock.EnterReadLock(); if (ActivityScopeImpl.scopeCache.TryGetValue(key, out activityScopeImpl)) { activityScope = activityScopeImpl; } } finally { try { ActivityScopeImpl.scopeCacheLock.ExitReadLock(); } catch (SynchronizationLockException) { } } if (activityScope != null) { return(activityScope); } return(null); }
internal static bool SetQueueTime(TimeSpan queueTime, IActivityScope activityScope = null) { return(WorkloadManagementLogger.DoIfStarted(activityScope, delegate(IActivityScope scope) { ActivityContext.AddOperation(scope, ActivityOperationType.QueueTime, null, (float)queueTime.TotalMilliseconds, 1); })); }
internal static bool SetResourceBlocked(string resourceInstance, IActivityScope activityScope = null) { return(WorkloadManagementLogger.DoIfStarted(activityScope, delegate(IActivityScope scope) { ActivityContext.AddOperation(scope, ActivityOperationType.ResourceBlocked, resourceInstance, 0f, 1); })); }
internal static bool SetBudgetUsage(TimeSpan usage, string instance, IActivityScope activityScope = null) { return(WorkloadManagementLogger.DoIfStarted(activityScope, delegate(IActivityScope scope) { ActivityContext.AddOperation(scope, ActivityOperationType.BudgetUsed, instance, (float)usage.TotalMilliseconds, 1); })); }
internal static string GetDiagnosticsInfo(HttpContext context) { RequestDetailsLogger current = RequestDetailsLoggerBase <RequestDetailsLogger> .GetCurrent(context); Guid guid = Guid.Empty; IActivityScope activityScope = null; if (current != null) { guid = current.ActivityId; activityScope = current.ActivityScope; } string text = string.Format("[ClientAccessServer={0},BackEndServer={1},RequestId={2},TimeStamp={3}] ", new object[] { Environment.MachineName, (activityScope == null) ? "UnKown" : activityScope.GetProperty(HttpProxyMetadata.TargetServer), guid, DateTime.UtcNow }); string text2 = string.Empty; if (context != null) { text2 = WinRMInfo.GetFailureCategoryInfo(context); } if (!string.IsNullOrEmpty(text2)) { text += string.Format("[FailureCategory={0}] ", text2); } ExTraceGlobals.VerboseTracer.TraceDebug <string>(0L, "[WinRMHelper::GetDiagnosticsInfo] diagnosticsInfo = {0}.", text); return(text); }
// Token: 0x060000BF RID: 191 RVA: 0x00005000 File Offset: 0x00003200 public void HandleEvent(MapiEvent mapiEvent, MailboxSession itemStore, StoreObject item) { using (new GuidTraceFilter(base.DatabaseInfo.Guid, mapiEvent.MailboxGuid)) { string value = (item != null) ? item.ClassName : mapiEvent.ObjectClass; if (!string.IsNullOrEmpty(value) || mapiEvent.ItemType == ObjectType.MAPI_STORE || mapiEvent.ItemType == ObjectType.MAPI_FOLDER) { EventBasedAssistant.Tracer.TraceDebug <EventBasedAssistant, long, IExchangePrincipal>((long)this.GetHashCode(), "{0}: Started handling event {1} for mailbox {2}.", this, mapiEvent.EventCounter, itemStore.MailboxOwner); List <KeyValuePair <string, object> > list = new List <KeyValuePair <string, object> >(); IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope(); Guid activityId = Guid.Empty; if (currentActivityScope != null) { activityId = currentActivityScope.ActivityId; } AssistantsLog.LogStartProcessingMailboxEvent(activityId, this, mapiEvent, itemStore.MailboxGuid); TraceContext.Set(itemStore); try { this.HandleEventInternal(mapiEvent, itemStore, item, list); goto IL_103; } finally { TraceContext.Reset(); AssistantsLog.LogEndProcessingMailboxEvent(activityId, this, list, itemStore.MailboxGuid, string.Empty, null); EventBasedAssistant.Tracer.TraceDebug <EventBasedAssistant, long, IExchangePrincipal>((long)this.GetHashCode(), "{0}: Ended handling event {1} for mailbox {2}.", this, mapiEvent.EventCounter, itemStore.MailboxOwner); } } EventBasedAssistant.Tracer.TraceDebug <IExchangePrincipal>((long)this.GetHashCode(), "{0}: Event not processed because we are unable get the ObjectClass on the item.", itemStore.MailboxOwner); IL_103 :; } }
public string GetCallerInformation() { int num = 0; if (string.IsNullOrEmpty(this.FilePath) || (num = this.FilePath.LastIndexOf("\\")) <= 0) { return(string.Empty); } IActivityScope activityScope = null; try { activityScope = (this.scope ?? ActivityContext.GetCurrentActivityScope()); } catch { } if (activityScope != null && !string.IsNullOrEmpty(activityScope.Action)) { return(string.Format("{0}: Method {1}; Line {2}; Action {3}", new object[] { this.FilePath.Substring(num + 1), this.MemberName, this.FileLine, activityScope.Action })); } return(string.Format("{0}: Method {1}; Line {2}", this.FilePath.Substring(num + 1), this.MemberName, this.FileLine)); }
private static string GetAuthUser(this HttpContextBase context) { if (context != null) { try { if (context.User != null && context.User.Identity.IsAuthenticated) { string name = context.User.Identity.Name; if (!string.IsNullOrEmpty(name)) { return(name); } } } catch (SystemException ex) { IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope(); if (currentActivityScope != null) { currentActivityScope.AppendToProperty(ServiceCommonMetadata.GenericErrors, ex.Message); } } } return(null); }
public static void AddOperation(IActivityScope scope, ActivityOperationType operation, string instance, float value = 0f, int count = 1) { bool flag = false; IActivityScope activityScope = ActivityContext.globalScope; TimeInResourcePerfCounter.AddOperation(operation, value); if (scope != null && scope.Status == ActivityContextStatus.ActivityStarted) { flag = scope.AddOperation(operation, instance, value, count); } if (!ActivityContext.IsGlobalScopeEnabled) { return; } if (flag) { activityScope.AddOperation(operation, "INSTR", value, count); return; } if (scope != null || SingleContext.Singleton.LocalId != null) { activityScope.AddOperation(operation, "MISSED", value, count); return; } if (DebugContext.GetDebugProperty(DebugProperties.ActivityId) == null) { activityScope.AddOperation(operation, "UNINSTR", value, count); return; } activityScope.AddOperation(operation, "SUPPR", value, count); }
protected static void CopyProperties(IActivityScope source, Dictionary <string, object> target, IEnumerable <KeyValuePair <Enum, string> > enumToKeyMappings) { foreach (KeyValuePair <Enum, string> keyValuePair in enumToKeyMappings) { ExtensibleLogger.CopyProperty(source, target, keyValuePair.Key, keyValuePair.Value, false); } }
public TResult Execute(CommandContext context) { this.Context = context; Stopwatch stopwatch = Stopwatch.StartNew(); TResult result; try { this.onBeforeExecute(); result = this.OnExecute(); } catch (Exception obj) { this.SetCustomLoggingData("Exception", obj); throw; } finally { stopwatch.Stop(); IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope(); if (currentActivityScope != null) { currentActivityScope.SetProperty(EntitiesMetadata.CommandName, base.GetType().Name); currentActivityScope.SetProperty(EntitiesMetadata.CoreExecutionLatency, stopwatch.ElapsedMilliseconds.ToString()); string customLoggingData = this.GetCustomLoggingData(); currentActivityScope.SetProperty(EntitiesMetadata.CustomData, customLoggingData); } } return(result); }
private static void UploadContacts(MailboxSession mailboxSession, string accessToken) { NewFacebookSubscription.Tracer.TraceFunction(0L, "Entering NewFacebookSubscription.UploadContacts. Mailbox {0}.", new object[] { mailboxSession.Identity }); try { IPeopleConnectApplicationConfig peopleConnectApplicationConfig = CachedPeopleConnectApplicationConfig.Instance.ReadFacebook(); string graphApiEndpoint = peopleConnectApplicationConfig.GraphApiEndpoint; using (FacebookClient facebookClient = new FacebookClient(new Uri(graphApiEndpoint))) { ContactsUploaderPerformanceTracker contactsUploaderPerformanceTracker = new ContactsUploaderPerformanceTracker(); IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope(); if (currentActivityScope != null) { currentActivityScope.UserState = contactsUploaderPerformanceTracker; } else { NewFacebookSubscription.Tracer.TraceFunction(0L, "Can't add metadata for Contacts upload as there is no current activity scope."); } FacebookContactsUploader facebookContactsUploader = new FacebookContactsUploader(contactsUploaderPerformanceTracker, facebookClient, peopleConnectApplicationConfig, (PropertyDefinition[] propertiesToLoad) => new RecursiveContactsEnumerator(mailboxSession, new XSOFactory(), DefaultFolderType.Contacts, propertiesToLoad)); facebookContactsUploader.UploadContacts(accessToken); } } finally { NewFacebookSubscription.Tracer.TraceFunction(0L, "Leaving NewFacebookSubscription.UploadContacts. Mailbox {0}.", new object[] { mailboxSession.Identity }); } }
// Token: 0x060010D1 RID: 4305 RVA: 0x00062714 File Offset: 0x00060914 public void SetMetadataValues(object context, RecipientType recipientType, string chunkId) { this.TraceDebug(context, "Entering SetMetadataValues - TaskName='{0}', RecipientType='{1}', ChunkId='{2}'", new object[] { this.TaskName, recipientType, chunkId }); Logger.RegisterMetadata(); IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope(); if (currentActivityScope != null && currentActivityScope.Status == ActivityContextStatus.ActivityStarted) { this.TraceDebug(context, "Setting metadata values TaskName='{0}', RecipientType='{1}', ChunkId='{2}', MailboxGuid='{3}', TenantGuid='{4}'", new object[] { this.TaskName, recipientType, chunkId, this.RunData.MailboxGuid, this.RunData.TenantGuid }); currentActivityScope.SetProperty(DirectoryProcessorMetadata.TaskName, this.TaskName); currentActivityScope.SetProperty(DirectoryProcessorMetadata.RecipientType, recipientType.ToString()); currentActivityScope.SetProperty(DirectoryProcessorMetadata.ChunkId, chunkId); currentActivityScope.SetProperty(DirectoryProcessorMetadata.MailboxGuid, this.RunData.MailboxGuid.ToString()); currentActivityScope.SetProperty(DirectoryProcessorMetadata.TenantGuid, this.RunData.TenantGuid.ToString()); } }
public static void PublishMetadata() { if (!BudgetMetadataPublisher.isBudgetMetadataRegistered) { ActivityContext.RegisterMetadata(typeof(BudgetMetadata)); BudgetMetadataPublisher.isBudgetMetadataRegistered = true; } HttpContext httpContext = HttpContext.Current; if (httpContext == null) { return; } IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope(); if (currentActivityScope == null) { return; } string contextItem = httpContext.GetContextItem("StartBudget"); if (contextItem != null) { string[] budgetElements = contextItem.Split(new char[] { ',' }); currentActivityScope.SetProperty(BudgetMetadata.BeginBudgetConnections, BudgetMetadataPublisher.GetBudgetSnapshotValueAtIndex(budgetElements, 1)); currentActivityScope.SetProperty(BudgetMetadata.MaxConn, BudgetMetadataPublisher.GetBudgetSnapshotValueAtIndex(budgetElements, 2)); currentActivityScope.SetProperty(BudgetMetadata.MaxBurst, BudgetMetadataPublisher.GetBudgetSnapshotValueAtIndex(budgetElements, 3)); currentActivityScope.SetProperty(BudgetMetadata.BeginBalance, BudgetMetadataPublisher.GetBudgetSnapshotValueAtIndex(budgetElements, 4)); currentActivityScope.SetProperty(BudgetMetadata.Cutoff, BudgetMetadataPublisher.GetBudgetSnapshotValueAtIndex(budgetElements, 5)); currentActivityScope.SetProperty(BudgetMetadata.RechargeRate, BudgetMetadataPublisher.GetBudgetSnapshotValueAtIndex(budgetElements, 6)); currentActivityScope.SetProperty(BudgetMetadata.ThrottlingPolicy, BudgetMetadataPublisher.GetBudgetSnapshotValueAtIndex(budgetElements, 7)); currentActivityScope.SetProperty(BudgetMetadata.IsServiceAct, BudgetMetadataPublisher.GetBudgetSnapshotValueAtIndex(budgetElements, 8)); currentActivityScope.SetProperty(BudgetMetadata.LiveTime, BudgetMetadataPublisher.GetBudgetSnapshotValueAtIndex(budgetElements, 9)); currentActivityScope.SetProperty(BudgetMetadata.BeginBudgetHangingConnections, BudgetMetadataPublisher.GetBudgetSnapshotValueAtIndex(budgetElements, 10)); currentActivityScope.SetProperty(BudgetMetadata.BeginBudgetSubscriptions, BudgetMetadataPublisher.GetBugdetSnapshotSubscriptions(contextItem)); } currentActivityScope.SetProperty(BudgetMetadata.TotalDCRequestCount, httpContext.GetContextItem("TotalLdapRequestCount")); currentActivityScope.SetProperty(BudgetMetadata.TotalDCRequestLatency, httpContext.GetContextItem("TotalLdapRequestLatency")); currentActivityScope.SetProperty(BudgetMetadata.TotalMBXRequestCount, httpContext.GetContextItem("TotalRpcRequestCount")); currentActivityScope.SetProperty(BudgetMetadata.TotalMBXRequestLatency, httpContext.GetContextItem("TotalRpcRequestLatency")); string contextItem2 = httpContext.GetContextItem("EndBudget"); if (contextItem2 != null) { string[] budgetElements2 = contextItem2.Split(new char[] { ',' }); currentActivityScope.SetProperty(BudgetMetadata.EndBudgetConnections, BudgetMetadataPublisher.GetBudgetSnapshotValueAtIndex(budgetElements2, 1)); currentActivityScope.SetProperty(BudgetMetadata.EndBalance, BudgetMetadataPublisher.GetBudgetSnapshotValueAtIndex(budgetElements2, 4)); currentActivityScope.SetProperty(BudgetMetadata.EndBudgetHangingConnections, BudgetMetadataPublisher.GetBudgetSnapshotValueAtIndex(budgetElements2, 10)); string bugdetSnapshotResources = BudgetMetadataPublisher.GetBugdetSnapshotResources(contextItem2); BudgetMetadataPublisher.SetBudgetSnapshotResourceInfo(bugdetSnapshotResources, currentActivityScope); currentActivityScope.SetProperty(BudgetMetadata.EndBudgetSubscriptions, BudgetMetadataPublisher.GetBugdetSnapshotSubscriptions(contextItem2)); } }
private Guid GetActivityId() { IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope(); Guid guid = (currentActivityScope != null) ? currentActivityScope.ActivityId : Guid.NewGuid(); this.AddVerboseLog("ActivityId: " + guid); return(guid); }
internal static bool SetBudgetType(string budgetType, IActivityScope activityScope = null) { WorkloadManagementLogger.RegisterMetadataIfNecessary(); return(WorkloadManagementLogger.DoIfStarted(activityScope, delegate(IActivityScope scope) { scope.SetProperty(WlmMetaData.BudgetType, budgetType); })); }
// Token: 0x060001AA RID: 426 RVA: 0x00007051 File Offset: 0x00005251 public void LogActivityEvent(IActivityScope activityScope, ActivityEventType eventType) { if (activityScope == null) { throw new ArgumentNullException("activityScope"); } this.InternalLogActivityEvent(activityScope, eventType); }
/// <summary> /// OnEvent is called whenever the event stream yields a payload and triggers an /// execution of the subscription query. /// </summary> /// <param name="payload"> /// The event stream payload. /// </param> /// <returns> /// Returns a query result which will be enqueued to the response stream. /// </returns> private async Task <IQueryResult> OnEvent(object payload) { using IActivityScope es = _diagnosticEvents.OnSubscriptionEvent(new(this, payload)); using IServiceScope serviceScope = _requestContext.Services.CreateScope(); OperationContext operationContext = _operationContextPool.Get(); try { var eventServices = serviceScope.ServiceProvider; var dispatcher = eventServices.GetRequiredService <IBatchDispatcher>(); // we store the event payload on the scoped context so that it is accessible // in the resolvers. ImmutableDictionary <string, object?> scopedContext = ImmutableDictionary <string, object?> .Empty .SetItem(WellKnownContextData.EventMessage, payload); // next we resolve the subscription instance. var rootValue = RootValueResolver.Resolve( _requestContext, eventServices, _subscriptionType, ref _cachedRootValue); // last we initialize a standard operation context to execute // the subscription query with the standard query executor. operationContext.Initialize( _requestContext, eventServices, dispatcher, _requestContext.Operation !, _requestContext.Variables !, rootValue, _resolveQueryRootValue); operationContext.Result.SetContextData( WellKnownContextData.EventMessage, payload); IQueryResult result = await _queryExecutor .ExecuteAsync(operationContext, scopedContext) .ConfigureAwait(false); _diagnosticEvents.SubscriptionEventResult(new(this, payload), result); return(result); } catch (Exception ex) { _diagnosticEvents.SubscriptionEventError(new(this, payload), ex); throw; } finally { _operationContextPool.Return(operationContext); } }
public static void SetThreadScope(IActivityScope activityScope) { ActivityContext.ClearThreadScope(); if (activityScope != null && activityScope.Status == ActivityContextStatus.ActivityStarted) { SingleContext.Singleton.LocalId = new Guid?(activityScope.LocalId); DebugContext.UpdateFrom(activityScope); } }
private static void OnAgentInvokeReturns(object dispatcher, IMExSession context) { IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope(); if (currentActivityScope != null) { currentActivityScope.Action = null; } }
private static void OnAgentInvokeStart(object dispatcher, IMExSession context) { IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope(); if (currentActivityScope != null) { currentActivityScope.Action = context.CurrentAgent.Name; } }
private static Guid GetActivityId() { IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope(); if (currentActivityScope == null) { return(Guid.NewGuid()); } return(currentActivityScope.ActivityId); }
public void Dispose() { this.performanceTracker.Stop(); IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope(); if (currentActivityScope != null) { currentActivityScope.Action = this.previousActionDescription; } }
internal static bool SetOverBudget(string policyPart, string policyValue, IActivityScope activityScope = null) { WorkloadManagementLogger.RegisterMetadataIfNecessary(); return(WorkloadManagementLogger.DoIfStarted(activityScope, delegate(IActivityScope scope) { ActivityContext.AddOperation(scope, ActivityOperationType.OverBudget, null, 0f, 1); scope.SetProperty(WlmMetaData.OverBudgetPolicyPart, policyPart); scope.SetProperty(WlmMetaData.OverBudgetPolicyValue, policyValue); })); }
public IActivityScope ValidateDocument(IRequestContext context) { var scopes = new IActivityScope[_listeners.Length]; for (var i = 0; i < _listeners.Length; i++) { scopes[i] = _listeners[i].ValidateDocument(context); } return(new AggregateActivityScope(scopes)); }
// Token: 0x06002599 RID: 9625 RVA: 0x0008835C File Offset: 0x0008655C public ICollection <KeyValuePair <string, object> > GetEventData() { IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope(); Dictionary <string, object> dictionary = new Dictionary <string, object> { { UserContextCookie.UserContextCookiePrefix, this.userContextKey }, { "ActID", (currentActivityScope == null) ? Guid.Empty : currentActivityScope.ActivityId }, { "C", this.userContextStatistics.Created.ToString(CultureInfo.InvariantCulture) }, { "CT", this.userContextStatistics.AcquireLatency }, { "EPT", this.userContextStatistics.ExchangePrincipalCreationTime }, { "MR", this.userContextStatistics.MiniRecipientCreationTime }, { "SKU", this.userContextStatistics.SKUCapabilityTestTime }, { "IL", this.userContextStatistics.CookieCreated ? 1 : 0 }, { "Err", (int)this.userContextStatistics.Error }, { "CAN", this.requestUri.AbsolutePath } }; if (this.userContext != null && this.userContext.ExchangePrincipal != null) { dictionary.Add("MG", this.userContext.ExchangePrincipal.MailboxInfo.MailboxGuid); dictionary.Add("PSA", ExtensibleLogger.FormatPIIValue(this.userContext.ExchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString())); } return(dictionary); }
internal static void RaiseEvent(IActivityScope activityScope, ActivityEventArgs args) { EventHandler <ActivityEventArgs> onActivityEvent = ActivityContext.OnActivityEvent; if (onActivityEvent != null && activityScope != null) { Guid activityId = activityScope.ActivityId; ExTraceGlobals.ActivityContextTracer.TraceDebug <ActivityEventType, Guid, int>(0L, "ActivityContext.RaiseEvent - raising event {0} for ActivityId {1}, and callback {2}.", args.ActivityEventType, activityId, onActivityEvent.GetHashCode()); onActivityEvent(activityScope, args); } }
public IActivityScope ExecuteRequest(IRequestContext context) { var scopes = new IActivityScope[_listeners.Length]; for (int i = 0; i < _listeners.Length; i++) { scopes[i] = _listeners[i].ExecuteRequest(context); } return(new AggregateActivityScope(scopes)); }
public ActivityScopeThreadGuard(IActivityScope scope) { if (scope != null) { this.originalScope = ActivityContext.GetCurrentActivityScope(); if (!object.ReferenceEquals(this.originalScope, scope)) { ActivityContext.SetThreadScope(scope); } } }
// Token: 0x06002563 RID: 9571 RVA: 0x00087834 File Offset: 0x00085A34 private static void InternalSaveTraces(IActivityScope activityScope, TroubleshootingContext troubleshootingContext) { IEnumerable <TraceEntry> traces = troubleshootingContext.GetTraces(); string eventId = activityScope.GetProperty(ExtensibleLoggerMetadata.EventId) + "_Trace"; foreach (TraceEntry entry in traces) { OwaServerTraceLogger.TraceLogEvent logEvent = new OwaServerTraceLogger.TraceLogEvent(activityScope, entry, eventId); OwaServerTraceLogger.instance.LogEvent(logEvent); } }