Esempio n. 1
0
        // Token: 0x0600025B RID: 603 RVA: 0x0000FDDC File Offset: 0x0000DFDC
        private void Application_BeginRequest(object sender, EventArgs e)
        {
            RequestDetailsLoggerBase <RequestDetailsLogger> .InitializeRequestLogger();

            RequestDetailsLoggerBase <RequestDetailsLogger> .Current.ActivityScope.UpdateFromMessage(HttpContext.Current.Request);

            RequestDetailsLoggerBase <RequestDetailsLogger> .Current.ActivityScope.SerializeTo(HttpContext.Current.Response);

            string sourceCafeServer = CafeHelper.GetSourceCafeServer(HttpContext.Current.Request);

            if (!string.IsNullOrEmpty(sourceCafeServer))
            {
                RequestDetailsLoggerBase <RequestDetailsLogger> .Current.Set(AutoDiscoverMetadata.FrontEndServer, sourceCafeServer);
            }
            Microsoft.Exchange.Diagnostics.Components.Autodiscover.ExTraceGlobals.FrameworkTracer.TraceDebug <string, string>((long)this.GetHashCode(), "[Application_BeginRequest()] Request.Path=\"{0}\"; Request.PhysicalPath=\"{1}\";", base.Request.Path, base.Request.PhysicalPath);
            int    num      = base.Request.Path.IndexOf('\\');
            string fullPath = Path.GetFullPath(base.Request.PhysicalPath);

            if (num >= 0 || fullPath != base.Request.PhysicalPath)
            {
                Microsoft.Exchange.Diagnostics.Components.Autodiscover.ExTraceGlobals.FrameworkTracer.TraceError <int, string>((long)this.GetHashCode(), "[Application_BeginRequest()] IndexOf('\\')={0};FullPath=\"{1}\"; // Throwing 404 HttpException", num, fullPath);
                this.exception = new HttpException(404, string.Empty);
                throw this.exception;
            }
        }
Esempio n. 2
0
        internal static void InitializeRequestLogger()
        {
            if (!LoggerSettings.LogEnabled)
            {
                return;
            }
            if (LoggerSettings.IsPowerShellWebService)
            {
                RequestDetailsLoggerBase <PswsLogger> .InitializeRequestLogger();

                return;
            }
            RequestDetailsLoggerBase <RpsHttpLogger> .InitializeRequestLogger();
        }
Esempio n. 3
0
        private void OnBeginRequest(object sender, EventArgs e)
        {
            HttpApplication httpApplication = (HttpApplication)sender;
            HttpContext     httpContext     = httpApplication.Context;

            Diagnostics.SendWatsonReportOnUnhandledException(delegate()
            {
                LatencyTracker latencyTracker = new LatencyTracker();
                latencyTracker.StartTracking(LatencyTrackerKey.ProxyModuleLatency, false);
                AspNetHelper.AddTimestampHeaderIfNecessary(httpContext.Request.Headers, "X-FrontEnd-Begin");
                if (Microsoft.Exchange.Diagnostics.Components.HttpProxy.ExTraceGlobals.VerboseTracer.IsTraceEnabled(TraceType.DebugTrace))
                {
                    Microsoft.Exchange.Diagnostics.Components.HttpProxy.ExTraceGlobals.VerboseTracer.TraceDebug <string, Uri, int>((long)this.GetHashCode(), "[ProxyModule::OnBeginRequest]: Method {0}; Url {1}; Context {2};", httpContext.Request.HttpMethod, httpContext.Request.Url, httpContext.GetHashCode());
                }
                if (HealthCheckResponder.Instance.IsHealthCheckRequest(httpContext))
                {
                    HealthCheckResponder.Instance.CheckHealthStateAndRespond(httpContext);
                    return;
                }
                RequestDetailsLogger requestDetailsLogger = RequestDetailsLoggerBase <RequestDetailsLogger> .InitializeRequestLogger();
                requestDetailsLogger.LogCurrentTime("BeginRequest");
                httpContext.Items[Constants.TraceContextKey] = httpContext.GetHashCode();
                httpContext.Items[Constants.LatencyTrackerContextKeyName] = latencyTracker;
                requestDetailsLogger.ActivityScope.UpdateFromMessage(httpContext.Request);
                requestDetailsLogger.ActivityScope.SerializeTo(httpContext.Response);
                RequestDetailsLoggerBase <RequestDetailsLogger> .SetCurrent(httpContext, requestDetailsLogger);
                httpContext.Items[typeof(ActivityScope)] = requestDetailsLogger.ActivityScope;
                httpContext.Items[Constants.RequestIdHttpContextKeyName] = requestDetailsLogger.ActivityScope.ActivityId;
                RequestDetailsLoggerBase <RequestDetailsLogger> .SafeSetLogger(requestDetailsLogger, HttpProxyMetadata.Protocol, HttpProxyGlobals.ProtocolType);
                requestDetailsLogger.SafeLogUriData(httpContext.Request.Url);
                RequestDetailsLoggerBase <RequestDetailsLogger> .SafeSetLogger(requestDetailsLogger, ServiceCommonMetadata.HttpMethod, httpContext.Request.HttpMethod);
                string requestCorrelationId = AspNetHelper.GetRequestCorrelationId(httpContext);
                RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(requestDetailsLogger, "CorrelationID", requestCorrelationId);
                httpContext.Response.AppendToLog(Constants.CorrelationIdKeyForIISLogs + requestCorrelationId + ";");
                string cookieValueAndSetIfNull = ClientIdCookie.GetCookieValueAndSetIfNull(httpContext);
                httpContext.Response.AppendToLog(string.Format("&{0}={1}", "ClientId", cookieValueAndSetIfNull));
                UrlUtilities.SaveOriginalRequestHostSchemePortToContext(httpContext);
                try
                {
                    this.OnBeginRequestInternal(httpApplication);
                }
                catch (Exception ex)
                {
                    RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericError(requestDetailsLogger, "OnBeginRequestInternal", ex.ToString());
                    requestDetailsLogger.AsyncCommit(false);
                    throw;
                }
            }, new Diagnostics.LastChanceExceptionHandler(RequestDetailsLogger.LastChanceExceptionHandler));
        }
Esempio n. 4
0
 internal static void InitializeRequestLogger()
 {
     if (!LoggerSettings.LogEnabled)
     {
         return;
     }
     if (LoggerSettings.IsRemotePS)
     {
         IActivityScope activityScope = null;
         if (!ActivityContext.IsStarted)
         {
             ActivityContext.ClearThreadScope();
             activityScope = ActivityContext.Start(null);
         }
         RequestDetailsLoggerBase <RpsAuthZLogger> .InitializeRequestLogger(activityScope ?? ActivityContext.GetCurrentActivityScope());
     }
 }
        private static RequestDetailsLogger GetRequestDetailsLogger(string eventId, IMailboxContext userContext, string primarySmtpAddress, out bool commitLogger)
        {
            RequestDetailsLogger requestDetailsLogger = OwaApplication.GetRequestDetailsLogger;

            if (requestDetailsLogger != null && !requestDetailsLogger.IsDisposed)
            {
                commitLogger = false;
                requestDetailsLogger.AppendGenericInfo("NestedCallback", eventId);
            }
            else
            {
                commitLogger = true;
                ActivityContext.ClearThreadScope();
                requestDetailsLogger = RequestDetailsLoggerBase <RequestDetailsLogger> .InitializeRequestLogger();

                requestDetailsLogger.ActivityScope.UserEmail = primarySmtpAddress;
                requestDetailsLogger.Set(ExtensibleLoggerMetadata.EventId, eventId);
                requestDetailsLogger.Set(OwaServerLogger.LoggerData.PrimarySmtpAddress, primarySmtpAddress);
                requestDetailsLogger.Set(OwaServerLogger.LoggerData.UserContext, userContext.Key);
            }
            return(requestDetailsLogger);
        }
        internal static void ExecuteWithoutUserContext(string eventId, Action <RequestDetailsLogger> action)
        {
            RequestDetailsLogger logger = OwaApplication.GetRequestDetailsLogger;

            ActivityContext.ClearThreadScope();
            logger = RequestDetailsLoggerBase <RequestDetailsLogger> .InitializeRequestLogger();

            try
            {
                OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
                {
                    action(logger);
                });
            }
            catch (GrayException ex)
            {
                SimulatedWebRequestContext.ProcessException(logger, eventId, ex.InnerException);
            }
            finally
            {
                logger.Commit();
            }
        }
 // Token: 0x06001159 RID: 4441 RVA: 0x000428F8 File Offset: 0x00040AF8
 internal override void ExecuteApplicationBeginRequest(object sender, EventArgs e)
 {
     try
     {
         OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
         {
             RequestDetailsLoggerBase <RequestDetailsLogger> .InitializeRequestLogger();
             RequestDetailsLogger getRequestDetailsLogger = OwaApplication.GetRequestDetailsLogger;
             getRequestDetailsLogger.ActivityScope.UpdateFromMessage(HttpContext.Current.Request);
             getRequestDetailsLogger.ActivityScope.SerializeTo(HttpContext.Current.Response);
             getRequestDetailsLogger.ActivityScope.SetProperty(OwaServerLogger.LoggerData.IsRequest, "1");
             string requestCorrelationId = HttpUtilities.GetRequestCorrelationId(HttpContext.Current);
             getRequestDetailsLogger.Set(OwaServerLogger.LoggerData.CorrelationId, requestCorrelationId);
             getRequestDetailsLogger.Set(OwaServerLogger.LoggerData.RequestStartTime, DateTime.UtcNow);
             HttpContext.Current.Response.AppendToLog("&ActID=" + getRequestDetailsLogger.ActivityId);
             HttpContext.Current.Response.AppendToLog("&CorrelationID=" + requestCorrelationId);
         });
     }
     catch (GrayException arg)
     {
         ExTraceGlobals.ConfigurationManagerTracer.TraceDebug <GrayException>(0L, "OwaApplication.ExecuteApplicationBeginRequest: GrayException: {0}", arg);
         throw;
     }
 }
 public void OnBeginRequest(HttpContextBase context)
 {
     ExWatson.SendReportOnUnhandledException(delegate()
     {
         RequestDetailsLogger requestDetailsLogger         = null;
         RoutingUpdateDiagnostics routingUpdateDiagnostics = this.diagnostics as RoutingUpdateDiagnostics;
         if (routingUpdateDiagnostics != null)
         {
             HttpContext context2 = context.ApplicationInstance.Context;
             requestDetailsLogger = RequestDetailsLoggerBase <RequestDetailsLogger> .InitializeRequestLogger();
             RequestDetailsLoggerBase <RequestDetailsLogger> .SetCurrent(context2, requestDetailsLogger);
             requestDetailsLogger.Set(RoutingUpdateModuleMetadata.Protocol, RequestDetailsLogger.ProtocolType.Value);
             routingUpdateDiagnostics.Clear();
         }
         NameValueCollection headers = context.Request.Headers;
         List <string> list          = new List <string>();
         list.AddIfNotNull(headers.Get("X-RoutingEntry"));
         if (RoutingUpdateModule.RUMLegacyRoutingEntryEnabled.Value)
         {
             list.AddIfNotNull(headers.Get("X-LegacyRoutingEntry"));
         }
         if (list.Count > 0)
         {
             try
             {
                 foreach (string text in list)
                 {
                     string[] source = text.Split(new char[]
                     {
                         ','
                     });
                     IEnumerable <IRoutingEntry> routingEntries = from entry in source
                                                                  where RoutingEntryHeaderSerializer.IsValidHeaderString(entry)
                                                                  select RoutingEntryHeaderSerializer.Deserialize(entry);
                     foreach (string value in this.GetRoutingUpdates(routingEntries))
                     {
                         context.Response.Headers.Add("X-RoutingEntryUpdate", value);
                     }
                 }
             }
             catch (Exception ex)
             {
                 requestDetailsLogger.AppendGenericError("Exception", ex.ToString());
                 throw;
             }
         }
         if (routingUpdateDiagnostics != null && !requestDetailsLogger.IsDisposed)
         {
             if (routingUpdateDiagnostics.GetTotalLatency() > 0L)
             {
                 routingUpdateDiagnostics.LogLatencies(requestDetailsLogger);
                 requestDetailsLogger.Commit();
             }
             else
             {
                 requestDetailsLogger.SkipLogging = true;
             }
             requestDetailsLogger.Dispose();
         }
     });
 }
Esempio n. 9
0
        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);
            }
        }