Пример #1
0
        /// <summary>
        /// Returns an HTML string to insert into the response body that will display
        /// the info gathered by WebStats.
        /// </summary>
        /// <param name="requestID"></param>
        /// <returns></returns>
        public string GetStatsWidget(string requestID)
        {
            var current     = Measurements.GetCurrentResponseSize();
            var min         = Measurements.GetMinResponseSize();
            var avg         = Measurements.GetAverageResponseSize();
            var max         = Measurements.GetMaxResponseSize();
            var moduleTime  = Measurements.GetModuleProcessingTime(requestID);
            var requestTime = Measurements.GetRequestProcessingTime(requestID);

            return(WidgetContent
                   .Replace("{currentResponseSize}", string.Format("{0:n0}", current))
                   .Replace("{minResponseSize}", string.Format("{0:n0}", min))
                   .Replace("{averageResponseSize}", string.Format("{0:n}", avg))
                   .Replace("{maxResponseSize}", string.Format("{0:n0}", max))
                   .Replace("{moduleTime}", string.Format("{0:n4}", moduleTime))
                   .Replace("{requestTime}", string.Format("{0:n4}", requestTime)));
        }
Пример #2
0
        public void ProcessRequestEnd()
        {
            // Get request ID from the headers.
            var requestID = Context.Request.Headers["WebStatsRequestID"];

            Measurements.LogModuleStart(requestID);

            Measurements.LogResponseSize((Context.Response.Filter as MeasurementFilter).BytesWritten);


            if (Context.Response.ContentType == "text/html")
            {
                var statsHTML = HtmlGenerator.GetStatsWidget(requestID);

                Context.Response.Write(statsHTML);
            }

            CleanupApplicationState(requestID);
        }