internal static void SafeSetLogger(Guid cmdletUniqueId, Enum key, object value) { if (!LoggerSettings.LogEnabled) { return; } if (LoggerHelper.IsPswsNormalRequest) { RequestDetailsLoggerBase <PswsLogger> .SafeSetLogger(RequestDetailsLoggerBase <PswsLogger> .Current, key, value); return; } RpsCmdletLoggerBuffer rpsCmdletLoggerBuffer = RpsCmdletLoggerBuffer.Get(cmdletUniqueId); if (rpsCmdletLoggerBuffer != null) { rpsCmdletLoggerBuffer.AddMetadataLog(key, value); } }
protected override void ExposeExceptionToClientResponse(Exception ex) { if (!WinRMHelper.FriendlyErrorEnabled.Value) { base.ExposeExceptionToClientResponse(ex); return; } if (ex is WebException) { WebException ex2 = (WebException)ex; if (WinRMHelper.IsPingRequest(ex2)) { ExTraceGlobals.VerboseTracer.TraceDebug <int>((long)this.GetHashCode(), "[RemotePowerShellProxyRequestHandler::ExposeExceptionToClientResponse]: Context={0}, Ping found.", base.TraceContext); RequestDetailsLoggerBase <RequestDetailsLogger> .SafeSetLogger(base.Logger, HttpProxyMetadata.ProtocolAction, "Ping"); base.ClientResponse.Headers["X-RemotePS-Ping"] = "Ping"; return; } if (WinRMHelper.CouldBePingRequest(ex2)) { ExTraceGlobals.VerboseTracer.TraceDebug <int>((long)this.GetHashCode(), "[RemotePowerShellProxyRequestHandler::ExposeExceptionToClientResponse]: Context={0}, Could be Ping request.", base.TraceContext); base.ClientResponse.Headers["X-RemotePS-Ping"] = "Possible-Ping"; return; } if (ex2.Status != WebExceptionStatus.ProtocolError) { WinRMInfo.SetFailureCategoryInfo(base.ClientResponse.Headers, FailureCategory.Cafe, ex2.Status.ToString()); } } if (ex is HttpProxyException && !string.IsNullOrWhiteSpace(ex.Message) && !WinRMHelper.DiagnosticsInfoHasBeenWritten(base.ClientResponse.Headers)) { WinRMInfo.SetFailureCategoryInfo(base.ClientResponse.Headers, FailureCategory.Cafe, ex.GetType().Name); string diagnosticsInfo = WinRMHelper.GetDiagnosticsInfo(base.HttpContext); ExTraceGlobals.VerboseTracer.TraceDebug <int, string>((long)this.GetHashCode(), "[RemotePowerShellProxyRequestHandler::ExposeExceptionToClientResponse]: Context={0}, Write Message {1} to client response.", base.TraceContext, ex.Message); WinRMHelper.SetDiagnosticsInfoWrittenFlag(base.ClientResponse.Headers); RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(base.Logger, "FriendlyError", "ExposeException"); base.ClientResponse.Write(diagnosticsInfo + ex.Message); return; } base.ExposeExceptionToClientResponse(ex); }
// Token: 0x060002C3 RID: 707 RVA: 0x0000DDE8 File Offset: 0x0000BFE8 internal static void SafeSet(this RequestDetailsLogger logger, Enum key, object value) { RequestDetailsLoggerBase <RequestDetailsLogger> .SafeSetLogger(logger, key, value); }
private static void InternalOnPostAuthorizeRequest(object sender) { ExTraceGlobals.CoreCallTracer.TraceDebug(0L, "[OwaRequestHandler::InternalOnPostAuthorizeRequest] entry."); RequestDetailsLogger getRequestDetailsLogger = OwaApplication.GetRequestDetailsLogger; SubActivityScopeLogger subActivityScopeLogger = SubActivityScopeLogger.Create(getRequestDetailsLogger, OwaServerLogger.LoggerData.OnPostAuthorizeRequestLatencyDetails); HttpApplication httpApplication = (HttpApplication)sender; HttpContext context = httpApplication.Context; if (!context.Request.IsAuthenticated && (context.Request.Url.LocalPath.EndsWith("service.svc", StringComparison.OrdinalIgnoreCase) || context.Request.Url.LocalPath.EndsWith("Speech.reco", StringComparison.OrdinalIgnoreCase))) { ExTraceGlobals.CoreCallTracer.TraceDebug <string>(0L, "[OwaRequestHandler::InternalOnPostAuthorizeRequest] unauthorized request. Request URL={0}.", context.Request.Url.OriginalString); context.Response.StatusCode = 401; httpApplication.CompleteRequest(); return; } RequestContext requestContext = RequestContext.Get(httpApplication.Context); subActivityScopeLogger.LogNext("a"); RequestDispatcher.DispatchRequest(requestContext); subActivityScopeLogger.LogNext("b"); OwaRequestType requestType = requestContext.RequestType; RequestDispatcherUtilities.SetXFrameOptionsHeader(RequestContext.Current, requestType); subActivityScopeLogger.LogNext("c"); if (context.User != null && context.User.Identity != null) { if (context.User.Identity is ClientSecurityContextIdentity) { IMailboxContext mailboxContext = UserContextManager.GetMailboxContext(context, null, false); subActivityScopeLogger.LogNext("d"); if (OwaRequestHandler.IsProxyLogonRequest(requestType)) { ExTraceGlobals.CoreCallTracer.TraceDebug <OwaRequestType>(0L, "[OwaRequestHandler::InternalOnPostAuthorizeRequest] proxy logon request. RequestType={0}", requestType); return; } RequestDetailsLogger.LogEvent(getRequestDetailsLogger, OwaServerLogger.LoggerData.CanaryValidationBegin); bool flag = OwaRequestHandler.IsRequestWithCanary(context.Request, requestType, context.Request.IsAuthenticated); bool flag2 = OwaRequestHandler.IsAfterLogonRequest(context.Request); string originalIdentitySid = OwaRequestHandler.GetOriginalIdentitySid(context); CanaryLogEvent.CanaryStatus canaryStatus = CanaryLogEvent.CanaryStatus.None; bool flag3 = !flag || flag2; if (!flag3) { Canary15Cookie.CanaryValidationResult canaryValidationResult; flag3 = Canary15Cookie.ValidateCanaryInHeaders(context, originalIdentitySid, Canary15Profile.Owa, out canaryValidationResult); canaryStatus |= (CanaryLogEvent.CanaryStatus)canaryValidationResult; } OwaRequestHandler.UpdateCanaryStatus(ref canaryStatus, flag, CanaryLogEvent.CanaryStatus.IsCanaryNeeded); OwaRequestHandler.UpdateCanaryStatus(ref canaryStatus, flag3, CanaryLogEvent.CanaryStatus.IsCanaryValid); OwaRequestHandler.UpdateCanaryStatus(ref canaryStatus, flag2, CanaryLogEvent.CanaryStatus.IsCanaryAfterLogonRequest); Canary15Cookie canary15Cookie = Canary15Cookie.TryCreateFromHttpContext(context, originalIdentitySid, Canary15Profile.Owa); OwaRequestHandler.UpdateCanaryStatus(ref canaryStatus, canary15Cookie.IsAboutToExpire, CanaryLogEvent.CanaryStatus.IsCanaryAboutToExpire); OwaRequestHandler.UpdateCanaryStatus(ref canaryStatus, canary15Cookie.IsRenewed, CanaryLogEvent.CanaryStatus.IsCanaryRenewed); subActivityScopeLogger.LogNext("e"); bool flag4 = flag || canary15Cookie.IsAboutToExpire; if (flag4) { canary15Cookie = new Canary15Cookie(originalIdentitySid, Canary15Profile.Owa); } if (canary15Cookie.IsRenewed || flag4) { context.Response.SetCookie(canary15Cookie.HttpCookie); CanaryLogEvent logEvent = new CanaryLogEvent(context, mailboxContext, canaryStatus, canary15Cookie.CreationTime, canary15Cookie.LogData); OwaServerLogger.AppendToLog(logEvent); subActivityScopeLogger.LogNext("f"); } if (flag3) { RequestDetailsLoggerBase <RequestDetailsLogger> .SafeSetLogger(getRequestDetailsLogger, OwaServerLogger.LoggerData.CanaryCreationTime, canary15Cookie.CreationTime); RequestDetailsLoggerBase <RequestDetailsLogger> .SafeSetLogger(getRequestDetailsLogger, OwaServerLogger.LoggerData.CanaryLogData, canary15Cookie.LogData); subActivityScopeLogger.LogNext("g"); } else { if (RequestDispatcherUtilities.IsDownLevelClient(context, false)) { throw new OwaCanaryException(Canary15Profile.Owa.Name, canary15Cookie.Value); } context.Response.StatusCode = 449; context.Response.End(); } RequestDetailsLoggerBase <RequestDetailsLogger> requestDetailsLogger = getRequestDetailsLogger; Enum key = OwaServerLogger.LoggerData.CanaryStatus; int num = (int)canaryStatus; RequestDetailsLoggerBase <RequestDetailsLogger> .SafeSetLogger(requestDetailsLogger, key, num.ToString("X")); RequestDetailsLogger.LogEvent(getRequestDetailsLogger, OwaServerLogger.LoggerData.CanaryValidationEnd); subActivityScopeLogger.LogEnd(); return; } } else { ExTraceGlobals.CoreCallTracer.TraceError(0L, "[OwaRequestHandler::InternalOnPostAuthorizeRequest] httpContext.User or httpContext.User.Identity is <NULL>."); } }
private void OnEndRequest(object sender, EventArgs e) { HttpContext httpContext = HttpContext.Current; HttpResponse response = httpContext.Response; if (response == null) { return; } RequestDetailsLogger current = RequestDetailsLoggerBase <RequestDetailsLogger> .GetCurrent(httpContext); RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(current, "OnEndRequest.Start.ContentType", response.ContentType); if (response.Headers["X-RemotePS-RevisedAction"] != null) { RequestDetailsLoggerBase <RequestDetailsLogger> .SafeSetLogger(current, HttpProxyMetadata.ProtocolAction, response.Headers["X-RemotePS-RevisedAction"]); } bool flag = httpContext.Items.Contains("X-HeaderPreSent") && (bool)httpContext.Items["X-HeaderPreSent"]; if (flag) { RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(current, "FriendlyError", "Skip-HeaderPreSent"); return; } try { int statusCode = response.StatusCode; int num; if (WinRMHelper.TryConvertStatusCode(statusCode, out num)) { ExTraceGlobals.VerboseTracer.TraceDebug <int, int>((long)this.GetHashCode(), "[RpsFriendlyErrorModule::OnEndRequest]: Convert status code from {0} to {1}.", statusCode, num); response.StatusCode = num; RequestDetailsLoggerBase <RequestDetailsLogger> .SafeSetLogger(current, ServiceCommonMetadata.HttpStatus, statusCode); } if (statusCode >= 400 && !"Ping".Equals(response.Headers["X-RemotePS-Ping"], StringComparison.OrdinalIgnoreCase) && !"Possible-Ping".Equals(response.Headers["X-RemotePS-Ping"], StringComparison.OrdinalIgnoreCase)) { response.ContentType = "application/soap+xml;charset=UTF-8"; if (!WinRMHelper.DiagnosticsInfoHasBeenWritten(response.Headers)) { string diagnosticsInfo = WinRMHelper.GetDiagnosticsInfo(httpContext); ExTraceGlobals.VerboseTracer.TraceDebug <int, string>((long)this.GetHashCode(), "[RpsFriendlyErrorModule::OnEndRequest]: Original Status Code: {0}, Append diagnostics info: {1}.", statusCode, diagnosticsInfo); if (statusCode == 401) { response.Output.Write(diagnosticsInfo + HttpProxyStrings.ErrorAccessDenied); } else { response.Output.Write(diagnosticsInfo); } RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(current, "FriendlyError", "HttpModule"); } } } catch (Exception ex) { ExTraceGlobals.VerboseTracer.TraceError <Exception>((long)this.GetHashCode(), "[RpsFriendlyErrorModule::OnEndRequest]: Exception = {0}", ex); RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericError(current, "RpsFriendlyErrorModule.OnEndRequest", ex.Message); } finally { RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(current, "OnEndRequest.End.ContentType", response.ContentType); } }
private void OnEndRequest(object sender, EventArgs e) { HttpApplication httpApplication = (HttpApplication)sender; HttpContext httpContext = httpApplication.Context; Diagnostics.SendWatsonReportOnUnhandledException(delegate() { LatencyTracker latencyTracker = LatencyTracker.FromHttpContext(httpContext); RequestDetailsLogger current = RequestDetailsLoggerBase <RequestDetailsLogger> .GetCurrent(httpContext); int traceContext = httpContext.GetTraceContext(); if (HttpProxyGlobals.ProtocolType != ProtocolType.Mapi) { OwaProxyRequestHandler.TryAddUnAuthenticatedPLTRequestPostDataToUriQueryOfIISLog(httpContext); } if (httpContext.Response != null && current != null) { httpContext.Response.AppendToLog(Constants.RequestIdKeyForIISLogs + current.ActivityId.ToString() + ";"); } if (HealthCheckResponder.Instance.IsHealthCheckRequest(httpContext)) { return; } if (httpContext.Response.StatusCode == 404 && httpContext.Response.SubStatusCode == 13) { httpContext.Response.StatusCode = 507; } if (Microsoft.Exchange.Diagnostics.Components.HttpProxy.ExTraceGlobals.VerboseTracer.IsTraceEnabled(TraceType.DebugTrace)) { Microsoft.Exchange.Diagnostics.Components.HttpProxy.ExTraceGlobals.VerboseTracer.TraceDebug((long)this.GetHashCode(), "[ProxyModule::OnEndRequest]: Method {0}; Url {1}; Username {2}; Context {3};", new object[] { httpContext.Request.HttpMethod, httpContext.Request.Url, (httpContext.User == null) ? string.Empty : httpContext.User.Identity.GetSafeName(true), traceContext }); } if (latencyTracker != null) { long currentLatency = latencyTracker.GetCurrentLatency(LatencyTrackerKey.HandlerToModuleSwitchingLatency); if (currentLatency >= 0L) { RequestDetailsLoggerBase <RequestDetailsLogger> .SafeSetLogger(current, HttpProxyMetadata.HandlerToModuleSwitchingLatency, currentLatency); } } ProxyRequestHandler proxyRequestHandler = httpContext.CurrentHandler as ProxyRequestHandler; if (proxyRequestHandler != null && !proxyRequestHandler.IsDisposed) { current.AppendGenericInfo("DisposeProxyRequestHandler", "ProxyModule::OnEndRequest"); proxyRequestHandler.Dispose(); } string value = httpContext.Items["AnonymousRequestFilterModule"] as string; if (!string.IsNullOrEmpty(value)) { current.AppendGenericInfo("AnonymousRequestFilterModule", value); } try { this.OnEndRequestInternal(httpApplication); } finally { if (current != null && !current.IsDisposed) { IActivityScope activityScope = current.ActivityScope; if (activityScope != null) { if (!string.IsNullOrEmpty(activityScope.TenantId)) { httpContext.Items["AuthenticatedUserOrganization"] = activityScope.TenantId; } ProxyModule.FinalizeRequestLatencies(httpContext, current, activityScope, latencyTracker, traceContext); } current.LogCurrentTime("EndRequest"); current.AsyncCommit(false); } if (Microsoft.Exchange.Diagnostics.Components.HttpProxy.ExTraceGlobals.VerboseTracer.IsTraceEnabled(TraceType.DebugTrace)) { Microsoft.Exchange.Diagnostics.Components.HttpProxy.ExTraceGlobals.VerboseTracer.TraceDebug(0L, "[ProxyModule::OnEndRequest]: Method {0}; Url {1}; OnEndRequestLatency {2}; Context {3};", new object[] { httpContext.Request.HttpMethod, httpContext.Request.Url, (latencyTracker != null) ? latencyTracker.GetCurrentLatency(LatencyTrackerKey.ProxyModuleLatency).ToString() : "Unknown", traceContext }); } } }, new Diagnostics.LastChanceExceptionHandler(RequestDetailsLogger.LastChanceExceptionHandler)); }
// Token: 0x060006EE RID: 1774 RVA: 0x00028810 File Offset: 0x00026A10 protected override void AddProtocolSpecificHeadersToServerRequest(WebHeaderCollection headers) { if (base.ClientRequest.IsAuthenticated && base.ProxyToDownLevel) { IIdentity callerIdentity = this.GetCallerIdentity(); WindowsIdentity windowsIdentity = callerIdentity as WindowsIdentity; GenericSidIdentity genericSidIdentity = callerIdentity as GenericSidIdentity; IPrincipal user = base.HttpContext.User; if (windowsIdentity != null) { string text; if (HttpContextItemParser.TryGetLiveIdMemberName(base.HttpContext.Items, ref text)) { headers["X-RemotePS-GenericIdentity"] = windowsIdentity.User.ToString(); } else { headers["X-RemotePS-WindowsIdentity"] = this.GetSerializedAccessTokenString(); } } else if (genericSidIdentity != null) { headers["X-RemotePS-GenericIdentity"] = genericSidIdentity.Sid.ToString(); } else { headers["X-RemotePS-GenericIdentity"] = IIdentityExtensions.GetSafeName(base.HttpContext.User.Identity, true); } } if (this.isSyndicatedAdminManageDownLevelTarget) { headers["msExchCafeForceRouteToLogonAccount"] = "1"; } if (LoggerHelper.IsProbePingRequest(base.ClientRequest)) { RequestDetailsLoggerBase <RequestDetailsLogger> .SafeSetLogger(base.Logger, 21, "ProbePingBackend"); } else if (WinRMHelper.WinRMParserEnabled.Value) { try { this.winRMInfo = base.ParseClientRequest <WinRMInfo>(new Func <Stream, WinRMInfo>(this.ParseWinRMInfo), 10000); } catch (InvalidOperationException ex) { if (ExTraceGlobals.ExceptionTracer.IsTraceEnabled(3)) { ExTraceGlobals.ExceptionTracer.TraceError <InvalidOperationException>((long)this.GetHashCode(), "[RemotePowerShellProxyRequestHandler::AddProtocolSpecificHeadersToServerRequest] ParseClientRequest throws exception {0}", ex); } RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericError(base.Logger, "ParseClientRequestException", ex.ToString()); } if (this.winRMInfo != null) { WinRMInfo.StampToHttpHeaders(this.winRMInfo, headers); } } DatabaseBasedAnchorMailbox databaseBasedAnchorMailbox = base.AnchoredRoutingTarget.AnchorMailbox as DatabaseBasedAnchorMailbox; if (databaseBasedAnchorMailbox != null) { ADObjectId database = databaseBasedAnchorMailbox.GetDatabase(); if (database != null) { headers["X-DatabaseGuid"] = database.ObjectGuid.ToString(); } } if (!base.ShouldRetryOnError) { headers["X-Cafe-Last-Retry"] = "Y"; } base.AddProtocolSpecificHeadersToServerRequest(headers); }
// Token: 0x06001B8A RID: 7050 RVA: 0x00069B60 File Offset: 0x00067D60 private void SetLogValue(Enum key, object value) { RequestDetailsLoggerBase <RequestDetailsLogger> .SafeSetLogger(this.logger, key, value); }
// Token: 0x060005FB RID: 1531 RVA: 0x00021BD8 File Offset: 0x0001FDD8 private void OnEndRequest(object sender, EventArgs e) { HttpApplication httpApplication = (HttpApplication)sender; HttpContext httpContext = httpApplication.Context; CheckpointTracker.GetOrCreate(httpContext.Items).Add(FrontEndHttpProxyCheckpoints.ProxyModuleEndRequest); Diagnostics.SendWatsonReportOnUnhandledException(delegate() { if (!HostHeaderValidator.HasValidHostHeaderStatusDescription(new HttpContextWrapper(httpContext).Response) || httpContext.Items["AutodiscoverRedirectModule"] != null) { return; } LatencyTracker latencyTracker = LatencyTracker.FromHttpContext(httpContext); RequestDetailsLogger current = RequestDetailsLoggerBase <RequestDetailsLogger> .GetCurrent(httpContext); RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(RequestDetailsLoggerBase <RequestDetailsLogger> .GetCurrent(httpContext), GuardedSharedCacheExecution.Default.Key, GuardedSharedCacheExecution.Default.Guard.GetCurrentValue()); int traceContext = httpContext.GetTraceContext(); if (httpContext.Response != null && current != null) { httpContext.Response.AppendToLog(Constants.RequestIdKeyForIISLogs + current.ActivityId.ToString() + ";"); } if (HealthCheckResponder.Instance.IsHealthCheckRequest(httpContext)) { return; } if (httpContext.Response.StatusCode == 404 && httpContext.Response.SubStatusCode == 13) { httpContext.Response.StatusCode = 507; } if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1)) { ExTraceGlobals.VerboseTracer.TraceDebug((long)this.GetHashCode(), "[ProxyModule::OnEndRequest]: Method {0}; Url {1}; Username {2}; Context {3};", new object[] { httpContext.Request.HttpMethod, httpContext.Request.Url, (httpContext.User == null) ? string.Empty : IIdentityExtensions.GetSafeName(httpContext.User.Identity, true), traceContext }); } if (latencyTracker != null) { long currentLatency = latencyTracker.GetCurrentLatency(LatencyTrackerKey.HandlerToModuleSwitchingLatency); if (currentLatency >= 0L) { RequestDetailsLoggerBase <RequestDetailsLogger> .SafeSetLogger(current, 5, currentLatency); } } ProxyRequestHandler proxyRequestHandler = httpContext.CurrentHandler as ProxyRequestHandler; if (proxyRequestHandler != null && !proxyRequestHandler.IsDisposed) { current.AppendGenericInfo("DisposeProxyRequestHandler", "ProxyModule::OnEndRequest"); proxyRequestHandler.Dispose(); } ProxyModule.InspectNativeProxyFatalError(httpContext.Response, current); string text = httpContext.Items["AnonymousRequestFilterModule"] as string; if (!string.IsNullOrEmpty(text)) { current.AppendGenericInfo("AnonymousRequestFilterModule", text); } try { this.OnEndRequestInternal(httpApplication); } finally { if (current != null && !current.IsDisposed) { IActivityScope activityScope = current.ActivityScope; if (activityScope != null) { if (!string.IsNullOrEmpty(activityScope.TenantId)) { httpContext.Items["AuthenticatedUserOrganization"] = activityScope.TenantId; } ProxyModule.FinalizeRequestLatencies(httpContext, current, activityScope, latencyTracker, traceContext); } current.LogCurrentTime("EndRequest"); RequestDetailsLoggerBase <RequestDetailsLogger> .SafeSetLogger(current, 0, DateTime.UtcNow); current.AsyncCommit(false, NativeProxyHelper.WasProxiedByNativeProxyHandler(SharedHttpContextWrapper.GetWrapper(httpContext))); } if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1)) { ExTraceGlobals.VerboseTracer.TraceDebug(0L, "[ProxyModule::OnEndRequest]: Method {0}; Url {1}; OnEndRequestLatency {2}; Context {3};", new object[] { httpContext.Request.HttpMethod, httpContext.Request.Url, (latencyTracker != null) ? latencyTracker.GetCurrentLatency(LatencyTrackerKey.ProxyModuleLatency).ToString() : "Unknown", traceContext }); } } }, new Diagnostics.LastChanceExceptionHandler(RequestDetailsLogger.LastChanceExceptionHandler)); }
// Token: 0x060005F2 RID: 1522 RVA: 0x00021190 File Offset: 0x0001F390 private static void FinalizeRequestLatencies(HttpContext httpContext, RequestDetailsLogger requestDetailsLogger, IActivityScope activityScope, LatencyTracker tracker, int traceContext) { if (tracker == null) { return; } if (requestDetailsLogger == null) { throw new ArgumentNullException("requestDetailsLogger"); } if (activityScope == null) { throw new ArgumentNullException("activityScope"); } if (httpContext == null) { throw new ArgumentNullException("httpContext"); } HttpContextBase wrapper = SharedHttpContextWrapper.GetWrapper(httpContext); long num = tracker.GetCurrentLatency(LatencyTrackerKey.ProxyModuleLatency); if (num >= 0L) { long num2 = 0L; long.TryParse(activityScope.GetProperty(6), out num2); long num3 = 0L; bool flag = requestDetailsLogger.TryGetLatency(37, ref num3); long num4 = requestDetailsLogger.GetLatency(34, 0L) + requestDetailsLogger.GetLatency(36, 0L) + num3 + requestDetailsLogger.GetLatency(39, 0L) + requestDetailsLogger.GetLatency(40, 0L); long num5 = num - num4; if (!NativeProxyHelper.WasProxiedByNativeProxyHandler(wrapper)) { PerfCounters.UpdateMovingAveragePerformanceCounter(PerfCounters.HttpProxyCountersInstance.MovingAverageCasLatency, num5); } RequestDetailsLoggerBase <RequestDetailsLogger> .SafeSetLogger(requestDetailsLogger, 43, num5); long num6 = num5 - num2; if (flag) { RequestDetailsLoggerBase <RequestDetailsLogger> .SafeSetLogger(requestDetailsLogger, 42, Math.Max(num6, 0L)); string property = activityScope.GetProperty(13); if (PerfCounters.RoutingLatenciesEnabled && !string.IsNullOrEmpty(property)) { string empty = string.Empty; Utilities.TryExtractForestFqdnFromServerFqdn(property, ref empty); PercentilePerfCounters.UpdateRoutingLatencyPerfCounter(empty, (double)num6); PerfCounters.GetHttpProxyPerForestCountersInstance(empty).TotalProxyWithLatencyRequests.Increment(); } } long val = num6 - requestDetailsLogger.GetLatency(35, 0L) - requestDetailsLogger.GetLatency(38, 0L); RequestDetailsLoggerBase <RequestDetailsLogger> .SafeSetLogger(requestDetailsLogger, 41, Math.Max(val, 0L)); long currentLatency = tracker.GetCurrentLatency(LatencyTrackerKey.ProxyModuleLatency); long num7 = currentLatency - num; num = currentLatency; if (num7 > 5L) { RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(requestDetailsLogger, "TotalRequestTimeDelta", num7); } } RequestDetailsLoggerBase <RequestDetailsLogger> .SafeSetLogger(requestDetailsLogger, 16, num); }
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); } }