A timer basically is a combination of a histogram and a meter and can again be declared via an annotation:
@GET@Path("/hello")@Timed(name="helloTime", absolute = true, description = "Timing of the Hello call", tags={"type=timer","app=shop"})public String getHelloTimed() { try { Thread.sleep((long) (Math.random()*200.0)); } catch (InterruptedException e) { // We don't care if the sleep is interrupted. } return "Hello World";}
The code in this example waits for a small random amount of time to make the output a bit more interesting.