internal static T Get(Guid cmdletUniqueId) { T result; CmdletStaticDataWithUniqueId <T> .TryGet(cmdletUniqueId, out result); return(result); }
internal static long StopLatencyTracker(Guid cmdletUniqueId) { LatencyTracker latencyTracker = CmdletStaticDataWithUniqueId <LatencyTracker> .Get(cmdletUniqueId); if (latencyTracker == null) { return(-1L); } return(latencyTracker.Stop()); }
internal static LatencyTracker GetLatencyTracker(Guid cmdletUniqueId) { if (cmdletUniqueId == Guid.Empty && !CmdletThreadStaticData.TryGetCurrentCmdletUniqueId(out cmdletUniqueId)) { return(null); } LatencyTracker result; CmdletStaticDataWithUniqueId <LatencyTracker> .TryGet(cmdletUniqueId, out result); return(result); }
internal static void StartLatencyTracker(Guid cmdletUniqueId) { LatencyTracker latencyTracker = CmdletStaticDataWithUniqueId <LatencyTracker> .Get(cmdletUniqueId); if (latencyTracker != null) { CmdletLogger.SafeAppendGenericError(cmdletUniqueId, "StartLatencyTracker", string.Format("Latency tracker with this cmdlet {0} already exists. Override it anyway.", cmdletUniqueId), false); } latencyTracker = new LatencyTracker(cmdletUniqueId.ToString(), new Func <IActivityScope>(ActivityContext.GetCurrentActivityScope)); latencyTracker.Start(); CmdletStaticDataWithUniqueId <LatencyTracker> .Set(cmdletUniqueId, latencyTracker); }
internal static RpsCmdletLoggerBuffer Get(Guid cmdletUniqueId) { if (cmdletUniqueId == Guid.Empty && !CmdletThreadStaticData.TryGetCurrentCmdletUniqueId(out cmdletUniqueId)) { return(null); } RpsCmdletLoggerBuffer rpsCmdletLoggerBuffer; if (!CmdletStaticDataWithUniqueId <RpsCmdletLoggerBuffer> .TryGet(cmdletUniqueId, out rpsCmdletLoggerBuffer)) { rpsCmdletLoggerBuffer = new RpsCmdletLoggerBuffer(); CmdletStaticDataWithUniqueId <RpsCmdletLoggerBuffer> .Set(cmdletUniqueId, rpsCmdletLoggerBuffer); } return(rpsCmdletLoggerBuffer); }
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); } }