示例#1
0
        private void OnEndRequest(object sender, EventArgs e)
        {
            ExTraceGlobals.ReportingWebServiceTracer.TraceDebug((long)this.GetHashCode(), "ReportingModule.OnEndRequest");
            HttpApplication httpApplication = (HttpApplication)sender;
            HttpContext     context         = httpApplication.Context;

            ReportingVersion.WriteVersionInfoInResponse(context);
            ReportingModule.activeRequestsCounter.Decrement();
            this.averageRequestTime.Stop();
            RequestStatistics requestStatistics = HttpContext.Current.Items[RequestStatistics.RequestStatsKey] as RequestStatistics;

            if (requestStatistics != null)
            {
                requestStatistics.AddStatisticsDataPoint(RequestStatistics.RequestStatItem.RequestResponseTime, this.requestStartTime, DateTime.UtcNow);
                requestStatistics.AddExtendedStatisticsDataPoint("HTTPCODE", context.Response.StatusCode.ToString());
                IPrincipal     user     = context.User;
                string         text     = context.Request.Headers["X-SourceCafeServer"];
                ServerLogEvent logEvent = new ServerLogEvent((ActivityContext.ActivityId != null) ? ActivityContext.ActivityId.Value.ToString() : string.Empty, string.IsNullOrEmpty(text) ? string.Empty : text, requestStatistics);
                ServerLogger.Instance.LogEvent(logEvent);
            }
            if (this.activityScope != null && !this.activityScope.IsDisposed)
            {
                this.activityScope.End();
            }
            ExTraceGlobals.ReportingWebServiceTracer.TraceDebug((long)this.GetHashCode(), "ReportingModule.OnEndRequest - End");
        }
        public static void Watch(RequestStatistics.RequestStatItem name, Action action)
        {
            DateTime utcNow = DateTime.UtcNow;

            action();
            if (HttpContext.Current != null && HttpContext.Current.Items != null)
            {
                RequestStatistics requestStatistics = HttpContext.Current.Items[RequestStatistics.RequestStatsKey] as RequestStatistics;
                if (requestStatistics != null)
                {
                    requestStatistics.AddStatisticsDataPoint(name, utcNow, DateTime.UtcNow);
                }
            }
        }