internal static void DisposeLatencyTracker(Guid cmdletUniqueId) { CmdletStaticDataWithUniqueId <LatencyTracker> .Remove(cmdletUniqueId); }
internal static void AsyncCommit(Guid cmdletUniqueId, bool forceSync) { if (!LoggerSettings.LogEnabled) { return; } if (!LoggerHelper.IsPswsNormalRequest) { IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope(); if (currentActivityScope == null) { throw new ArgumentException("activityScope is null."); } RequestDetailsLoggerBase <RpsCmdletLogger> .InitializeRequestLogger(currentActivityScope); RpsCmdletLogger rpsCmdletLogger = RequestDetailsLoggerBase <RpsCmdletLogger> .Current; if (rpsCmdletLogger == null) { return; } rpsCmdletLogger.EndActivityContext = false; RpsCmdletLoggerBuffer rpsCmdletLoggerBuffer = RpsCmdletLoggerBuffer.Get(cmdletUniqueId); foreach (KeyValuePair <Enum, object> keyValuePair in rpsCmdletLoggerBuffer.MetadataLogCache) { RequestDetailsLoggerBase <RpsCmdletLogger> .SafeSetLogger(rpsCmdletLogger, keyValuePair.Key, keyValuePair.Value); } foreach (KeyValuePair <string, string> keyValuePair2 in rpsCmdletLoggerBuffer.GenericInfoLogCache) { RequestDetailsLoggerBase <RpsCmdletLogger> .SafeAppendColumn(rpsCmdletLogger, RpsCmdletMetadata.GenericInfo, keyValuePair2.Key, keyValuePair2.Value); } foreach (KeyValuePair <string, string> keyValuePair3 in rpsCmdletLoggerBuffer.GenericErrorLogCache) { RequestDetailsLoggerBase <RpsCmdletLogger> .SafeAppendColumn(rpsCmdletLogger, RpsCmdletMetadata.GenericErrors, keyValuePair3.Key, keyValuePair3.Value); } foreach (KeyValuePair <Enum, Dictionary <string, string> > keyValuePair4 in rpsCmdletLoggerBuffer.GenericColumnLogCache) { foreach (KeyValuePair <string, string> keyValuePair5 in keyValuePair4.Value) { RequestDetailsLoggerBase <RpsCmdletLogger> .SafeAppendColumn(rpsCmdletLogger, keyValuePair4.Key, keyValuePair5.Key, keyValuePair5.Value); } } foreach (KeyValuePair <Enum, double> keyValuePair6 in rpsCmdletLoggerBuffer.LatencyLogCache) { rpsCmdletLogger.UpdateLatency(keyValuePair6.Key, keyValuePair6.Value); } rpsCmdletLogger.AsyncCommit(forceSync); foreach (KeyValuePair <Enum, object> keyValuePair7 in rpsCmdletLoggerBuffer.MetadataLogCache) { currentActivityScope.SetProperty(keyValuePair7.Key, null); } foreach (KeyValuePair <Enum, double> keyValuePair8 in rpsCmdletLoggerBuffer.LatencyLogCache) { currentActivityScope.SetProperty(keyValuePair8.Key, null); } foreach (KeyValuePair <Enum, Dictionary <string, string> > keyValuePair9 in rpsCmdletLoggerBuffer.GenericColumnLogCache) { currentActivityScope.SetProperty(keyValuePair9.Key, null); } currentActivityScope.SetProperty(RpsCmdletMetadata.GenericInfo, null); currentActivityScope.SetProperty(RpsCmdletMetadata.GenericErrors, null); rpsCmdletLoggerBuffer.Reset(); CmdletStaticDataWithUniqueId <RpsCmdletLoggerBuffer> .Remove(cmdletUniqueId); } }