/**
   * @param res Query result.
   * @param err Error or {@code null} if query executed successfully.
   * @param startTime Start time.
   * @param duration Duration.
   */
  public void onExecuted(Object res, Throwable err, long startTime, long duration) {
    boolean fail = err != null;

    // Update own metrics.
    metrics.onQueryExecute(duration, fail);

    // Update metrics in query manager.
    cctx.queries().onMetricsUpdate(duration, fail);

    if (log.isDebugEnabled())
      log.debug(
          "Query execution finished [qry="
              + this
              + ", startTime="
              + startTime
              + ", duration="
              + duration
              + ", fail="
              + fail
              + ", res="
              + res
              + ']');
  }
 @Override
 public GridCacheQueryMetrics metrics() {
   return metrics.copy();
 }