You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by jburkhardt <jb...@gmail.com> on 2010/09/17 19:23:17 UTC

best practice for logging execution time

Title is a little weird as I didn't quite know the proper way to phrase this.

I'm interested in logging the duration of certain things, such as how long
it takes the file component to read or write a file, how long it takes the
jms component to publish or consume a message, etc.
As an example, my first instinct was to extend the JmsProducer class and add
a start() and stop() call to a timer class in the doSend function.  This
would certainly have the intended effect, but doing this for each and every
component I want metrics on would be tedious to say the least.

Is there a simpler, general way to achieve this in camel?  I've taken a
brief look at the Tracer and Interceptor and don't see quite how I'd be able
to use them to log execution times of individual components.  Perhaps I'm
missing something.  I would love to be able to do this all from Spring DSL
and keep the actual Java code to a minimum but I realize that may be wishful
thinking.
Any help would be appreciated.
-- 
View this message in context: http://camel.465427.n5.nabble.com/best-practice-for-logging-execution-time-tp2844045p2844045.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: best practice for logging execution time

Posted by Bilgin Ibryam <bi...@gmail.com>.
You can get these kind of statistics using JMX too
Did you see http://camel.apache.org/camel-jmx.html

Bilgin

On 29 July 2013 23:20, salemi <sa...@avaya.com> wrote:
> I like to identify the average execution time spent in Camel. I have a
> aggregator that aggregate 10 messages before it send them out to the
> endpoint.
> Would EventNotifier still work?
>
>
>
> -----
> Alireza Salemi
> --
> View this message in context: http://camel.465427.n5.nabble.com/best-practice-for-logging-execution-time-tp2844045p5736458.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

Re: best practice for logging execution time

Posted by salemi <sa...@avaya.com>.
Claus,


I have to figure out how many messages we can put trough one Camel instance.
We need to at least manage to route 1000 messages a second.

Looking at the JMX stats I see each message takes about 10ms. I was
wondering how can Identify where the times are spent and how I can improve
my route!

What the route does is receive a messages from JMS topic convert it from
JSON String to a JSON Object and for send tto javaspaces. The javaspaces
right is a clusted write do the performance is bad. So I added a aggregator
in front of the javaspaces and now I am writing 10 messages at the time to
javaspaces. So the question how to measure the times from receiving the 10
messages received until they get written in javaspaces.  

<route>
<from uri="jms:topic:topic1">
<unmarshal ref="csJSON"/>
<to uri="direct:javaspaces"/>
<route>
  
<route id="javaspaces" shutdownRunningTask="CompleteCurrentTaskOnly"
autoStartup="true">
<from uri="direct:javaspaces"/>
<transacted/>
<aggregate strategyRef="aggregatorStrategy" completionSize="10"
completionTimeout="1000">
<correlationExpression>
<simple>${body.entity}</simple>
</correlationExpression>
<bean ref="jsInterface"/>
</aggregate>
</route>



-----
Alireza Salemi
--
View this message in context: http://camel.465427.n5.nabble.com/best-practice-for-logging-execution-time-tp2844045p5736506.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: best practice for logging execution time

Posted by Christian Posta <ch...@gmail.com>.
You can also take a look at the Log component which allows you to log
groups of exchanges based on number or based on time:

from("activemq:orders").to(
"log:com.mycompany.order?level=DEBUG&groupInterval=10000&groupDelay=60000&groupActiveOnly=false"
).to("bean:processOrder");


http://camel.apache.org/log.html


On Tue, Jul 30, 2013 at 8:23 AM, Claus Ibsen <cl...@gmail.com> wrote:

> On Tue, Jul 30, 2013 at 12:20 AM, salemi <sa...@avaya.com> wrote:
> > I like to identify the average execution time spent in Camel. I have a
> > aggregator that aggregate 10 messages before it send them out to the
> > endpoint.
> > Would EventNotifier still work?
> >
>
> It depends what and how fine grained you want to measure?
> So what do you mean by "execution time spent in Camel" ?
>
> And as Bilgin wrote you can also get a lot of stats from JMX.
>
>
>
>
> >
> >
> > -----
> > Alireza Salemi
> > --
> > View this message in context:
> http://camel.465427.n5.nabble.com/best-practice-for-logging-execution-time-tp2844045p5736458.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: cibsen@redhat.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
>



-- 
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta

Re: best practice for logging execution time

Posted by Claus Ibsen <cl...@gmail.com>.
The JMX stats is per Exchange in the processor nodes.
There is JMX stats per route as well which would then be "per route"
And likewise a JMX stats for the entire CamelContext.

So you have 3 different levels of stats.


So in your aggregate route, you will have stats for all incoming
exchanges into the aggregator.
And stats for the outgoing. So you can have 10 incoming, and 1 outgoing exchange




On Fri, Aug 2, 2013 at 2:31 AM, salemi <sa...@avaya.com> wrote:
>
>
> I have the following route and aggregating the 10 Exchanges into one. Now
> when I run Camel JMX and it provides mewith the meanProcessingTime. What
> does that mean for the route below. Is  the mean time for a exchange that
> contains 10 exchanges or for each exchange that arrives trough JMS?
>
> <route>
> <from uri="jms:topic:topic1">
> <unmarshal ref="csJSON"/>
> <to uri="direct:javaspaces"/>
> <route>
>
> <route id="javaspaces" shutdownRunningTask="CompleteCurrentTaskOnly"
> autoStartup="true">
> <from uri="direct:javaspaces"/>
> <transacted/>
> <aggregate strategyRef="aggregatorStrategy" completionSize="10"
> completionTimeout="1000">
> <correlationExpression>
> <simple>${body.entity}</simple>
> </correlationExpression>
> <bean ref="jsInterface"/>
> </aggregate>
> </route>
>
>
>
>
>
> -----
> Alireza Salemi
> --
> View this message in context: http://camel.465427.n5.nabble.com/best-practice-for-logging-execution-time-tp2844045p5736667.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: best practice for logging execution time

Posted by salemi <sa...@avaya.com>.

I have the following route and aggregating the 10 Exchanges into one. Now
when I run Camel JMX and it provides mewith the meanProcessingTime. What
does that mean for the route below. Is  the mean time for a exchange that
contains 10 exchanges or for each exchange that arrives trough JMS?

<route>
<from uri="jms:topic:topic1">
<unmarshal ref="csJSON"/>
<to uri="direct:javaspaces"/>
<route>
 
<route id="javaspaces" shutdownRunningTask="CompleteCurrentTaskOnly"
autoStartup="true">
<from uri="direct:javaspaces"/>
<transacted/>
<aggregate strategyRef="aggregatorStrategy" completionSize="10"
completionTimeout="1000">
<correlationExpression>
<simple>${body.entity}</simple>
</correlationExpression>
<bean ref="jsInterface"/>
</aggregate>
</route> 





-----
Alireza Salemi
--
View this message in context: http://camel.465427.n5.nabble.com/best-practice-for-logging-execution-time-tp2844045p5736667.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: best practice for logging execution time

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Jul 30, 2013 at 12:20 AM, salemi <sa...@avaya.com> wrote:
> I like to identify the average execution time spent in Camel. I have a
> aggregator that aggregate 10 messages before it send them out to the
> endpoint.
> Would EventNotifier still work?
>

It depends what and how fine grained you want to measure?
So what do you mean by "execution time spent in Camel" ?

And as Bilgin wrote you can also get a lot of stats from JMX.




>
>
> -----
> Alireza Salemi
> --
> View this message in context: http://camel.465427.n5.nabble.com/best-practice-for-logging-execution-time-tp2844045p5736458.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: best practice for logging execution time

Posted by salemi <sa...@avaya.com>.
I like to identify the average execution time spent in Camel. I have a
aggregator that aggregate 10 messages before it send them out to the
endpoint.
Would EventNotifier still work?



-----
Alireza Salemi
--
View this message in context: http://camel.465427.n5.nabble.com/best-practice-for-logging-execution-time-tp2844045p5736458.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: best practice for logging execution time

Posted by Claus Ibsen <cl...@gmail.com>.
Yeah you can use EventNotifier and listen on ExchangeSentEvent's which
has the time recorded as well.
http://camel.apache.org/eventnotifier-to-log-details-about-all-sent-exchanges.html



On Fri, Sep 17, 2010 at 7:23 PM, jburkhardt <jb...@gmail.com> wrote:
>
> Title is a little weird as I didn't quite know the proper way to phrase this.
>
> I'm interested in logging the duration of certain things, such as how long
> it takes the file component to read or write a file, how long it takes the
> jms component to publish or consume a message, etc.
> As an example, my first instinct was to extend the JmsProducer class and add
> a start() and stop() call to a timer class in the doSend function.  This
> would certainly have the intended effect, but doing this for each and every
> component I want metrics on would be tedious to say the least.
>
> Is there a simpler, general way to achieve this in camel?  I've taken a
> brief look at the Tracer and Interceptor and don't see quite how I'd be able
> to use them to log execution times of individual components.  Perhaps I'm
> missing something.  I would love to be able to do this all from Spring DSL
> and keep the actual Java code to a minimum but I realize that may be wishful
> thinking.
> Any help would be appreciated.
> --
> View this message in context: http://camel.465427.n5.nabble.com/best-practice-for-logging-execution-time-tp2844045p2844045.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus