Search code examples
javaweb-serviceslatencyrestlet

Log response-time in restlet-based webservice


What is the simplest way to log the response-time for a restlet-based webservice?

I want to make sure that our webservice has a reasonable response time. So I want to be able to keep an eye on response times, and do something about the requests that take too long.

The closest thing I could find is this recipe: http://www.naviquan.com/blog/restlet-cookbook-log, it explains how to change the log format. But there doesn't seem to be a parameter for response times, so probably a completely different approach is needed.


Solution

  • Well, the simplest way of logging response times is, of course, by calling System.getCurrentTimeMillis() at the start of your restlet, and then again at the end of your restlet and logging the difference. That won't of course give you the framework overhead, and I suspect it's much more naive and trivial than you are after.

    I'm posting it, however, because after 10 days nobody has answered you, and I suspect it's because everybody's quietly thinking

    "Can't you just use System.getCurrentTimeMillis()? No, surely that's way too dumb an answer; I'd look like an idiot if I said that. I'll just wait for someone else to make the first post."