You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by lars vonk <la...@gmail.com> on 2008/01/30 10:13:20 UTC

Re: Monitoring Wicket using JAMon

Hi,

I came up with two possible candidate methods to put in JAMon monitoring.

The:

1. ISessionStore.onBeginRequest and ISessionStore.onEndRequest
2. RequestCycle.onBeginRequest and RequestCycle.onEndRequest.

For now I choose to override the ISessionStore because that one is
called before and after the RequestCycle methods. I want to check with
you guys if this is the best option or not. Which one do you
recommend? Is there maybe another candidate I overlooked?


Thanks, Lars

On Dec 24, 2007 5:45 PM, lars vonk <la...@gmail.com> wrote:
> Hi all,
>
> I am currently monitoring some spring beans in our application using
> JAMon (http://jamonapi.sourceforge.net/). To get a complete oversight
> I would like to measure the entry and exit point of a single page in
> my JAMon report.
> In the report I'd like to group the webrequest per page. I was
> stepping through the wicket source code but could not find a good
> point to intercept and put in my JAMon monitoring code.
> So my question is: What is the best point in wicket to monitor? I was
> thinking about the doGet of the WicketFilter it self, since that is
> the entry point. But how do I get hold of the requested page name
> there?  I also looked at the RequestCycle.request, but since that
> method is final I can't intercept it.
>
> Any other suggestions are welcome.
>
> Thanks, Lars
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Monitoring Wicket using JAMon

Posted by Ryan Sonnek <ry...@gmail.com>.
I'd be happy to help if you need any since I commit to a few separate
wicketstuff projects, but applying for your own commit access would
probably be best.

On Mon, Feb 25, 2008 at 10:45 AM, lars vonk <la...@gmail.com> wrote:
> I would be glad to contribute something. Are you related to the
>  wicketstuff project? Or should I just appy for commit access as
>  described on: http://wicketstuff.org/confluence/display/STUFFWEB/Home.
>
>  Cheers, Lars
>
>
>
>  On Mon, Feb 25, 2008 at 5:00 PM, Ryan Sonnek <ry...@gmail.com> wrote:
>  > I've been looking at doing something similar to this in my
>  >  application.  any thoughts on contributing this to a new wicketstuff
>  >  project?
>  >
>  >
>  >
>  >  On Thu, Jan 31, 2008 at 9:14 AM, Johan Compagner <jc...@gmail.com> wrote:
>  >  > >
>  >  >  > I am not sure if I follow you here. What do you mean by testing two
>  >  >  > pages? Here is how I think it works (and want it to work):
>  >  >  >
>  >  >  > 1. User clicks on component on Page1 that will result in navigating to
>  >  >  > Page2. In this case JAMon shows:  Page2  30ms.
>  >  >  > 2. User clicks on component on Page2 that will result in a refresh
>  >  >  > (ajax or not) of Page2. IN this case JAMon shows: Page2 30 ms.
>  >  >  >
>  >  >  >
>  >  >  yes in situation 2 you are testing page2 completely, so the request phase
>  >  >  (handling of the click event)
>  >  >  and the response phase (the render of page2)
>  >  >
>  >  >  but in situation 1 you are testing the request phase of page1 (the click
>  >  >  event)
>  >  >  and then the rendering of pag2 (thats the respond)
>  >  >
>  >  >  And it all depends what takes a lot of time, is it the render because loads
>  >  >  of new data is queried from the db
>  >  >  with loads of stuff on the page. Or is it the action that does a heavy query
>  >  >  or other backend action?
>  >  >
>  >  >  johan
>  >  >
>  >
>  >
>  >
>
>
> > ---------------------------------------------------------------------
>  >  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>  >  For additional commands, e-mail: users-help@wicket.apache.org
>  >
>  >
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>  For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Monitoring Wicket using JAMon

Posted by lars vonk <la...@gmail.com>.
I would be glad to contribute something. Are you related to the
wicketstuff project? Or should I just appy for commit access as
described on: http://wicketstuff.org/confluence/display/STUFFWEB/Home.

Cheers, Lars

On Mon, Feb 25, 2008 at 5:00 PM, Ryan Sonnek <ry...@gmail.com> wrote:
> I've been looking at doing something similar to this in my
>  application.  any thoughts on contributing this to a new wicketstuff
>  project?
>
>
>
>  On Thu, Jan 31, 2008 at 9:14 AM, Johan Compagner <jc...@gmail.com> wrote:
>  > >
>  >  > I am not sure if I follow you here. What do you mean by testing two
>  >  > pages? Here is how I think it works (and want it to work):
>  >  >
>  >  > 1. User clicks on component on Page1 that will result in navigating to
>  >  > Page2. In this case JAMon shows:  Page2  30ms.
>  >  > 2. User clicks on component on Page2 that will result in a refresh
>  >  > (ajax or not) of Page2. IN this case JAMon shows: Page2 30 ms.
>  >  >
>  >  >
>  >  yes in situation 2 you are testing page2 completely, so the request phase
>  >  (handling of the click event)
>  >  and the response phase (the render of page2)
>  >
>  >  but in situation 1 you are testing the request phase of page1 (the click
>  >  event)
>  >  and then the rendering of pag2 (thats the respond)
>  >
>  >  And it all depends what takes a lot of time, is it the render because loads
>  >  of new data is queried from the db
>  >  with loads of stuff on the page. Or is it the action that does a heavy query
>  >  or other backend action?
>  >
>  >  johan
>  >
>
>
>
> ---------------------------------------------------------------------
>  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>  For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Monitoring Wicket using JAMon

Posted by Ryan Sonnek <ry...@gmail.com>.
I've been looking at doing something similar to this in my
application.  any thoughts on contributing this to a new wicketstuff
project?

On Thu, Jan 31, 2008 at 9:14 AM, Johan Compagner <jc...@gmail.com> wrote:
> >
>  > I am not sure if I follow you here. What do you mean by testing two
>  > pages? Here is how I think it works (and want it to work):
>  >
>  > 1. User clicks on component on Page1 that will result in navigating to
>  > Page2. In this case JAMon shows:  Page2  30ms.
>  > 2. User clicks on component on Page2 that will result in a refresh
>  > (ajax or not) of Page2. IN this case JAMon shows: Page2 30 ms.
>  >
>  >
>  yes in situation 2 you are testing page2 completely, so the request phase
>  (handling of the click event)
>  and the response phase (the render of page2)
>
>  but in situation 1 you are testing the request phase of page1 (the click
>  event)
>  and then the rendering of pag2 (thats the respond)
>
>  And it all depends what takes a lot of time, is it the render because loads
>  of new data is queried from the db
>  with loads of stuff on the page. Or is it the action that does a heavy query
>  or other backend action?
>
>  johan
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Monitoring Wicket using JAMon

Posted by Johan Compagner <jc...@gmail.com>.
>
> I am not sure if I follow you here. What do you mean by testing two
> pages? Here is how I think it works (and want it to work):
>
> 1. User clicks on component on Page1 that will result in navigating to
> Page2. In this case JAMon shows:  Page2  30ms.
> 2. User clicks on component on Page2 that will result in a refresh
> (ajax or not) of Page2. IN this case JAMon shows: Page2 30 ms.
>
>
yes in situation 2 you are testing page2 completely, so the request phase
(handling of the click event)
and the response phase (the render of page2)

but in situation 1 you are testing the request phase of page1 (the click
event)
and then the rendering of pag2 (thats the respond)

And it all depends what takes a lot of time, is it the render because loads
of new data is queried from the db
with loads of stuff on the page. Or is it the action that does a heavy query
or other backend action?

johan

Re: Monitoring Wicket using JAMon

Posted by lars vonk <la...@gmail.com>.
Response inline

On Jan 31, 2008 2:24 PM, Johan Compagner <jc...@gmail.com> wrote:
> no you dont need the threadlocal
> WebRequestCycle is already a thread local thats only used for one request
> so in your WebRequestCycle you can have a start time. (onBeginRequest)
> and then in onEndRequest you do your calculation.
>
Thanks for the explanation.

> The problem that i see is that that time covers 2 things. 1 the request
> phase on the page of the component that is clicked on
> and the response page that could be again that same page but could also be a
> completely different one.
> So at that time you are testing 2 pages
>

I am not sure if I follow you here. What do you mean by testing two
pages? Here is how I think it works (and want it to work):

1. User clicks on component on Page1 that will result in navigating to
Page2. In this case JAMon shows:  Page2  30ms.
2. User clicks on component on Page2 that will result in a refresh
(ajax or not) of Page2. IN this case JAMon shows: Page2 30 ms.

In my understanding I measure the time it takes to handle a complete
request-respone cycle.

Lars



> johan
>
>
>
>
> On Jan 31, 2008 1:32 PM, lars vonk <la...@gmail.com> wrote:
>
> > Hi thanks for the replies,
> >
> > Yes I want to do it per Page so I can monitor the performance per page.
> >
> > Here is how I implemented it, I am not sure if I always get the name
> > of the Page name in the implementation of onEndRequest. (Allthough
> > during tests I always got the name of the Page.)
> >
> > public class JAMonMonitoredWebRequestCycle extends WebRequestCycle {
> >
> >    static final String UNIT = "ms.";
> >
> >    private ThreadLocal<Long> startTimes = new ThreadLocal<Long>();
> >
> >    public JAMonMonitoredWebRequestCycle(WebApplication application,
> > WebRequest request, Response response) {
> >        super(application, request, response);
> >    }
> >
> >    @Override
> >    protected void onBeginRequest() {
> >        super.onBeginRequest();
> >        addStartTimeToThreadLocal();
> >    }
> >
> >    @Override
> >    protected void onEndRequest() {
> >        super.onEndRequest();
> >        calculateDurationAndAddToMonitor();
> >    }
> >
> >
> >    private void addStartTimeToThreadLocal() {
> >        startTimes.set(System.currentTimeMillis());
> >    }
> >
> >    private void calculateDurationAndAddToMonitor() {
> >        if(startTimes.get() != null) {
> >            Class<?> pageClass = null;
> >            if(getWebResponse().isAjax() && getWebRequest().getPage() !=
> > null) {
> >                pageClass = getWebRequest().getPage().getClass();
> >            } else {
> >                pageClass = getResponsePageClass();
> >            }
> >            if(pageClass != null) {
> >                MonitorFactory.add(pageClass.toString(), UNIT,
> > System.currentTimeMillis() - startTimes.get().doubleValue());
> >            }
> >            startTimes.set(null);
> >        }
> >    }
> >
> > }
> >
> >
> > I believe the Page to be rendered is not availble yet in the
> > onBeginRequest so I use MonitorFactory.add() in the onEndRequest and
> > store the startTime in a ThreadLocal. While typing this email I am
> > thinking that WebRequestCycle is statefull so I probably do need the
> > ThreadLocal right?
> >
> > Lars
> >
> > On Jan 30, 2008 8:22 PM, Eelco Hillenius <ee...@gmail.com>
> > wrote:
> > > On Jan 30, 2008 11:20 AM, Igor Vaynberg <ig...@gmail.com> wrote:
> > > > but per page...
> > >
> > > Why don't you just answer then.
> > >
> > >
> > > Eelco
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > For additional commands, e-mail: users-help@wicket.apache.org
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Monitoring Wicket using JAMon

Posted by Johan Compagner <jc...@gmail.com>.
no you dont need the threadlocal
WebRequestCycle is already a thread local thats only used for one request
so in your WebRequestCycle you can have a start time. (onBeginRequest)
and then in onEndRequest you do your calculation.

The problem that i see is that that time covers 2 things. 1 the request
phase on the page of the component that is clicked on
and the response page that could be again that same page but could also be a
completely different one.
So at that time you are testing 2 pages

johan



On Jan 31, 2008 1:32 PM, lars vonk <la...@gmail.com> wrote:

> Hi thanks for the replies,
>
> Yes I want to do it per Page so I can monitor the performance per page.
>
> Here is how I implemented it, I am not sure if I always get the name
> of the Page name in the implementation of onEndRequest. (Allthough
> during tests I always got the name of the Page.)
>
> public class JAMonMonitoredWebRequestCycle extends WebRequestCycle {
>
>    static final String UNIT = "ms.";
>
>    private ThreadLocal<Long> startTimes = new ThreadLocal<Long>();
>
>    public JAMonMonitoredWebRequestCycle(WebApplication application,
> WebRequest request, Response response) {
>        super(application, request, response);
>    }
>
>    @Override
>    protected void onBeginRequest() {
>        super.onBeginRequest();
>        addStartTimeToThreadLocal();
>    }
>
>    @Override
>    protected void onEndRequest() {
>        super.onEndRequest();
>        calculateDurationAndAddToMonitor();
>    }
>
>
>    private void addStartTimeToThreadLocal() {
>        startTimes.set(System.currentTimeMillis());
>    }
>
>    private void calculateDurationAndAddToMonitor() {
>        if(startTimes.get() != null) {
>            Class<?> pageClass = null;
>            if(getWebResponse().isAjax() && getWebRequest().getPage() !=
> null) {
>                pageClass = getWebRequest().getPage().getClass();
>            } else {
>                pageClass = getResponsePageClass();
>            }
>            if(pageClass != null) {
>                MonitorFactory.add(pageClass.toString(), UNIT,
> System.currentTimeMillis() - startTimes.get().doubleValue());
>            }
>            startTimes.set(null);
>        }
>    }
>
> }
>
>
> I believe the Page to be rendered is not availble yet in the
> onBeginRequest so I use MonitorFactory.add() in the onEndRequest and
> store the startTime in a ThreadLocal. While typing this email I am
> thinking that WebRequestCycle is statefull so I probably do need the
> ThreadLocal right?
>
> Lars
>
> On Jan 30, 2008 8:22 PM, Eelco Hillenius <ee...@gmail.com>
> wrote:
> > On Jan 30, 2008 11:20 AM, Igor Vaynberg <ig...@gmail.com> wrote:
> > > but per page...
> >
> > Why don't you just answer then.
> >
> >
> > Eelco
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Monitoring Wicket using JAMon

Posted by lars vonk <la...@gmail.com>.
Hi thanks for the replies,

Yes I want to do it per Page so I can monitor the performance per page.

Here is how I implemented it, I am not sure if I always get the name
of the Page name in the implementation of onEndRequest. (Allthough
during tests I always got the name of the Page.)

public class JAMonMonitoredWebRequestCycle extends WebRequestCycle {

    static final String UNIT = "ms.";

    private ThreadLocal<Long> startTimes = new ThreadLocal<Long>();

    public JAMonMonitoredWebRequestCycle(WebApplication application,
WebRequest request, Response response) {
        super(application, request, response);
    }

    @Override
    protected void onBeginRequest() {
        super.onBeginRequest();
        addStartTimeToThreadLocal();
    }

    @Override
    protected void onEndRequest() {
        super.onEndRequest();
        calculateDurationAndAddToMonitor();
    }


    private void addStartTimeToThreadLocal() {
        startTimes.set(System.currentTimeMillis());
    }

    private void calculateDurationAndAddToMonitor() {
        if(startTimes.get() != null) {
            Class<?> pageClass = null;
            if(getWebResponse().isAjax() && getWebRequest().getPage() != null) {
                pageClass = getWebRequest().getPage().getClass();
            } else {
                pageClass = getResponsePageClass();
            }
            if(pageClass != null) {
                MonitorFactory.add(pageClass.toString(), UNIT,
System.currentTimeMillis() - startTimes.get().doubleValue());
            }
            startTimes.set(null);
        }
    }

}


I believe the Page to be rendered is not availble yet in the
onBeginRequest so I use MonitorFactory.add() in the onEndRequest and
store the startTime in a ThreadLocal. While typing this email I am
thinking that WebRequestCycle is statefull so I probably do need the
ThreadLocal right?

Lars

On Jan 30, 2008 8:22 PM, Eelco Hillenius <ee...@gmail.com> wrote:
> On Jan 30, 2008 11:20 AM, Igor Vaynberg <ig...@gmail.com> wrote:
> > but per page...
>
> Why don't you just answer then.
>
>
> Eelco
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Monitoring Wicket using JAMon

Posted by Eelco Hillenius <ee...@gmail.com>.
On Jan 30, 2008 11:20 AM, Igor Vaynberg <ig...@gmail.com> wrote:
> but per page...

Why don't you just answer then.

Eelco

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Monitoring Wicket using JAMon

Posted by Igor Vaynberg <ig...@gmail.com>.
but per page...

-igor


On Jan 30, 2008 11:18 AM, Eelco Hillenius <ee...@gmail.com> wrote:
> On Jan 30, 2008 11:14 AM, Igor Vaynberg <ig...@gmail.com> wrote:
> > because he wants to know what page instance was accessed?
>
> He wants to monitor performance of requests from what I read.
>
>
> Eelco
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Monitoring Wicket using JAMon

Posted by Eelco Hillenius <ee...@gmail.com>.
On Jan 30, 2008 11:14 AM, Igor Vaynberg <ig...@gmail.com> wrote:
> because he wants to know what page instance was accessed?

He wants to monitor performance of requests from what I read.

Eelco

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Monitoring Wicket using JAMon

Posted by Igor Vaynberg <ig...@gmail.com>.
because he wants to know what page instance was accessed?

-igor


On Jan 30, 2008 11:11 AM, Eelco Hillenius <ee...@gmail.com> wrote:
> > 1. ISessionStore.onBeginRequest and ISessionStore.onEndRequest
> > 2. RequestCycle.onBeginRequest and RequestCycle.onEndRequest.
> >
> > For now I choose to override the ISessionStore because that one is
> > called before and after the RequestCycle methods. I want to check with
> > you guys if this is the best option or not. Which one do you
> > recommend? Is there maybe another candidate I overlooked?
>
> Logically, 2 is nicer, but 1 might give you more clean results. Why
> not use WicketFilter though? If you need/ want separate methods, you
> could just create your own variant of WicketFilter.
>
> Eelco
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Monitoring Wicket using JAMon

Posted by Eelco Hillenius <ee...@gmail.com>.
> 1. ISessionStore.onBeginRequest and ISessionStore.onEndRequest
> 2. RequestCycle.onBeginRequest and RequestCycle.onEndRequest.
>
> For now I choose to override the ISessionStore because that one is
> called before and after the RequestCycle methods. I want to check with
> you guys if this is the best option or not. Which one do you
> recommend? Is there maybe another candidate I overlooked?

Logically, 2 is nicer, but 1 might give you more clean results. Why
not use WicketFilter though? If you need/ want separate methods, you
could just create your own variant of WicketFilter.

Eelco

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org