private void beginMetrics(String method) {
    Timer timer = Metrics.getOrCreateTimer(MetricsConstants.API_PREFIX + method);
    if (timer != null) {
      timerContexts.put(method, timer.time());
    }
    timer = Metrics.getOrCreateTimer(MetricsConstants.TOTAL_API_CALLS);
    if (timer != null) {
      totalApiCallsTimerContext = timer.time();
    }
  }
Call this function in correspondence of PerfLogBegin to mark the end of the measurement.
@param callerName
@param method
@return long duration  the difference between now and startTime, or -1 if startTime is null
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/metrics/PerfLogger.java