private void endMetrics(String method) {
    Timer.Context context = timerContexts.remove(method);
    if (context != null) {
      context.close();
    }
    if (totalApiCallsTimerContext != null) {
      totalApiCallsTimerContext.close();
    }
  }
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