Examples of TimerContext


Examples of com.yammer.metrics.core.TimerContext

    private static final com.yammer.metrics.core.Timer putTimer =
            Metrics.newTimer(TextEntityResource.class, "puts", TimeUnit.MILLISECONDS, TimeUnit.SECONDS);

    @POST
    public String echo(final String text) {
        final TimerContext timer = postTimer.time();
        try {
            return text;
        } finally {
            timer.stop();
        }
    }
View Full Code Here

Examples of org.springside.modules.metrics.Timer.TimerContext

   * /api/v1/user/1.json 返回json
   * /api/v1/user/1 返回xml(why?)
   */
  @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  public UserDTO getUser(@PathVariable("id") Long id) {
    final TimerContext exectuionTimer = executionMetrics.start();
    try {
      User user = accountService.getUser(id);

      if (user == null) {
        String message = "用户不存在(id:" + id + ")";
        logger.warn(message);
        throw new RestException(HttpStatus.NOT_FOUND, message);
      }

      // 使用Dozer转换DTO类,并补充Dozer不能自动绑定的属性
      UserDTO dto = BeanMapper.map(user, UserDTO.class);
      dto.setTeamId(user.getTeam().getId());
      return dto;
    } finally {
      exectuionTimer.stop();
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.