@Override
  public void beforeCompile(QueryLifeTimeHookContext ctx) {
    if (metrics != null) {
      compilingQryScp = metrics.createScope(MetricsConstant.HS2_COMPILING_QUERIES);
    }
  }
LifeTimeHook gathering metrics for the query lifecycle if the
metrics are enabled
ql/src/java/org/apache/hadoop/hive/ql/hooks/MetricsQueryLifeTimeHook.java