APISonar


com.codahale.metrics.Timer.time

> com > codahale > metrics > Timer > time
com APIs codahale APIs metrics APIs Timer APIs time APIs

Example 1
private final Timer requestTimes;

  public void startRequest() {
    numRequests.incrementAndGet();
    currentTimer = requestTimes.time();
  }
Example 2
private static Timer _getCurrentRunParametersTimer;

  public static Context getCurrentRunParametersTimerContext() {
    if(_getCurrentRunParametersTimer!=null)
    {
      return _getCurrentRunParametersTimer.time();
    }else
    {
      return null;
    }
  }
Example 3
public void testTwoTimers() throws IOException, InterruptedException {
		Timer t = metricRegistry.timer(name("response_time").tag("foo", "bar").build());
		Timer.Context time = t.time();
		Thread.sleep(1L);
		time.stop();
		Timer t2 = metricRegistry.timer(name("response_time").tag("foo", "baz").build());
		Timer.Context time2 = t2.time();
		Thread.sleep(1L);
		time2.stop();

		assertTypeHelpTimer("response_time");
	}
Example 4
private final Timer commitTimer;

    private void commit() {
        if (db.isClosed()) {
            return;
        }
        final Timer.Context time = commitTimer.time();
        if (LOG.isDebugEnabled()) {
            LOG.debug("Committing {} (entries {})", getDbFileName(), size());
        }
        db.commit();
        time.stop();
    }
Example 5
public static Context startTimer(Timer timer) {
        if (timer != null) {
            return timer.time();
        }
        return null;
    }
Example 6
public StartedTimersPair(Timer timer1, Timer timer2) {
        time1 = timer1.time();
        time2 = timer2.time();
    }
Example 7
private final Timer postTimer;

    public void post(Object event) {
        try (final Timer.Context ignored = postTimer.time()) {
            super.post(event);
        }
    }
Example 8
private final Timer gets;

    public Optional<P> authenticate(C credentials) throws AuthenticationException {
        final Timer.Context context = gets.time();
        try {
            return cache.get(credentials);
        } catch (ExecutionException e) {
            throw new AuthenticationException(e);
        } finally {
            context.stop();
        }
    }
Example 9
private Timer entCreateBatchTimer;

    public <A extends Entity> A create( String entityType, Class<A> entityClass,
            Map<String, Object> properties, UUID importId ) throws Exception {

        Timer.Context timeEntityCassCreation = entCreateBatchTimer.time();


        A entity = batchCreate( entityType, entityClass, properties, importId);

        //Adding graphite metrics
        timeEntityCassCreation.stop();

        return entity;
    }
Example 10
private final Timer cleanupDuration;

    public void cleanUp() throws IOException {
        try (Timer.Context t = cleanupDuration.time()) {
            containerMemoryTracker.remove(port);
            cleanUpForRestart();
        } catch (IOException e) {
            //This may or may not be reported depending on when process exits
            numCleanupExceptions.mark();
            throw e;
        }
    }
Example 11
private Timer cleanTimer = null;

  public Timer.Context getCleanCtx() {
    if (config.isMetricsOn() && cleanTimer == null) {
      cleanTimer = createTimer(cleanTimerName);
    }
    return cleanTimer == null ? null : cleanTimer.time();
  }
Example 12
private Timer indexTimer = null;

  public Timer.Context getIndexCtx() {
    if (config.isMetricsOn() && indexTimer == null) {
      indexTimer = createTimer(indexTimerName);
    }
    return indexTimer == null ? null : indexTimer.time();
  }
Example 13
private Timer overallTimer = null;

  public Timer.Context getOverallTimerContext() {
    if (config.isMetricsOn() && overallTimer == null) {
      overallTimer = createTimer(overallTimerName);
    }
    return overallTimer == null ? null : overallTimer.time();
  }
Example 14
private Timer rollbackTimer = null;

  public Timer.Context getRollbackCtx() {
    if (config.isMetricsOn() && rollbackTimer == null) {
      rollbackTimer = createTimer(rollbackTimerName);
    }
    return rollbackTimer == null ? null : rollbackTimer.time();
  }
Example 15
public Timer hiveSyncTimer = null;

  public Timer.Context getHiveSyncTimerContext() {
    if (config.isMetricsOn() && hiveSyncTimer == null) {
      hiveSyncTimer = createTimer(hiveSyncTimerName);
    }
    return hiveSyncTimer == null ? null : hiveSyncTimer.time();
  }
Example 16
private Timer commitTimer = null;

  public Timer.Context getCommitCtx() {
    if (config.isMetricsOn() && commitTimer == null) {
      commitTimer = createTimer(commitTimerName);
    }
    return commitTimer == null ? null : commitTimer.time();
  }
Example 17
private Timer finalizeTimer = null;

  public Timer.Context getFinalizeCtx() {
    if (config.isMetricsOn() && finalizeTimer == null) {
      finalizeTimer = createTimer(finalizeTimerName);
    }
    return finalizeTimer == null ? null : finalizeTimer.time();
  }
Example 18
private Timer compactionTimer = null;

  public Timer.Context getCompactionCtx() {
    if (config.isMetricsOn() && compactionTimer == null) {
      compactionTimer = createTimer(commitTimerName);
    }
    return compactionTimer == null ? null : compactionTimer.time();
  }
Example 19
private Timer deltaCommitTimer = null;

  public Timer.Context getDeltaCommitCtx() {
    if (config.isMetricsOn() && deltaCommitTimer == null) {
      deltaCommitTimer = createTimer(deltaCommitTimerName);
    }
    return deltaCommitTimer == null ? null : deltaCommitTimer.time();
  }
Example 20
private final Timer getTimer, putTimer;

    public Element get(Object key) throws IllegalStateException, CacheException {
        final Timer.Context ctx = getTimer.time();
        try {
            return underlyingCache.get(key);
        } finally {
            ctx.stop();
        }
    }
Example 21
private final Timer timer;

    public void run() {
        try {
            if (!queue.isEmpty()) {
                Timer.Context ctx = timer.time();
                commit();
                ctx.close();
            }
        } catch (Exception ex) {
            LOGGER.error("Could not commit batch.", ex);
        }
    }
Example 22
private final Timer eventInsertTimer = Metrics.timer(EventElasticSearchIO.class,
            "Insertion time for events");

    public void insert(String tenantId, Map<String, Object> event) throws IOException {
        Timer.Context eventInsertTimerContext = eventInsertTimer.time();

        try {
            event.put(Event.FieldLabels.tenantId.toString(), tenantId);
            elasticsearchRestHelper.indexEvent(event);
        }
        finally {
            eventInsertTimerContext.stop();
        }
    }
Example 23
private Timer entCreateTimer;

    public Entity create( Id id, Map<String, Object> properties ) throws Exception {

        //Adding graphite metrics
        Timer.Context timeCassCreation = entCreateTimer.time();

        Entity entity = batchCreate( id.getType(), null, properties, id.getUuid());

        timeCassCreation.stop();

        return entity;
    }
Example 24
private static final Timer          clearAccountTimer = metricRegistry.timer(name(MessagesCache.class, "clearAccount"));

  public void clear(String destination) {
    Timer.Context timer = clearAccountTimer.time();

    try {
      for (int i = 1; i < 255; i++) {
        clear(destination, i);
      }
    } finally {
      timer.stop();
    }
  }
Example 25
protected final Timer waiting;

    public Future<?> submit(Runnable runnable) {
        submitted.mark();
        Timer.Context waitingTimerContext = waiting.time();
        return delegate.submit(new InstrumentedRunnable(runnable, waitingTimerContext));
    }