private static void preparePerfLogger(QueryInfo queryInfo, PerfLogger perfLogger) throws NoSuchFieldException,
      IllegalAccessException {
    // this reflection hack is for making us able to mock some values to the thread local perfLogger
    // which is otherwise not accessible
    Field startTimesField = perfLogger.getClass().getDeclaredField("startTimes");
    Field endTimesField = perfLogger.getClass().getDeclaredField("endTimes");
    startTimesField.setAccessible(true);
    endTimesField.setAccessible(true);
    final ConcurrentMap<String, Long> startTimes = (ConcurrentMap)startTimesField.get(perfLogger);
    final ConcurrentMap<String, Long> endTimes = (ConcurrentMap)endTimesField.get(perfLogger);

    // COMPILE (planning)
    startTimes.put(PerfLogger.COMPILE, queryInfo.getBeginTime());
    long compileEndTime = queryInfo.getBeginTime() + DummyRecord.PLANNING_DURATION;
    endTimes.put(PerfLogger.COMPILE, compileEndTime);

    // GET_SESSION
    long getSessionStartTime = compileEndTime + DummyRecord.PREPARE_PLAN_DURATION;
    startTimes.put(PerfLogger.TEZ_GET_SESSION, getSessionStartTime);
    long getSessionEndTime = getSessionStartTime + DummyRecord.GET_SESSION_DURATION;
    endTimes.put(PerfLogger.TEZ_GET_SESSION, getSessionEndTime);

    // let's ignore DAG submission time for the sake of this unit test
    startTimes.put(PerfLogger.TEZ_SUBMIT_DAG, getSessionEndTime);
    endTimes.put(PerfLogger.TEZ_SUBMIT_DAG, getSessionEndTime);

    startTimes.put(PerfLogger.TEZ_RUN_DAG, getSessionEndTime);
    long runTezDagEndTime = getSessionEndTime + DummyRecord.EXECUTION_DURATION;
    endTimes.put(PerfLogger.TEZ_RUN_DAG, runTezDagEndTime);
  }
This unit test asserts that the record is created as expected from the various hive source objects like:
DriverContext, SessionState, QueryInfo, etc.
itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/queryhistory/TestQueryHistoryService.java