Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I'm trying to create a process for better understand what's happening in my code. I want to create metrics to automatically give my answers about simple or complex questions like:

  1. How many times a url was clicked? (how many requests arrived to a certain servlet method)
  2. How many times a certain user requested the same page?
  3. How many requests are pending in a queue on average?

and so on...

Is there an easy way to do this automatically and elegantly (for example - attribute like @CountHits would be great)?

I found this open source: http://metrics.codahale.com/getting-started/#reporting-via-jmx But it's too coupled to the code. Not so elegant :/

share|improve this question
1  
I don't know of anything as nice as @CountHits, but if you implement that could you please let us know? ;) –  FrustratedWithFormsDesigner Jun 10 '13 at 21:04
    
Sure :) I found something that does that but not as elegant as I wish. –  Avi Jun 10 '13 at 21:25
    
@FrustratedWithFormsDesigner - Have a look at my edit. It's something. –  Avi Jun 10 '13 at 21:27
add comment

3 Answers

Depends on when you want to measure, you can use http://perfinsp.sourceforge.net/jprof.html in development to get a profile of your program. I've never use is, but I've used 'gprof' for non-java codes.

If you want to monitor your program in production, you can try http://newrelic.com. It gives you basically everything you mentioned and more but involve some cost. I think using it for a few months should help iron out most of the stuff that need to be fixed.

Both of them don't require any modification to your code.

share|improve this answer
add comment

http://newrelic.com/ is a newish service that might help you.

It's essentially a profiler with web-based display, and can show number of invokations per minute of a specific method. YMMV.

share|improve this answer
    
Thanks, checking it out. BTW - I'm oriented to conclude about user behaviors than performance. Although I guess metrics are metrics and if it's reach enough it might help. –  Avi Jun 11 '13 at 7:03
add comment

As far as I know there aren't anything like @CountHits. But if you are so keen in knowing the metrics like the no of clicks and all I would suggest you to use a logging library like log4j to log all the event details and then use a search/analyze tool like Splunk(http://www.splunk.com/) to find out whatever interests you in an elegant way.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.