Build a end-to-end log to record system performance.

1. Web Trigger point .(the time point when user  click button)

  1>If the click is ajax post back

 Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);
        function BeginRequestHandler(sender, args)
        {
              pageCover.startProcessing('');
              var elem = args.get_postBackElement();
               //set begin time point and button id
        }

   2>If click is normal postback

       $(window).bind('beforeunload', handleOnbeforeunload);

2.IIS Request point (the time point when begin to execute in IIS)

        protected override void OnInit(EventArgs e)
        {
           preInitTime = DateTime.Now;//set the iis request time
           base.OnInit(e);
        }

 

3.IIS Response point (the time point when the business logic have finished)

        1>If it's ajax postback protected override object SaveViewState()
        {
          object obj = base.SaveViewState();
          //here add cookie for ajax postback 
          ActionLogHelper.SetCookieInResponse(preInitTime);//here set the time point
          return obj;
       }

       2>If it's normal postback

          protected override void Render(HtmlTextWriter writer)
         {
           base.Render(writer);
           //here for postback
           ActionLogHelper.SetCookieInResponse(preInitTime);
          }

4.Page begin to Render (Begin to render page.)

       1>If it's normal postback   add a javascript at the bottom of page

           <script type="text/javascript" language="javascript">
            var getRep=new Date();
          </script>

       2>If it's a ajax postback

            Sys.WebForms.PageRequestManager.getInstance().add_pageLoading(pageLoadingHandler)
            function pageLoadingHandler(sender, args)
           {
               getRep=new Date();
           }

5.Finish page render.

    1>If it's ajax postback

      Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
        function EndRequestHandler(sender, args)
        {

          SendLogAndClear();

        }           

   2>If it's normal postback

        <script type="text/javascript" language="javascript">
         //rem the time get response
         $(window).bind('load', function() {SendLogAndClear();});
        </script>

6.After the above five step call method to save the data .

 $.post($I('ctl00_actionLogUrl').value+'?  userId='+userId+'&ipAddress='+ipAddress+'&accessWebPage='+accessWebPage+'&lastWebPage='+lastWebPage+'&requestType='+requestType+'&eventSource='+eventSource+'&webTriggerPoint='+webTriggerPoint+'&webGetRepPoint='+webGetRepPoint+'&webLoadedPoint='+webLoadedPoint+'&iisRecReqPoint='+iisRecReqPoint+'&iisResponsePoint='+iisResponsePoint+'&reqSize='+reqSize+'&respSize='+respSize);

 

Remark:

We can get these five time point after ia transaction, And

D2-D1: url request time

D3-D2: business logic execute time.

D5-D4: Page render ui time.

 

posted @ 2010-01-11 15:11  C.fly  阅读(237)  评论(0编辑  收藏  举报